jjb: lttng-modules: update ubuntu crossbuild jobs
[lttng-ci.git] / scripts / lttng-modules / param-build.sh
CommitLineData
51c9c62d 1#!/bin/bash
f3d8604b 2#
51c9c62d 3# Copyright (C) 2016-2019 Michael Jeanson <mjeanson@efficios.com>
f3d8604b
MJ
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
51c9c62d
MJ
18set -exu
19
39961776 20# Parameters
447eaf93
KS
21platforms=${platforms:-}
22# Derive arch from label if it isn't set
23if [ -z "${arch:-}" ] ; then
24 # Labels may be platform specific, eg. jammy-amd64, deb12-armhf
25 regex='[[:alnum:]]+-([[:alnum:]]+)'
26 if [[ "${platforms}" =~ ${regex} ]] ; then
27 arch="${BASH_REMATCH[1]}"
28 else
29 arch="${platforms:-}"
30 fi
31fi
a86b55bc 32
39961776
MJ
33cross_arch=${cross_arch:-}
34ktag=${ktag:-}
5a196804
MJ
35kgitrepo=${kgitrepo:-}
36mversion=${mversion:-}
37mgitrepo=${mgitrepo:-}
a86b55bc
KS
38make_args=()
39
40DEBUG=${DEBUG:-}
39961776 41
339db64d
MJ
42## FUNCTIONS ##
43
f3d8604b
MJ
44# Kernel version compare functions
45verlte() {
51fa2ab3 46 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ]
f3d8604b
MJ
47}
48
49verlt() {
28b10e79 50 # shellcheck disable=SC2015
51fa2ab3 51 [ "$1" = "$2" ] && return 1 || verlte "$1" "$2"
f3d8604b
MJ
52}
53
54vergte() {
51fa2ab3 55 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -n1)" ]
f3d8604b
MJ
56}
57
58vergt() {
28b10e79 59 # shellcheck disable=SC2015
51fa2ab3 60 [ "$1" = "$2" ] && return 1 || vergte "$1" "$2"
f3d8604b
MJ
61}
62
5a196804
MJ
63git_clone_modules_sources() {
64 mkdir -p "$MODULES_GIT_DIR"
28b10e79
MJ
65
66 # If the version starts with "refs/", checkout the specific git ref, otherwise treat it
67 # as a branch name.
68 if [ "${mversion:0:5}" = "refs/" ]; then
69 git clone --no-tags --depth=1 "${mgitrepo}" "$MODULES_GIT_DIR"
70 (cd "$MODULES_GIT_DIR" && git fetch origin "${mversion}" && git checkout FETCH_HEAD)
71 else
72 git clone --no-tags --depth=1 -b "${mversion}" "${mgitrepo}" "$MODULES_GIT_DIR"
73 fi
5a196804
MJ
74}
75
76# Checkout a shallow kernel tree of the specified tag
77git_clone_linux_sources() {
78 mkdir -p "$LINUX_GIT_DIR"
79 git clone --depth=1 -b "${ktag}" --reference "$LINUX_GIT_REF_REPO_DIR" "${kgitrepo}" "$LINUX_GIT_DIR"
80}
7e02032c 81
7e02032c 82
5a196804
MJ
83# Export the kernel sources from the git repo
84git_export_linux_sources() {
85 cd "$LINUX_GIT_DIR"
86 git archive "${ktag}" | tar -x -C "$LINUX_SRCOBJ_DIR"
87}
88
89
90# Upload the tar archive to the object store
91upload_archive_obj() {
92 s3cmd -c "$WORKSPACE/.s3cfg" put "$WORKSPACE/$obj_name" "$obj_url_prefix/"
93 rm -f "$WORKSPACE/$obj_name"
94}
95
96
97extract_archive_obj() {
02c6a56a 98 tar -xf "$WORKSPACE/$obj_name" -C "$LINUX_OBJ_DIR" -I pbzip2
5a196804
MJ
99 rm -f "$WORKSPACE/$obj_name"
100}
101
102
103tar_archive_obj() {
104 cd "$LINUX_OBJ_DIR"
105 tar -cf "$WORKSPACE/$obj_name" -I pbzip2 .
106 cd -
107}
108
6c0b2710
KS
109list_gccs() {
110 local gccs
111 gccs=()
112 IFS=: read -r -a path_array <<< "$PATH"
113 while read -r gcc ; do
114 gccs+=("$gcc")
115 done < <(find "${path_array[@]}" -maxdepth 1 -regex '.*/gcc-[0-9\.]+$' -printf '%f\n' | sort -t- -k2 -V -r)
116 echo "${gccs[@]}"
117}
118
5a196804
MJ
119# Find the most recent GCC version supported by the kernel sources
120select_compiler() {
121 local selected_cc
122
123 cd "$LINUX_SRCOBJ_DIR"
124
125 kversion=$(make -s kernelversion)
126
127 set +e
128
6c0b2710 129 for cc in $(list_gccs) ; do
a86b55bc
KS
130 if "${CROSS_COMPILE:-}${cc}" -I include/ -D__LINUX_COMPILER_H -D__LINUX_COMPILER_TYPES_H -E include/linux/compiler-gcc.h; then
131 cc_version=$(echo "${cc}" | cut -d'-' -f2)
132 if { verlt "${kversion}" "5.17"; } && { vergt "${cc_version}" "11"; } ; then
133 # Using gcc-12+ with '-Wuse-after-free' breaks the build of older
134 # kernels (in particular, objtool). Some releases on LTS
135 # branches between 4.x and 5.15 can be built with gcc-12.
136 # @see https://lore.kernel.org/lkml/20494.1643237814@turing-police/
137 # @see https://gitlab.com/linux-kernel/stable/-/commit/52a9dab6d892763b2a8334a568bd4e2c1a6fde66
138 continue
139 fi
5a196804
MJ
140 selected_cc="$cc"
141 break
142 fi
143 done
144
145 set -e
146
a86b55bc
KS
147 # Force gcc-4.8 for kernels before 4.4
148 if { verlt "$kversion" "4.4"; }; then
149 selected_cc='gcc-4.8'
150 fi
151
efdab1b7 152 if [ -z "$selected_cc" ]; then
5a196804
MJ
153 echo "Found no suitable compiler."
154 exit 1
155 fi
156
a86b55bc
KS
157 _KAFLAGS=()
158 _KCFLAGS=()
159 _KCPPFLAGS=()
160 _HOSTCFLAGS=()
425e4992
MJ
161 if [ "$selected_cc" != "gcc-4.8" ]; then
162 # Older kernel Makefiles do not expect the compiler to default to PIE
a86b55bc
KS
163 _KAFLAGS+=(-fno-pie)
164 _KCFLAGS+=(
165 -fno-pie
166 -no-pie
167 -fno-stack-protector
168 )
169 _KCPPFLAGS+=(-fno-pie)
170 fi
171
172 selected_cc_version="$(echo "${selected_cc}" | cut -d'-' -f2)"
173 if { vergte "${selected_cc_version}" "10"; } && { verlt "${kversion}" "5.10"; } ; then
174 # gcc-10 changed the default from '-fcommon' to '-fno-common', which
175 # causes a linker failure. '-fcommon' can be set on the HOSTCFLAGS
176 # to avoid the issue.
177 # @see https://gitlab.com/linux-kernel/stable/-/commit/e33a814e772cdc36436c8c188d8c42d019fda639
178 _HOSTCFLAGS+=(-fcommon)
179 fi
180
181 if [ "${cross_arch:-}" == "armhf" ] ; then
182 if { verlt "${kversion}" "5.14"; } ; then
183 # Work-around for producing instructions that aren't valid for the
184 # default architectures.
185 # Eg. Error: selected processor does not support `cpsid i' in ARM mode
186 _KCFLAGS+=(-march=armv7-a -mfpu=vfpv3-d16)
187 _KCPPFLAGS+=(-march=armv7-a -mfpu=vfpv3-d16)
188 fi
189 fi
190
191 if { vergt "${selected_cc_version}" "8"; } && { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.17"; } ; then
192 # This was added to -Wall in gcc 9 but some kernels do not include the fixes
193 # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88583
194 _KCFLAGS+=(-Wno-error=packed-not-aligned)
425e4992
MJ
195 fi
196
a86b55bc
KS
197 export KAFLAGS="${_KAFLAGS[*]}"
198 export KCFLAGS="${_KCFLAGS[*]}"
199 export KCPPFLAGS="${_KCPPFLAGS[*]}"
200 export HOSTCFLAGS="${_HOSTCFLAGS[*]}"
5a196804 201 export CC="${CROSS_COMPILE:-}${selected_cc}"
1d5a0a3c 202 export HOSTCC="${selected_cc}"
5a196804 203
a86b55bc
KS
204 make_args=(
205 CC="${CC}"
206 HOSTCC="${HOSTCC}"
207 HOSTCFLAGS="${HOSTCFLAGS:-}"
208 )
209 if [ -n "${DEBUG}" ] ; then
210 make_args+=(
211 V=1
212 )
213 fi
5a196804
MJ
214 cd -
215}
216
a86b55bc
KS
217patch_linux_kernel() {
218 local commit_hash
219 commit_hash="$1"
220 set +e
221 git -C "${LINUX_GIT_REF_REPO_DIR}" format-patch -n1 --stdout "${commit_hash}" | patch -p1
222 set -e
223 if [ "$?" -gt 1 ] ; then
224 echo "Serious issue patching"
225 exit 1
226 fi
227}
5a196804
MJ
228
229build_linux_kernel() {
230 cd "$LINUX_SRCOBJ_DIR"
231
a86b55bc 232 kversion=$(make -s kernelversion "${make_args[@]}")
23ebcd4b 233 pahole_version="$(pahole --version | tr -d 'v')"
a86b55bc
KS
234
235 if { verlt "${kversion}" "3.3"; } && [ "${vanilla_config}" = "imx_v6_v7_defconfig" ] ; then
236 # imx_v6_v7 didn't exist before 06965c39b4c63933fa0a1cde2237ef85477c5655
237 if { verlt "${kversion}" "3.2"; } ; then
238 vanilla_config='mx5_defconfig'
239 else
240 vanilla_config='mx51_defconfig'
241 fi
242 fi
243
244 if { verlt "${kversion}" "3.13"; } && [ "${vanilla_config}" = "pseries_le_defconfig" ] ; then
245 # pseries_le_deconfig was introduced in f53e462e907cbaed29c49c0f10f5b8f614e1bf1d
246 vanilla_config='pseries_defconfig'
247 fi
5a196804 248
7e02032c 249 # Generate kernel configuration
a1ae361e 250 case "$ktag" in
7e02032c 251 Ubuntu*)
39961776 252 if [ "${cross_arch}" = "powerpc" ]; then
5a196804 253 if vergte "${kversion}" "4.10"; then
39961776
MJ
254 echo "Ubuntu removed big endian powerpc configuration from kernel >= 4.10. Don't try to build it."
255 exit 0
256 fi
257 fi
af101606 258
0c1bde3d
KS
259 fakeroot debian/rules clean KW_DEFCONFIG_DIR=.
260
073dc82c 261 # Hack for kernel Ubuntu-hwe-5.8
0c1bde3d
KS
262 # The debian/control file is produced by the clean target above, so this
263 # check needs to happen afterwards.
264 if [ ! -f "debian/compat" ] && ! grep -q debhelper-compat debian/control; then
073dc82c
MJ
265 echo "10" > "debian/compat"
266 fi
267
0c1bde3d
KS
268 # genconfigs check can fail in certain cases, eg. when a more recent
269 # compiler exposes kernel configuration flags which aren't set in the
270 # Ubuntu annotations.
271 # In any case, the configuration will be updated with any missing values
272 # later in our build script.
273 fakeroot debian/rules genconfigs KW_DEFCONFIG_DIR=. do_skip_checks=true
5a196804 274 cp CONFIGS/"${ubuntu_config}" .config
7e02032c 275 ;;
c45b04df 276
7e02032c 277 *)
16844a6d
MJ
278 # Force 32bit build on i386, default is 64bit
279 if [ "$arch" = "i386" ]; then
5a196804
MJ
280 export ARCH="i386"
281 fi
282
a86b55bc 283 make "${vanilla_config}" "${make_args[@]}"
7e02032c
MJ
284 ;;
285 esac
286
a86b55bc
KS
287 if [ "${vanilla_config}" = "pseries_defconfig" ] && [ "${cross_arch}" = "ppc64el" ] ; then
288 # @see diff <(git show v3.13:arch/powerpc/configs/pseries_defconfig) <(git show v3.13:arch/powerpc/configs/pseries_le_defconfig)
289 scripts/config --enable CONFIG_CPU_LITTLE_ENDIAN
290 scripts/config --enable CONFIG_CMA
291 scripts/config --disable CONFIG_XMON_DEFAULT
292 # scripts/config --disable CONFIG_VIRTUALIZATION
293 # scripts/config --disable CONFIG_KVM_BOOK3S_64
294 scripts/config --disable CONFIG_KVM_BOOK3S_64_HV
295 fi
296
53b51a15 297 # oldnoconfig was renamed in 4.19
5a196804 298 if vergte "$kversion" "4.19"; then
53b51a15 299 update_conf_target="olddefconfig"
5a196804 300 else
53b51a15 301 update_conf_target="oldnoconfig"
5a196804
MJ
302 fi
303
304 # Fix 'defined(@array)' was removed from recent perl
305 if [ -f "kernel/timeconst.pl" ]; then
306 sed -i 's/defined(\@\(.*\))/@\1/' kernel/timeconst.pl
307 fi
308
309 # Fix syntax of inline assembly which is confused with C++11 raw strings on gcc >= 5
53b51a15 310 if [ "$HOSTCC" != "gcc-4.8" ]; then
5a196804
MJ
311 if [ -f "arch/x86/kvm/svm.c" ]; then
312 sed -i 's/ R"/ R "/g; s/"R"/" R "/g' arch/x86/kvm/svm.c
313 fi
314
315 if [ -f "arch/x86/kvm/vmx.c" ]; then
316 sed -i 's/ R"/ R "/g; s/"R"/" R "/g' arch/x86/kvm/vmx.c
317 fi
318 fi
319
a86b55bc
KS
320 if { verlt "${kversion}" "5.11"; } && { vergte "${kversion}" "4.10"; } ; then
321 # Binutils > 2.35 strips empty symbol tables, causing obltool to fail
322 # in certain cases when files are empty.
323 # @see https://gitlab.com/linux-kernel/stable/-/commit/1d489151e9f9d1647110277ff77282fe4d96d09b
324 #
325 # There doesn't seem to be any LD/AS/AR flags to control this behaviour,
326 # therefore patching tools/objtool/elf.c is attempted.
327 patch_linux_kernel 1d489151e9f9d1647110277ff77282fe4d96d09b
328 if { verlt "${kversion}" "4.18"; } ; then
329 patch_linux_kernel e81e0724432542af8d8c702c31e9d82f57b1ff31
330 fi
331 fi
332
333 if { vergt "${selected_cc_version}" "7"; } && { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.17"; } ; then
334 # Builds fail due to -Werror=restrict in pager.o and str_error_r.o
335 if { verlt "${kversion}" "4.16"; } ; then
336 # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS
337 # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ad343a98e74e85aa91d844310e797f96fee6983b
338 patch_linux_kernel ad343a98e74e85aa91d844310e797f96fee6983b
339 fi
340 if { verlt "${kversion}" "4.17"; } ; then
341 # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS
342 # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=854e55ad289ef8888e7991f0ada85d5846f5afb9
343 patch_linux_kernel 854e55ad289ef8888e7991f0ada85d5846f5afb9
344 fi
345
ad23f63b
KS
346 fi
347
348 if { vergt "${selected_cc_version}" "9"; } && { verlt "${kversion}" "5.6"; } ; then
a86b55bc
KS
349 # Duplicate decalarations of __force_order
350 # @see https://gitlab.com/linux-kernel/stable/-/commit/df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
ad23f63b 351 patch_linux_kernel df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
a86b55bc
KS
352 # However, kaslr_64.c doesn't exit in 4.15, 4.16, it's named pagetable.c
353 if [ -f arch/x86/boot/compressed/pagetable.c ] ; then
354 sed -i '/^unsigned long __force_order;$/d' arch/x86/boot/compressed/pagetable.c
355 fi
356 fi
357
358 if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ; then
359 # Some old kernels fail to build when make is too new
360 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
361 patch_linux_kernel 9564a8cf422d7b58f6e857e3546d346fa970191e
362 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
363 patch_linux_kernel 9feeb638cde083c737e295c0547f1b4f28e99583
364 fi
365
7b15f9fa
KS
366 if { vergte "${kversion}" "4.12"; } && { verlt "${kversion}" "4.19"; } ; then
367 # Old kernels can fail to build while on newer host kernels with errors
368 # such as:
369 # In file included from scripts/selinux/genheaders/genheaders.c:19:
370 # ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map.
a86b55bc
KS
371 # @see https://gitlab.com/linux-kernel/stable/-/commit/dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
372 #
373 patch_linux_kernel dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
374 fi
375
376 if { vergte "${kversion}" "3.18"; } && { verlt "${kversion}" "4.4"; } ; then
377 # Compatibility with binutils >= ~ 2.31
378 patch_linux_kernel b21ebf2fb4cde1618915a97cc773e287ff49173e
379 fi
380
381 # The above patch only partially applies linux 3.17, and has been, so a
382 # rebased version is used instead.
383 if { vergte "${kversion}" "3.17"; } && { verlt "${kversion}" "3.18"; } ; then
384 cat <<'EOF' | patch -p1
385diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
386index 48598105..0652c5b6 100644
387--- a/arch/x86/kernel/machine_kexec_64.c
388+++ b/arch/x86/kernel/machine_kexec_64.c
389@@ -516,6 +516,7 @@ int arch_kexec_apply_relocations_add(const Elf64_Ehdr *ehdr,
390 goto overflow;
391 break;
392 case R_X86_64_PC32:
393+ case R_X86_64_PLT32:
394 value -= (u64)address;
395 *(u32 *)location = value;
396 break;
397diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
398index e69f9882..7c6bc9fe 100644
399--- a/arch/x86/kernel/module.c
400+++ b/arch/x86/kernel/module.c
401@@ -180,6 +180,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
402 goto overflow;
403 break;
404 case R_X86_64_PC32:
405+ case R_X86_64_PLT32:
406 val -= (u64)loc;
407 *(u32 *)loc = val;
408 #if 0
409diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
410index bbb1d225..8deeacbc 100644
411--- a/arch/x86/tools/relocs.c
412+++ b/arch/x86/tools/relocs.c
413@@ -763,6 +763,7 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
414 switch (r_type) {
415 case R_X86_64_NONE:
416 case R_X86_64_PC32:
417+ case R_X86_64_PLT32:
418 /*
419 * NONE can be ignored and PC relative relocations don't
420 * need to be adjusted.
421EOF
422 fi
423
4d7942d1 424 if ( { vergte "${kversion}" "3.14"; } && { verlt "${kversion}" "4.4"; } ) ||
a86b55bc
KS
425 ( { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.17"; } ); then
426 # While the original motivation of this patch is for fixing builds using
4d7942d1 427 # clang, the same error occurs between linux >= 3.14 and < 4.4, and in
a86b55bc
KS
428 # 4.15, 4.16.
429 #
430 # This patch only partially applies due to changes in kernel/Makefile,
431 # so a supplementary patch is needed
432 #
433 # Without this patch, builds fail with
434 # Cannot find symbol for section 2: .text.
435 # kernel/elfcore.o: failed
436 #
437 # @see https://github.com/linuxppc/issues/issues/388
438 # @see https://lore.kernel.org/lkml/20201204165742.3815221-2-arnd@kernel.org/
439 #
440 patch_linux_kernel 6e7b64b9dd6d96537d816ea07ec26b7dedd397b9
441 if grep -q elfcore.o kernel/Makefile ; then
442 sed -i '/^.* += elfcore.o$/d' kernel/Makefile
443 fi
444 fi
9bbfa9db
MJ
445 # Same as above for the v4.4 branch
446 if ( { vergte "${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.257"; } ); then
447 patch_linux_kernel 3140b0740b31cc63cf2ee08bc3f746b423eb068d
448 if grep -q elfcore.o kernel/Makefile ; then
449 sed -i '/^.* += elfcore.o$/d' kernel/Makefile
450 fi
451 fi
a86b55bc 452
15ef760e
MJ
453 if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ; then
454 # Kernels between v4.5 and v4.8 built with gcc >= 8 on arm will hit an
455 # assembler error :
456 #
457 # kernel/.tmp_fork.s: Assembler messages:
458 # kernel/.tmp_fork.s:1790: Error: .err encountered
459 #
460 # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85745
461 #
462 patch_linux_kernel 9f73bd8bb445e0cbe4bcef6d4cfc788f1e184007
463 fi
464
53b51a15
MJ
465 # Newer binutils don't accept 3 operand 'cmp' instructions on ppc64
466 # Convert them to 'cmpw' which was previously done silently
467 if verlt "$kversion" "4.9"; then
468 find arch/powerpc/ -name "*.S" -print0 | xargs -0 sed -i "s/\(cmp\)\(\s\+[a-zA-Z0-9]\+,\s*[a-zA-Z0-9]\+,\s*[a-zA-Z0-9]\+\)/cmpw\2/"
469 find arch/powerpc/ -name "*.S" -print0 | xargs -0 sed -i "s/\(cmpli\)\(\s\+[a-zA-Z0-9]\+,\s*[a-zA-Z0-9]\+,\s*[a-zA-Z0-9]\+\)/cmplwi\2/"
470 sed -i "s/\$pie \-o \"\$ofile\"/\$pie --no-dynamic-linker -o \"\$ofile\"/" arch/powerpc/boot/wrapper
471 fi
472
5a196804
MJ
473 # Fix a typo in v2.6.36.x
474 if [ -f "arch/x86/kernel/entry_64.S" ]; then
475 sed -i 's/END(do_hypervisor_callback)/END(xen_do_hypervisor_callback)/' arch/x86/kernel/entry_64.S
476 fi
477
53b51a15
MJ
478 # Fix compiler switch in vdso Makefile for 2.6.36 to 2.6.36.2
479 if { vergte "$kversion" "2.6.36" && verlte "$kversion" "2.6.36.3"; }; then
480 sed -i 's/-m elf_x86_64/-m64/' arch/x86/vdso/Makefile
481 sed -i 's/-m elf_i386/-m32/' arch/x86/vdso/Makefile
482 fi
483
5a196804
MJ
484 # Fix kernel < 3.0 with gcc >= 4.7
485 if verlt "$kversion" "3.0"; then
486 sed -i '/linux\/compiler.h/a #include <linux\/linkage.h> \/* For asmregparm *\/' arch/x86/include/asm/ptrace.h
487 sed -i 's/extern long syscall_trace_enter/extern asmregparm long syscall_trace_enter/' arch/x86/include/asm/ptrace.h
488 sed -i 's/extern void syscall_trace_leave/extern asmregparm void syscall_trace_leave/' arch/x86/include/asm/ptrace.h
489 echo "header-y += linkage.h" >> include/linux/Kbuild
490 fi
491
a86b55bc
KS
492 if [ "${cross_arch}" = "powerpc" ] ; then
493 if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.16"; } ; then
494 # Avoid register errors such as
495 # aes_generic.c:(.text+0x4e0): undefined reference to `_restgpr_31_x'
496 # @see https://gitlab.com/linux-kernel/stable/-/commit/148b974deea927f5dbb6c468af2707b488bfa2de
497 make_args+=(
498 CFLAGS_aes_generic.o=''
499 )
500 fi
501 fi
502
23ebcd4b
KS
503 if [ "$(scripts/config --state CONFIG_DEBUG_INFO_BTF)" == "y" ] &&
504 { vergte "${pahole_version}" "1.24"; } &&
505 { vergte "${kversion}" "5.10"; } && { verlt "${kversion}" "6.0"; } ;then
506 # Some kernels Eg. Ubuntu-hwe-5.13-5.13.0-52.59_20.04.1
507 # fail with the following error:
508 # BTFIDS vmlinux
509 # FAILED: load BTF from vmlinux: Invalid argument
510 #
511 # When CONFIG_DEBUG_INFO_BTF is set, certain versions of pahole require
512 # `--skip_encoding_btf_enum64` to be passed as the kernel doesn't define
513 # BTF_KIND_ENUM64.
514 #
515 # Introduced in 341dfcf8d78eaa3a2dc96dea06f0392eb2978364 (~v5.10)
516 # @see https://lore.kernel.org/bpf/20220825171620.cioobudss6ovyrkc@altlinux.org/t/
517 #
518 if [ -f "scripts/pahole-flags.sh" ] ; then
519 sed -i 's/ -J ${PAHOLE_FLAGS} / -J ${PAHOLE_FLAGS} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
520 else
521 sed -i 's/ -J ${extra_paholeopt} / -J ${extra_paholeopt} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
522 fi
523 fi
524
7e02032c 525 # GCC 4.8
53b51a15 526 if [ "$HOSTCC" == "gcc-4.8" ]; then
a86b55bc
KS
527 scripts/config --disable CONFIG_CC_STACKPROTECTOR_STRONG
528 scripts/config --disable CONFIG_PPC_OF_BOOT_TRAMPOLINE
53b51a15 529 fi
7e02032c
MJ
530
531 # Don't try to sign modules
53b51a15 532 scripts/config --disable CONFIG_MODULE_SIG
7e02032c 533
9ef18fa2 534 # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails
53b51a15 535 scripts/config --disable CONFIG_STACK_VALIDATION
5a196804
MJ
536
537 # Cause problems with inline assembly on i386
53b51a15 538 scripts/config --disable CONFIG_DEBUG_SECTION_MISMATCH
5a196804 539
1d5a0a3c 540 # Don't build samples, they are broken on some kernel releases
53b51a15
MJ
541 scripts/config --disable CONFIG_SAMPLES
542 scripts/config --disable CONFIG_BUILD_DOCSRC
c45b04df
MJ
543
544 # Disable kcov
53b51a15 545 scripts/config --disable CONFIG_KCOV
c45b04df
MJ
546
547 # Broken on some RT kernels
53b51a15 548 scripts/config --disable CONFIG_HYPERV
1d5a0a3c 549
1e300ea9 550 # Broken drivers
53b51a15
MJ
551 scripts/config --disable CONFIG_RAPIDIO_TSI721
552 scripts/config --disable CONFIG_SGI_XP
553 scripts/config --disable CONFIG_MFD_WM8994
554 scripts/config --disable CONFIG_DRM_RADEON
555 scripts/config --disable CONFIG_SND_SOC_WM5100
a9aea01c
KS
556 # More recent compiler optimizations (from gcc 8 onwards )expose build errors
557 # with netronome on older kernels.
558 # Observed in 4.11-rt, 4.15-4.17, 5.0-rt - 5.16-rt
559 # It seems easier to disable the driver than to attempt patching.
560 # Eg.
561 # In function ‘ur_load_imm_any’,
562 # inlined from ‘jeq_imm’ at drivers/net/ethernet/netronome/nfp/bpf/jit.c:3146:13:
563 # ./include/linux/compiler.h:350:45: error: call to ‘__compiletime_assert_1062’ declared with attribute error: FIELD_FIT: value too large for the field
564 # 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
565 #
566 scripts/config --disable CONFIG_NET_VENDOR_NETRONOME
567 # Eg.
568 # In function ‘memcpy’,
569 # inlined from ‘kszphy_get_strings’ at drivers/net/phy/micrel.c:664:3:
570 # ./include/linux/string.h:305:25: error: call to ‘__read_overflow2’ declared with attribute error: detected read beyond size of object passed as 2nd parameter
571 # 305 | __read_overflow2();
572 # | ^~~~~~~~~~~~~~~~~~
573 # make[3]: *** [scripts/Makefile.build:308: drivers/net/phy/micrel.o] Error 1
574 #
575 scripts/config --disable CONFIG_MICREL_PHY
576
1e300ea9 577
5a196804
MJ
578 # IGBVF won't build with recent gcc on 2.6.38.x
579 if { vergte "$kversion" "2.6.37" && verlt "$kversion" "2.6.38"; }; then
53b51a15 580 scripts/config --disable CONFIG_IGBVF
5a196804 581 fi
9ef18fa2 582
c72041eb
MJ
583 # Don't fail the build on warnings
584 scripts/config --disable CONFIG_WERROR
a86b55bc 585 scripts/config --enable CONFIG_PPC_DISABLE_WERROR
c72041eb 586
51fa2ab3 587 # Set required options
53b51a15
MJ
588 scripts/config --enable CONFIG_TRACEPOINTS
589 scripts/config --enable CONFIG_KALLSYMS
590 scripts/config --enable CONFIG_HIGH_RES_TIMERS
591 scripts/config --enable CONFIG_KPROBES
592 scripts/config --enable CONFIG_FTRACE
593 scripts/config --enable CONFIG_BLK_DEV_IO_TRACE
594 scripts/config --enable CONFIG_KALLSYMS_ALL
595 scripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTS
596 scripts/config --enable CONFIG_PERF_EVENTS
597 scripts/config --enable CONFIG_EVENT_TRACING
598 scripts/config --enable CONFIG_KRETPROBES
7e02032c 599
a86b55bc
KS
600 if [ -n "${DEBUG}" ] ; then
601 cat .config
602 fi
5a196804 603
a86b55bc
KS
604 make "$update_conf_target" "${make_args[@]}"
605 make -j"$NPROC" "${make_args[@]}"
5a196804 606
80eda7bb 607 krelease=$(make -s kernelrelease "${make_args[@]}")
5a196804
MJ
608
609 # Save the kernel and modules
610 mkdir -p "$LINUX_INSTOBJ_DIR/boot"
a86b55bc
KS
611 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install "${make_args[@]}"
612 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install "${make_args[@]}"
5a196804
MJ
613 rm -f "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/build"
614 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
615 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
616}
617
618
619extract_distro_headers() {
620
621 # Enter linux source dir
622 cd "${LINUX_SRCOBJ_DIR}"
623
624
625 # For RT kernels, copy version file
626 if [ -s localversion-rt ]; then
627 cp -a localversion-rt "${LINUX_HDROBJ_DIR}"
628 fi
629
630 # Copy all Makefile related stuff
631 find . -path './include/*' -prune \
632 -o -path './scripts/*' -prune -o -type f \
633 \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
634 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
635 -print | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
636
637 # Copy base scripts and include dirs
638 cp -a scripts include "${LINUX_HDROBJ_DIR}"
7e02032c 639
5a196804
MJ
640 # Copy arch includes
641 (find arch -name include -type d -print0 | \
efdab1b7 642 xargs -0 -n1 -I '{}' find '{}' -type f) | \
5a196804
MJ
643 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
644
645 # Copy arch scripts
646 (find arch -name scripts -type d -print0 | \
efdab1b7 647 xargs -0 -n1 -I '{}' find '{}' -type f) | \
5a196804
MJ
648 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
649
650 # Cleanup scripts
651 rm -f "${LINUX_HDROBJ_DIR}/scripts/*.o"
652 rm -f "${LINUX_HDROBJ_DIR}/scripts/*/*.o"
653
04873cc3 654 # On powerpc 32bits this object is required to link modules
5a196804 655 if [ "${karch}" = "powerpc" ]; then
efdab1b7 656 if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then
10528202
MJ
657 :
658 else
04873cc3
MJ
659 cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LINUX_HDROBJ_DIR}/"
660 fi
5a196804
MJ
661 fi
662
663 # On arm64 between 4.13 and 1.15 this object is required to build with ftrace support
664 if [ "${karch}" = "arm64" ]; then
665 if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
666 cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LINUX_HDROBJ_DIR}/"
667 fi
668 fi
669
670 # Newer kernels need objtool to build modules when CONFIG_STACK_VALIDATION=y
671 if [ -f tools/objtool/objtool ]; then
672 cp -a --parents tools/objtool/objtool "${LINUX_HDROBJ_DIR}/"
673 fi
674
675 if [ -f "arch/x86/kernel/macros.s" ]; then
676 cp -a --parents arch/x86/kernel/macros.s "${LINUX_HDROBJ_DIR}/"
677 fi
678
679 # Copy modules related stuff, if available
680 if [ -s Module.symvers ]; then
681 cp Module.symvers "${LINUX_HDROBJ_DIR}"
682 fi
683
684 if [ -s System.map ]; then
685 cp System.map "${LINUX_HDROBJ_DIR}"
686 fi
687
688 if [ -s Module.markers ]; then
689 cp Module.markers "${LINUX_HDROBJ_DIR}"
690 fi
691
692 # Copy config file
693 cp .config "${LINUX_HDROBJ_DIR}"
694
695 # Make sure the Makefile and version.h have a matching timestamp so that
696 # external modules can be built
697 if [ -s "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" ]; then
698 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h"
699 elif [ -s "${LINUX_HDROBJ_DIR}/include/linux/version.h" ]; then
700 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/linux/version.h"
701 else
702 echo "Missing version.h"
703 exit 1
704 fi
705 touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h"
706
707 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
780f6285
MJ
708 if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then
709 cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
710 fi
5a196804
MJ
711
712 # Finally clean the object files from the full source tree
713 make clean
714
715 # And regen the modules support files
a86b55bc 716 make modules_prepare "${make_args[@]}"
51fa2ab3 717
04873cc3 718 # On powerpc 32bits this object is required to link modules
d815b018 719 if [ "${karch}" = "powerpc" ]; then
efdab1b7 720 if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then
10528202
MJ
721 :
722 else
a86b55bc 723 make arch/powerpc/lib/crtsavres.o "${make_args[@]}"
04873cc3 724 fi
d815b018
MJ
725 fi
726
7a76a4d0 727 # On arm64 between 4.13 and 4.15 this object is required to build with ftrace support
a1ae361e 728 if [ "${karch}" = "arm64" ]; then
c236528e 729 if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
a86b55bc 730 make arch/arm64/kernel/ftrace-mod.o "${make_args[@]}"
a1ae361e
MJ
731 fi
732 fi
733
7e02032c 734 # Version specific tasks
a1ae361e 735 case "$ktag" in
7e02032c
MJ
736 Ubuntu*)
737 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
a1ae361e 738 ABINUM="$(echo "$ktag" | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')"
5a196804
MJ
739 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> include/generated/utsrelease.h
740 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h"
7e02032c
MJ
741 ;;
742 esac
7e02032c
MJ
743}
744
745
339db64d
MJ
746build_modules() {
747
5a196804
MJ
748 local kdir="$1"
749 local outdir="$2"
750 local kversion
751
752 kversion=$(make -C "$LINUX_HDROBJ_DIR" -s kernelversion)
339db64d 753
2456f978
MJ
754 # Try to catch some compatibility problems by turning some
755 # warnings into errors.
999a2aa0 756 #export KCFLAGS="$KCFLAGS -Wall -Werror"
2456f978 757
339db64d 758 # Enter lttng-modules source dir
5a196804 759 cd "${MODULES_GIT_DIR}"
339db64d
MJ
760
761 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
762 # timekeeping subsystem. We want those build to fail.
5a196804
MJ
763 if { vergte "$kversion" "3.10" && verlte "$kversion" "3.10.13"; } || \
764 { vergte "$kversion" "3.11" && verlte "$kversion" "3.11.2"; }; then
339db64d
MJ
765
766 set +e
767
768 # Build modules
a86b55bc 769 KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
0f71a764 770 ret=$?
339db64d 771
5a196804
MJ
772 set -e
773
339db64d 774 # We expect this build to fail, if it doesn't, fail the job.
0f71a764 775 if [ "$ret" -eq 0 ]; then
e9b44189 776 echo "This build should have failed."
339db64d
MJ
777 exit 1
778 fi
779
780 # We have to publish at least one file or the build will fail
5a196804 781 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${outdir}/BROKEN.txt.ko"
339db64d 782
5a196804 783 KERNELDIR="${kdir}" make clean
7e02032c 784
339db64d
MJ
785 else # Regular build
786
787 # Build modules against full kernel sources
a86b55bc 788 KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
339db64d
MJ
789
790 # Install modules to build dir
5a196804 791 KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${outdir}" modules_install
339db64d
MJ
792
793 # Clean build dir
5a196804 794 KERNELDIR="${kdir}" make clean
339db64d
MJ
795 fi
796}
797
798
799## MAIN ##
800
f3d8604b
MJ
801# Use all CPU cores
802NPROC=$(nproc)
803
5a196804
MJ
804MODULES_GIT_DIR="${WORKSPACE}/src/lttng-modules"
805LINUX_GIT_DIR="${WORKSPACE}/src/linux"
339db64d 806
5a196804
MJ
807LINUX_OBJ_DIR="${WORKSPACE}/linux"
808LINUX_SRCOBJ_DIR="${LINUX_OBJ_DIR}/sources"
809LINUX_HDROBJ_DIR="${LINUX_OBJ_DIR}/headers"
810LINUX_INSTOBJ_DIR="${LINUX_OBJ_DIR}/install"
339db64d 811
5a196804
MJ
812MODULES_OUTPUT_KSRC_DIR="${WORKSPACE}/build/lttng-modules-ksrc"
813MODULES_OUTPUT_KHDR_DIR="${WORKSPACE}/build/lttng-modules-khdr"
339db64d 814
5a196804
MJ
815LINUX_GIT_REF_REPO_DIR="$HOME/gitcache/linux-stable.git/"
816
817OBJ_STORE_URL="s3://jenkins"
818
819cd "$WORKSPACE"
820
821# Create build directories
822mkdir -p "${LINUX_SRCOBJ_DIR}" "${LINUX_HDROBJ_DIR}" "${LINUX_INSTOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
823
824git_clone_modules_sources
339db64d 825
7e02032c 826# Setup cross compile env if available
39961776 827if [ "x${cross_arch}" != "x" ]; then
7e02032c
MJ
828
829 case "$cross_arch" in
830 "armhf")
831 karch="arm"
832 cross_compile="arm-linux-gnueabihf-"
53b51a15 833 vanilla_config="imx_v6_v7_defconfig"
7e02032c
MJ
834 ubuntu_config="armhf-config.flavour.generic"
835 ;;
836
837 "arm64")
838 karch="arm64"
839 cross_compile="aarch64-linux-gnu-"
53b51a15 840 vanilla_config="defconfig"
7e02032c
MJ
841 ubuntu_config="arm64-config.flavour.generic"
842 ;;
843
844 "powerpc")
845 karch="powerpc"
846 cross_compile="powerpc-linux-gnu-"
e9b44189 847 vanilla_config="ppc44x_defconfig"
7e02032c
MJ
848 ubuntu_config="powerpc-config.flavour.powerpc-smp"
849 ;;
850
851 "ppc64el")
852 karch="powerpc"
853 cross_compile="powerpc64le-linux-gnu-"
e9b44189 854 vanilla_config="pseries_le_defconfig"
7e02032c
MJ
855 ubuntu_config="ppc64el-config.flavour.generic"
856 ;;
857
858 *)
51fa2ab3 859 echo "Unsupported cross arch $cross_arch"
7e02032c
MJ
860 exit 1
861 ;;
862 esac
339db64d 863
7e02032c
MJ
864 # Export variables used by Kbuild for cross compilation
865 export ARCH="${karch}"
866 export CROSS_COMPILE="${cross_compile}"
339db64d 867
7e02032c 868# Set arch specific values if we are not cross compiling
39961776 869elif [ "x${arch}" != "x" ]; then
e9b44189 870
7e02032c 871 case "$arch" in
16844a6d 872 "i386")
7e02032c 873 karch="x86"
1490b049 874 vanilla_config="allmodconfig"
7e02032c
MJ
875 ubuntu_config="i386-config.flavour.generic"
876 ;;
877
16844a6d 878 "amd64")
7e02032c 879 karch="x86"
1490b049 880 vanilla_config="allmodconfig"
7e02032c
MJ
881 ubuntu_config="amd64-config.flavour.generic"
882 ;;
883
884 "armhf")
885 karch="arm"
1490b049 886 vanilla_config="allmodconfig"
7e02032c
MJ
887 ubuntu_config="armhf-config.flavour.generic"
888 ;;
889
890 "arm64")
891 karch="arm64"
1490b049 892 vanilla_config="allmodconfig"
7e02032c
MJ
893 ubuntu_config="arm64-config.flavour.generic"
894 ;;
895
896 "powerpc")
897 karch="powerpc"
1490b049 898 vanilla_config="allmodconfig"
7e02032c
MJ
899 ubuntu_config="powerpc-config.flavour.powerpc-smp"
900 ;;
901
902 "ppc64el")
903 karch="powerpc"
1490b049 904 vanilla_config="allmodconfig"
7e02032c
MJ
905 ubuntu_config="ppc64el-config.flavour.generic"
906 ;;
907
908 *)
909 echo "Unsupported arch $arch"
910 exit 1
911 ;;
912 esac
913else
04873cc3 914 echo "No arch or cross_arch specified"
7e02032c
MJ
915 exit 1
916fi
339db64d 917
339db64d 918
b214d997 919
5a196804
MJ
920# First get the kernel build from the object store, or build it, if it's
921# not available.
339db64d 922
5a196804
MJ
923echo "# Setup endpoint
924host_base = obj.internal.efficios.com
925host_bucket = obj.internal.efficios.com
926bucket_location = us-east-1
927use_https = True
7e02032c 928
5a196804
MJ
929# Setup access keys
930access_key = jenkins
931secret_key = echo123456
339db64d 932
5a196804
MJ
933# Enable S3 v4 signature APIs
934signature_v2 = False" > "$WORKSPACE/.s3cfg"
339db64d 935
c45b04df 936url_hash="$(echo -n "$kgitrepo" | md5sum | awk '{ print $1 }')"
5a196804 937obj_name="linux.tar.bz2"
87445931 938
efdab1b7 939if [ -z "${cross_arch}" ]; then
909c5352 940 obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platforms}/$arch/native"
87445931 941else
909c5352 942 obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platforms}/${cross_arch}"
87445931
MJ
943fi
944
5a196804 945obj_url="$obj_url_prefix/$obj_name"
339db64d 946
5a196804 947set +e
e18b6e95
KS
948# In s3cmd 2.3, the return code of get when an object does not exist (64)
949# is different than in 2.2 (12). The return codes of 's3cmd info' are
950# consistent between 2.2 and 2.3.
951s3cmd -c "$WORKSPACE/.s3cfg" info "$obj_url"
5a196804
MJ
952ret=$?
953set -e
339db64d 954
5a196804
MJ
955case "$ret" in
956 "0")
e18b6e95 957 s3cmd -c "$WORKSPACE/.s3cfg" get "$obj_url"
5a196804
MJ
958 extract_archive_obj
959 ;;
a1ae361e 960
5a196804
MJ
961 "12")
962 echo "File not found"
339db64d 963
5a196804
MJ
964 # Build all the things and upload
965 # then finish the module build...
339db64d 966
5a196804
MJ
967 git_clone_linux_sources
968 git_export_linux_sources
339db64d 969
5a196804 970 select_compiler
a1ae361e 971
5a196804
MJ
972 ## PREPARE FULL LINUX SOURCE TREE
973 build_linux_kernel
d138fc44 974
5a196804
MJ
975 ## EXTRACT DISTRO STYLE KERNEL HEADERS / DEVEL
976 extract_distro_headers
339db64d 977
5a196804 978 tar_archive_obj
339db64d 979
5a196804 980 upload_archive_obj
339db64d 981
5a196804 982 ;;
339db64d 983
5a196804
MJ
984 *)
985 echo "Unknown error? Abort"
986 exit 1
987 ;;
988esac
339db64d 989
5a196804 990select_compiler
f3d8604b 991
a86b55bc
KS
992selected_cc_version="$(echo "${selected_cc}" | cut -d'-' -f2)"
993# lttng-modules requires gcc >= 5.1 for aarch64
994# @see https://github.com/lttng/lttng-modules/commit/be06402dbdbea2f3394e60ec15c5d3356e2be416
995if { verlt "${selected_cc_version}" "5.1"; } && [ "${cross_arch}" = "arm64" ] ; then
996 echo "Building lltng-modules on aarch64 requires gcc >= 5.1"
997 exit 0
998fi
999
7e02032c 1000## BUILD modules
5a196804
MJ
1001# Either we downloaded a pre-build kernel or we built it and uploaded
1002# the archive for future builds.
1003
1004cd "$WORKSPACE"
f3d8604b 1005
339db64d 1006# Build modules against full kernel sources
5a196804 1007build_modules "${LINUX_SRCOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}"
f3d8604b 1008
339db64d 1009# Build modules against kernel headers
5a196804 1010build_modules "${LINUX_HDROBJ_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
f3d8604b 1011
5a196804
MJ
1012# Make sure some modules were actually built
1013tree "${MODULES_OUTPUT_KSRC_DIR}"
1014if [ "x$(find "${MODULES_OUTPUT_KSRC_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
7e02032c
MJ
1015 echo "No modules built!"
1016 exit 1
1017fi
1018
5a196804
MJ
1019tree "${MODULES_OUTPUT_KHDR_DIR}"
1020if [ "x$(find "${MODULES_OUTPUT_KHDR_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
7e02032c
MJ
1021 echo "No modules built!"
1022 exit 1
1023fi
b214d997 1024
f3d8604b 1025# EOF
This page took 0.081537 seconds and 4 git commands to generate.