jjb: lttng-modules: many kernel build fixes
[lttng-ci.git] / scripts / lttng-modules / param-build.sh
1 #!/bin/bash
2 #
3 # Copyright (C) 2016-2019 Michael Jeanson <mjeanson@efficios.com>
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
18 set -exu
19
20 # Parameters
21 platforms=${platforms:-}
22 # Derive arch from label if it isn't set
23 if [ -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
31 fi
32
33 cross_arch=${cross_arch:-}
34 ktag=${ktag:-}
35 kgitrepo=${kgitrepo:-}
36 mversion=${mversion:-}
37 mgitrepo=${mgitrepo:-}
38 make_args=()
39
40 DEBUG=${DEBUG:-}
41
42 ## FUNCTIONS ##
43
44 # Kernel version compare functions
45 verlte() {
46 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ]
47 }
48
49 verlt() {
50 # shellcheck disable=SC2015
51 [ "$1" = "$2" ] && return 1 || verlte "$1" "$2"
52 }
53
54 vergte() {
55 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -n1)" ]
56 }
57
58 vergt() {
59 # shellcheck disable=SC2015
60 [ "$1" = "$2" ] && return 1 || vergte "$1" "$2"
61 }
62
63 git_clone_modules_sources() {
64 mkdir -p "$MODULES_GIT_DIR"
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
74 }
75
76 # Checkout a shallow kernel tree of the specified tag
77 git_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 }
81
82
83 # Export the kernel sources from the git repo
84 git_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
91 upload_archive_obj() {
92 s3cmd -c "$WORKSPACE/.s3cfg" put "$WORKSPACE/$obj_name" "$obj_url_prefix/"
93 rm -f "$WORKSPACE/$obj_name"
94 }
95
96
97 extract_archive_obj() {
98 tar -xf "$WORKSPACE/$obj_name" -C "$LINUX_OBJ_DIR" -I pbzip2
99 rm -f "$WORKSPACE/$obj_name"
100 }
101
102
103 tar_archive_obj() {
104 cd "$LINUX_OBJ_DIR"
105 tar -cf "$WORKSPACE/$obj_name" -I pbzip2 .
106 cd -
107 }
108
109 list_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
119 # Find the most recent GCC version supported by the kernel sources
120 select_compiler() {
121 local selected_cc
122
123 cd "$LINUX_SRCOBJ_DIR"
124
125 kversion=$(make -s kernelversion)
126
127 set +e
128
129 for cc in $(list_gccs) ; do
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
140 selected_cc="$cc"
141 break
142 fi
143 done
144
145 set -e
146
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
152 if [ -z "$selected_cc" ]; then
153 echo "Found no suitable compiler."
154 exit 1
155 fi
156
157 _KAFLAGS=()
158 _KCFLAGS=()
159 _KCPPFLAGS=()
160 _HOSTCFLAGS=()
161 if [ "$selected_cc" != "gcc-4.8" ]; then
162 # Older kernel Makefiles do not expect the compiler to default to PIE
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)
195 fi
196
197 export KAFLAGS="${_KAFLAGS[*]}"
198 export KCFLAGS="${_KCFLAGS[*]}"
199 export KCPPFLAGS="${_KCPPFLAGS[*]}"
200 export HOSTCFLAGS="${_HOSTCFLAGS[*]}"
201 export CC="${CROSS_COMPILE:-}${selected_cc}"
202 export HOSTCC="${selected_cc}"
203
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
214 cd -
215 }
216
217 patch_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 }
228
229 build_linux_kernel() {
230 cd "$LINUX_SRCOBJ_DIR"
231
232 kversion=$(make -s kernelversion "${make_args[@]}")
233 pahole_version="$(pahole --version | tr -d 'v')"
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
248
249 # Generate kernel configuration
250 case "$ktag" in
251 Ubuntu*)
252 if [ "${cross_arch}" = "powerpc" ]; then
253 if vergte "${kversion}" "4.10"; then
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
258
259 fakeroot debian/rules clean KW_DEFCONFIG_DIR=.
260
261 # Hack for kernel Ubuntu-hwe-5.8
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
265 echo "10" > "debian/compat"
266 fi
267
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
274 cp CONFIGS/"${ubuntu_config}" .config
275 ;;
276
277 *)
278 # Force 32bit build on i386, default is 64bit
279 if [ "$arch" = "i386" ]; then
280 export ARCH="i386"
281 fi
282
283 make "${vanilla_config}" "${make_args[@]}"
284 ;;
285 esac
286
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
297 # oldnoconfig was renamed in 4.19
298 if vergte "$kversion" "4.19"; then
299 update_conf_target="olddefconfig"
300 else
301 update_conf_target="oldnoconfig"
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
310 if [ "$HOSTCC" != "gcc-4.8" ]; then
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
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.14"; } && { 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
346 fi
347
348 if { vergt "${selected_cc_version}" "9"; } && { verlt "${kversion}" "5.6"; } ; then
349 # Duplicate decalarations of __force_order
350 # @see https://gitlab.com/linux-kernel/stable/-/commit/df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
351 # However, kaslr_64.c doesn't exit in 4.15, 4.16, it's named pagetable.c
352 if [ -f arch/x86/boot/compressed/pagetable.c ] ; then
353 sed -i '/^unsigned long __force_order;$/d' arch/x86/boot/compressed/pagetable.c
354 fi
355 if [ -f arch/x86/boot/compressed/kaslr_64.c ] ; then
356 patch_linux_kernel df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
357 fi
358 fi
359
360 if { vergte "${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then
361 # In some cases, compiling net/bpfilter can fail with the following error:
362 # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory
363 # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1
364 #
365 # While the issue is potentially in a number of old versions, it has only
366 # been observed in v4.18-rt
367 #
368 patch_linux_kernel 303a339f30a9441c4695d3d2cc78f1b33cd959ff
369 fi
370
371 if { vergte "${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then
372 # In some cases, compiling net/bpfilter can fail with the following error:
373 # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory
374 # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1
375 #
376 # While the issue is potentially in a number of old versions, it has only
377 # been observed in v4.18-rt
378 #
379 patch_linux_kernel 303a339f30a9441c4695d3d2cc78f1b33cd959ff
380 fi
381
382 if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ; then
383 # Some old kernels fail to build when make is too new
384 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
385 patch_linux_kernel 9564a8cf422d7b58f6e857e3546d346fa970191e
386 fi
387
388 if { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.55"; } ; then
389 # Some old kernels fail to build when make is too new
390 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
391 patch_linux_kernel e82885490a611f2b75a6c27cd7bb09665c1740be
392 fi
393
394 if ( { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ) || \
395 ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.56"; } ) ; then
396 # Some old kernels fail to build when make is too new
397 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
398 patch_linux_kernel 9feeb638cde083c737e295c0547f1b4f28e99583
399 fi
400
401 if ( { vergte "${kversion}" "4.12"; } && { verlt "${kversion}" "4.20.17"; } ) || \
402 ( { vergte "${kversion}" "5.0"; } && { verlt "${kversion}" "5.0.12"; } ) ; then
403 # Old kernels can fail to build while on newer host kernels with errors
404 # such as:
405 # In file included from scripts/selinux/genheaders/genheaders.c:19:
406 # ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map.
407 # @see https://gitlab.com/linux-kernel/stable/-/commit/dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
408 #
409 patch_linux_kernel dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
410 fi
411
412 if { vergte "${kversion}" "3.18"; } && { verlt "${kversion}" "4.16"; } ; then
413 # Compatibility with binutils >= ~ 2.31
414 patch_linux_kernel b21ebf2fb4cde1618915a97cc773e287ff49173e
415 fi
416
417 # The above patch only partially applies linux 3.17, and has been, so a
418 # rebased version is used instead.
419 if { vergte "${kversion}" "3.17"; } && { verlt "${kversion}" "3.18"; } ; then
420 cat <<'EOF' | patch -p1
421 diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
422 index 48598105..0652c5b6 100644
423 --- a/arch/x86/kernel/machine_kexec_64.c
424 +++ b/arch/x86/kernel/machine_kexec_64.c
425 @@ -516,6 +516,7 @@ int arch_kexec_apply_relocations_add(const Elf64_Ehdr *ehdr,
426 goto overflow;
427 break;
428 case R_X86_64_PC32:
429 + case R_X86_64_PLT32:
430 value -= (u64)address;
431 *(u32 *)location = value;
432 break;
433 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
434 index e69f9882..7c6bc9fe 100644
435 --- a/arch/x86/kernel/module.c
436 +++ b/arch/x86/kernel/module.c
437 @@ -180,6 +180,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
438 goto overflow;
439 break;
440 case R_X86_64_PC32:
441 + case R_X86_64_PLT32:
442 val -= (u64)loc;
443 *(u32 *)loc = val;
444 #if 0
445 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
446 index bbb1d225..8deeacbc 100644
447 --- a/arch/x86/tools/relocs.c
448 +++ b/arch/x86/tools/relocs.c
449 @@ -763,6 +763,7 @@ static int do_reloc64(struct section *sec, Elf_Rel *rel, ElfW(Sym) *sym,
450 switch (r_type) {
451 case R_X86_64_NONE:
452 case R_X86_64_PC32:
453 + case R_X86_64_PLT32:
454 /*
455 * NONE can be ignored and PC relative relocations don't
456 * need to be adjusted.
457 EOF
458 fi
459
460 if ( { vergte "${kversion}" "3.14"; } && { verlt "${kversion}" "4.4"; } ) ||
461 ( { vergte "${kversion}" "4.8"; } && { verlt "${kversion}" "4.18"; } ); then
462 # While the original motivation of this patch is for fixing builds using
463 # clang, the same error occurs between linux >= 3.14 and < 4.4, and in
464 # 4.15, 4.16.
465 # For rt-linux, the error has been observed in 4.8, 4.11, and 4.13.
466 #
467 # This patch only partially applies due to changes in kernel/Makefile,
468 # so a supplementary patch is needed
469 #
470 # Without this patch, builds fail with
471 # Cannot find symbol for section 2: .text.
472 # kernel/elfcore.o: failed
473 #
474 # @see https://github.com/linuxppc/issues/issues/388
475 # @see https://lore.kernel.org/lkml/20201204165742.3815221-2-arnd@kernel.org/
476 #
477 patch_linux_kernel 6e7b64b9dd6d96537d816ea07ec26b7dedd397b9
478 if grep -q elfcore.o kernel/Makefile ; then
479 sed -i '/^.* += elfcore.o$/d' kernel/Makefile
480 fi
481 fi
482 # Same as above for the v4.4 branch
483 if ( { vergte "${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.257"; } ); then
484 patch_linux_kernel 3140b0740b31cc63cf2ee08bc3f746b423eb068d
485 if grep -q elfcore.o kernel/Makefile ; then
486 sed -i '/^.* += elfcore.o$/d' kernel/Makefile
487 fi
488 fi
489
490 if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ; then
491 # Kernels between v4.5 and v4.8 built with gcc >= 8 on arm will hit an
492 # assembler error :
493 #
494 # kernel/.tmp_fork.s: Assembler messages:
495 # kernel/.tmp_fork.s:1790: Error: .err encountered
496 #
497 # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85745
498 #
499 patch_linux_kernel 9f73bd8bb445e0cbe4bcef6d4cfc788f1e184007
500 fi
501
502 if ( { vergte "${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.136"; } ) ||
503 ( { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ); then
504 # Hacky patch to deal with the following build error:
505 # Cannot find symbol for section 7: .text.unlikely.
506 # kernel/kexec_file.o: failed
507 # make[1]: *** [scripts/Makefile.build:291: kernel/kexec_file.o] Error 1
508 #
509 # This error happens with binutils 2.36 and 2.37, but should probably not
510 # be an issue with binutils 2.38.
511 # @see https://github.com/linuxppc/issues/issues/388
512 # @see https://github.com/bminor/binutils-gdb/commit/c09c8b42021180eee9495bd50d8b35e683d3901b
513 #
514 # There is some sort of config (unspecified in past discussions) which
515 # provokes the error, and there was never a potential fix merged in
516 # this discussion, in part because the build systems of the kernel
517 # switched to objtool instead.
518 #
519 # @see https://lore.kernel.org/all/20210215162209.5e2a475b@gandalf.local.home/
520 #
521 sed -i 's/return txtname;/return shdr0->sh_size ? txtname : NULL;/' scripts/recordmcount.h
522
523 # After applying the above patch, the build continues but fails with
524 # head64.c:(.text.exit+0x5): undefined reference to `__gcov_exit'
525 #
526 scripts/config --disable CONFIG_GCOV_KERNEL
527 fi
528
529 if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.5.5"; } ; then
530 # drivers/staging/wilc1000/wilc_spi.c:123:34: error: storage size of ‘wilc1000_spi_ops’ isn’t known
531 patch_linux_kernel ce7b516f3f9e11fe4ee06fad0d7e853bb6e8f160
532 fi
533
534 # Newer binutils don't accept 3 operand 'cmp' instructions on ppc64
535 # Convert them to 'cmpw' which was previously done silently
536 if verlt "$kversion" "4.9"; then
537 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/"
538 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/"
539 sed -i "s/\$pie \-o \"\$ofile\"/\$pie --no-dynamic-linker -o \"\$ofile\"/" arch/powerpc/boot/wrapper
540 fi
541
542 if [ "$(scripts/config --state CONFIG_EXTCON_ADC_JACK)" != "n" ] &&
543 ( { vergte "${kversion}" "4.2"; } && { verlt "${kversion}" "4.12"; } ); then
544 # 73b6ecdb93e8e77752cae9077c424fcdc6f23c39 introduced a change where
545 # extcon-adc-jack.h has an incompatible pointer type.
546 # In GCC >= 5 this will provoke a warning and build failure.
547 # Eg.
548 # drivers/extcon/extcon-adc-jack.c: In function ‘adc_jack_probe’:
549 # drivers/extcon/extcon-adc-jack.c:111:64: error: passing argument 2 of ‘devm_extcon_dev_allocate’ from incompatible pointer type [-Werror=incompatible-pointer-types]
550 # make[2]: *** [scripts/Makefile.build:295: drivers/extcon/extcon-adc-jack.o] Error 1
551 #
552 # 8a522bf2d4f788306443d36b26b54f0aedcdfdbe (in 4.11) has a fix for this warning
553 #
554 patch_linux_kernel 8a522bf2d4f788306443d36b26b54f0aedcdfdbe
555 fi
556
557 if ( { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.15.2"; } ) || \
558 ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.18"; } ) ; then
559 # Fix an objtool Segmentation fault
560 patch_linux_kernel dd12561854824fd1f05baf2a1b794faa046e2425
561 fi
562
563 if { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.268"; } ; then
564 # Builds fail due to -Werror=use-after-free in sigchain.o and help.o
565 patch_linux_kernel e89bb266b710ce056f141f29f091fd468a4a8185
566 fi
567
568 # Fix a typo in v2.6.36.x
569 if [ -f "arch/x86/kernel/entry_64.S" ]; then
570 sed -i 's/END(do_hypervisor_callback)/END(xen_do_hypervisor_callback)/' arch/x86/kernel/entry_64.S
571 fi
572
573 # Fix compiler switch in vdso Makefile for 2.6.36 to 2.6.36.2
574 if { vergte "$kversion" "2.6.36" && verlte "$kversion" "2.6.36.3"; }; then
575 sed -i 's/-m elf_x86_64/-m64/' arch/x86/vdso/Makefile
576 sed -i 's/-m elf_i386/-m32/' arch/x86/vdso/Makefile
577 fi
578
579 # Fix kernel < 3.0 with gcc >= 4.7
580 if verlt "$kversion" "3.0"; then
581 sed -i '/linux\/compiler.h/a #include <linux\/linkage.h> \/* For asmregparm *\/' arch/x86/include/asm/ptrace.h
582 sed -i 's/extern long syscall_trace_enter/extern asmregparm long syscall_trace_enter/' arch/x86/include/asm/ptrace.h
583 sed -i 's/extern void syscall_trace_leave/extern asmregparm void syscall_trace_leave/' arch/x86/include/asm/ptrace.h
584 echo "header-y += linkage.h" >> include/linux/Kbuild
585 fi
586
587 if [ "${cross_arch}" = "powerpc" ] ; then
588 if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.16"; } ; then
589 # Avoid register errors such as
590 # aes_generic.c:(.text+0x4e0): undefined reference to `_restgpr_31_x'
591 # @see https://gitlab.com/linux-kernel/stable/-/commit/148b974deea927f5dbb6c468af2707b488bfa2de
592 make_args+=(
593 CFLAGS_aes_generic.o=''
594 )
595 fi
596 fi
597
598 if [ "$(scripts/config --state CONFIG_DEBUG_INFO_BTF)" == "y" ] &&
599 { vergte "${pahole_version}" "1.24"; } &&
600 { vergte "${kversion}" "5.10"; } && { verlt "${kversion}" "6.0"; } ;then
601 # Some kernels Eg. Ubuntu-hwe-5.13-5.13.0-52.59_20.04.1
602 # fail with the following error:
603 # BTFIDS vmlinux
604 # FAILED: load BTF from vmlinux: Invalid argument
605 #
606 # When CONFIG_DEBUG_INFO_BTF is set, certain versions of pahole require
607 # `--skip_encoding_btf_enum64` to be passed as the kernel doesn't define
608 # BTF_KIND_ENUM64.
609 #
610 # Introduced in 341dfcf8d78eaa3a2dc96dea06f0392eb2978364 (~v5.10)
611 # @see https://lore.kernel.org/bpf/20220825171620.cioobudss6ovyrkc@altlinux.org/t/
612 #
613 if [ -f "scripts/pahole-flags.sh" ] ; then
614 sed -i 's/ -J ${PAHOLE_FLAGS} / -J ${PAHOLE_FLAGS} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
615 else
616 sed -i 's/ -J ${extra_paholeopt} / -J ${extra_paholeopt} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
617 fi
618 fi
619
620 # GCC 4.8
621 if [ "$HOSTCC" == "gcc-4.8" ]; then
622 scripts/config --disable CONFIG_CC_STACKPROTECTOR_STRONG
623 scripts/config --disable CONFIG_PPC_OF_BOOT_TRAMPOLINE
624 fi
625
626 # Don't try to sign modules
627 scripts/config --disable CONFIG_MODULE_SIG
628
629 # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails
630 scripts/config --disable CONFIG_STACK_VALIDATION
631
632 # Cause problems with inline assembly on i386
633 scripts/config --disable CONFIG_DEBUG_SECTION_MISMATCH
634
635 # Don't build samples, they are broken on some kernel releases
636 scripts/config --disable CONFIG_SAMPLES
637 scripts/config --disable CONFIG_BUILD_DOCSRC
638
639 # Disable kcov
640 scripts/config --disable CONFIG_KCOV
641
642 # Broken on some RT kernels
643 scripts/config --disable CONFIG_HYPERV
644
645 # Broken drivers
646 scripts/config --disable CONFIG_RAPIDIO_TSI721
647 scripts/config --disable CONFIG_SGI_XP
648 scripts/config --disable CONFIG_MFD_WM8994
649 scripts/config --disable CONFIG_DRM_RADEON
650 scripts/config --disable CONFIG_SND_SOC_WM5100
651 # More recent compiler optimizations (from gcc 8 onwards )expose build errors
652 # with netronome on older kernels.
653 # Observed in 4.11-rt, 4.15-4.17, 5.0-rt - 5.16-rt
654 # It seems easier to disable the driver than to attempt patching.
655 # Eg.
656 # In function ‘ur_load_imm_any’,
657 # inlined from ‘jeq_imm’ at drivers/net/ethernet/netronome/nfp/bpf/jit.c:3146:13:
658 # ./include/linux/compiler.h:350:45: error: call to ‘__compiletime_assert_1062’ declared with attribute error: FIELD_FIT: value too large for the field
659 # 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
660 #
661 scripts/config --disable CONFIG_NET_VENDOR_NETRONOME
662 # Eg.
663 # In function ‘memcpy’,
664 # inlined from ‘kszphy_get_strings’ at drivers/net/phy/micrel.c:664:3:
665 # ./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
666 # 305 | __read_overflow2();
667 # | ^~~~~~~~~~~~~~~~~~
668 # make[3]: *** [scripts/Makefile.build:308: drivers/net/phy/micrel.o] Error 1
669 #
670 scripts/config --disable CONFIG_MICREL_PHY
671
672
673 # IGBVF won't build with recent gcc on 2.6.38.x
674 if { vergte "$kversion" "2.6.37" && verlt "$kversion" "2.6.38"; }; then
675 scripts/config --disable CONFIG_IGBVF
676 fi
677
678 # Don't fail the build on warnings
679 scripts/config --disable CONFIG_WERROR
680 scripts/config --enable CONFIG_PPC_DISABLE_WERROR
681
682 # Set required options
683 scripts/config --enable CONFIG_TRACEPOINTS
684 scripts/config --enable CONFIG_KALLSYMS
685 scripts/config --enable CONFIG_HIGH_RES_TIMERS
686 scripts/config --enable CONFIG_KPROBES
687 scripts/config --enable CONFIG_FTRACE
688 scripts/config --enable CONFIG_BLK_DEV_IO_TRACE
689 scripts/config --enable CONFIG_KALLSYMS_ALL
690 scripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTS
691 scripts/config --enable CONFIG_PERF_EVENTS
692 scripts/config --enable CONFIG_EVENT_TRACING
693 scripts/config --enable CONFIG_KRETPROBES
694
695 if [ -n "${DEBUG}" ] ; then
696 cat .config
697 fi
698
699 make "$update_conf_target" "${make_args[@]}"
700 make -j"$NPROC" "${make_args[@]}"
701
702 krelease=$(make -s kernelrelease "${make_args[@]}")
703
704 # Save the kernel and modules
705 mkdir -p "$LINUX_INSTOBJ_DIR/boot"
706 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install "${make_args[@]}"
707 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install "${make_args[@]}"
708 rm -f "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/build"
709 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
710 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source"
711 }
712
713
714 extract_distro_headers() {
715
716 # Enter linux source dir
717 cd "${LINUX_SRCOBJ_DIR}"
718
719
720 # For RT kernels, copy version file
721 if [ -s localversion-rt ]; then
722 cp -a localversion-rt "${LINUX_HDROBJ_DIR}"
723 fi
724
725 # Copy all Makefile related stuff
726 find . -path './include/*' -prune \
727 -o -path './scripts/*' -prune -o -type f \
728 \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
729 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
730 -print | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
731
732 # Copy base scripts and include dirs
733 cp -a scripts include "${LINUX_HDROBJ_DIR}"
734
735 # Copy arch includes
736 (find arch -name include -type d -print0 | \
737 xargs -0 -n1 -I '{}' find '{}' -type f) | \
738 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
739
740 # Copy arch scripts
741 (find arch -name scripts -type d -print0 | \
742 xargs -0 -n1 -I '{}' find '{}' -type f) | \
743 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
744
745 # Cleanup scripts
746 rm -f "${LINUX_HDROBJ_DIR}/scripts/*.o"
747 rm -f "${LINUX_HDROBJ_DIR}/scripts/*/*.o"
748
749 # On powerpc 32bits this object is required to link modules
750 if [ "${karch}" = "powerpc" ]; then
751 if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then
752 :
753 else
754 cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LINUX_HDROBJ_DIR}/"
755 fi
756 fi
757
758 # On arm64 between 4.13 and 1.15 this object is required to build with ftrace support
759 if [ "${karch}" = "arm64" ]; then
760 if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
761 cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LINUX_HDROBJ_DIR}/"
762 fi
763 fi
764
765 # Newer kernels need objtool to build modules when CONFIG_STACK_VALIDATION=y
766 if [ -f tools/objtool/objtool ]; then
767 cp -a --parents tools/objtool/objtool "${LINUX_HDROBJ_DIR}/"
768 fi
769
770 if [ -f "arch/x86/kernel/macros.s" ]; then
771 cp -a --parents arch/x86/kernel/macros.s "${LINUX_HDROBJ_DIR}/"
772 fi
773
774 # Copy modules related stuff, if available
775 if [ -s Module.symvers ]; then
776 cp Module.symvers "${LINUX_HDROBJ_DIR}"
777 fi
778
779 if [ -s System.map ]; then
780 cp System.map "${LINUX_HDROBJ_DIR}"
781 fi
782
783 if [ -s Module.markers ]; then
784 cp Module.markers "${LINUX_HDROBJ_DIR}"
785 fi
786
787 # Copy config file
788 cp .config "${LINUX_HDROBJ_DIR}"
789
790 # Make sure the Makefile and version.h have a matching timestamp so that
791 # external modules can be built
792 if [ -s "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" ]; then
793 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h"
794 elif [ -s "${LINUX_HDROBJ_DIR}/include/linux/version.h" ]; then
795 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/linux/version.h"
796 else
797 echo "Missing version.h"
798 exit 1
799 fi
800 touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h"
801
802 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
803 if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then
804 cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
805 fi
806
807 # Finally clean the object files from the full source tree
808 make clean
809
810 # And regen the modules support files
811 make modules_prepare "${make_args[@]}"
812
813 # On powerpc 32bits this object is required to link modules
814 if [ "${karch}" = "powerpc" ]; then
815 if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then
816 :
817 else
818 make arch/powerpc/lib/crtsavres.o "${make_args[@]}"
819 fi
820 fi
821
822 # On arm64 between 4.13 and 4.15 this object is required to build with ftrace support
823 if [ "${karch}" = "arm64" ]; then
824 if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
825 make arch/arm64/kernel/ftrace-mod.o "${make_args[@]}"
826 fi
827 fi
828
829 # Version specific tasks
830 case "$ktag" in
831 Ubuntu*)
832 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
833 ABINUM="$(echo "$ktag" | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')"
834 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> include/generated/utsrelease.h
835 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h"
836 ;;
837 esac
838 }
839
840
841 build_modules() {
842
843 local kdir="$1"
844 local outdir="$2"
845 local kversion
846
847 kversion=$(make -C "$LINUX_HDROBJ_DIR" -s kernelversion)
848
849 # Try to catch some compatibility problems by turning some
850 # warnings into errors.
851 #export KCFLAGS="$KCFLAGS -Wall -Werror"
852
853 # Enter lttng-modules source dir
854 cd "${MODULES_GIT_DIR}"
855
856 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
857 # timekeeping subsystem. We want those build to fail.
858 if { vergte "$kversion" "3.10" && verlte "$kversion" "3.10.13"; } || \
859 { vergte "$kversion" "3.11" && verlte "$kversion" "3.11.2"; }; then
860
861 set +e
862
863 # Build modules
864 KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
865 ret=$?
866
867 set -e
868
869 # We expect this build to fail, if it doesn't, fail the job.
870 if [ "$ret" -eq 0 ]; then
871 echo "This build should have failed."
872 exit 1
873 fi
874
875 # We have to publish at least one file or the build will fail
876 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${outdir}/BROKEN.txt.ko"
877
878 KERNELDIR="${kdir}" make clean
879
880 else # Regular build
881
882 # Build modules against full kernel sources
883 KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
884
885 # Install modules to build dir
886 KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${outdir}" modules_install
887
888 # Clean build dir
889 KERNELDIR="${kdir}" make clean
890 fi
891 }
892
893
894 ## MAIN ##
895
896 # Use all CPU cores
897 NPROC=$(nproc)
898
899 MODULES_GIT_DIR="${WORKSPACE}/src/lttng-modules"
900 LINUX_GIT_DIR="${WORKSPACE}/src/linux"
901
902 LINUX_OBJ_DIR="${WORKSPACE}/linux"
903 LINUX_SRCOBJ_DIR="${LINUX_OBJ_DIR}/sources"
904 LINUX_HDROBJ_DIR="${LINUX_OBJ_DIR}/headers"
905 LINUX_INSTOBJ_DIR="${LINUX_OBJ_DIR}/install"
906
907 MODULES_OUTPUT_KSRC_DIR="${WORKSPACE}/build/lttng-modules-ksrc"
908 MODULES_OUTPUT_KHDR_DIR="${WORKSPACE}/build/lttng-modules-khdr"
909
910 LINUX_GIT_REF_REPO_DIR="$HOME/gitcache/linux-stable.git/"
911
912 OBJ_STORE_URL="s3://jenkins"
913
914 cd "$WORKSPACE"
915
916 # Create build directories
917 mkdir -p "${LINUX_SRCOBJ_DIR}" "${LINUX_HDROBJ_DIR}" "${LINUX_INSTOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
918
919 git_clone_modules_sources
920
921 # Setup cross compile env if available
922 if [ "x${cross_arch}" != "x" ]; then
923
924 case "$cross_arch" in
925 "armhf")
926 karch="arm"
927 cross_compile="arm-linux-gnueabihf-"
928 vanilla_config="imx_v6_v7_defconfig"
929 ubuntu_config="armhf-config.flavour.generic"
930 ;;
931
932 "arm64")
933 karch="arm64"
934 cross_compile="aarch64-linux-gnu-"
935 vanilla_config="defconfig"
936 ubuntu_config="arm64-config.flavour.generic"
937 ;;
938
939 "powerpc")
940 karch="powerpc"
941 cross_compile="powerpc-linux-gnu-"
942 vanilla_config="ppc44x_defconfig"
943 ubuntu_config="powerpc-config.flavour.powerpc-smp"
944 ;;
945
946 "ppc64el")
947 karch="powerpc"
948 cross_compile="powerpc64le-linux-gnu-"
949 vanilla_config="pseries_le_defconfig"
950 ubuntu_config="ppc64el-config.flavour.generic"
951 ;;
952
953 *)
954 echo "Unsupported cross arch $cross_arch"
955 exit 1
956 ;;
957 esac
958
959 # Export variables used by Kbuild for cross compilation
960 export ARCH="${karch}"
961 export CROSS_COMPILE="${cross_compile}"
962
963 # Set arch specific values if we are not cross compiling
964 elif [ "x${arch}" != "x" ]; then
965
966 case "$arch" in
967 "i386")
968 karch="x86"
969 vanilla_config="allmodconfig"
970 ubuntu_config="i386-config.flavour.generic"
971 ;;
972
973 "amd64")
974 karch="x86"
975 vanilla_config="allmodconfig"
976 ubuntu_config="amd64-config.flavour.generic"
977 ;;
978
979 "armhf")
980 karch="arm"
981 vanilla_config="allmodconfig"
982 ubuntu_config="armhf-config.flavour.generic"
983 ;;
984
985 "arm64")
986 karch="arm64"
987 vanilla_config="allmodconfig"
988 ubuntu_config="arm64-config.flavour.generic"
989 ;;
990
991 "powerpc")
992 karch="powerpc"
993 vanilla_config="allmodconfig"
994 ubuntu_config="powerpc-config.flavour.powerpc-smp"
995 ;;
996
997 "ppc64el")
998 karch="powerpc"
999 vanilla_config="allmodconfig"
1000 ubuntu_config="ppc64el-config.flavour.generic"
1001 ;;
1002
1003 *)
1004 echo "Unsupported arch $arch"
1005 exit 1
1006 ;;
1007 esac
1008 else
1009 echo "No arch or cross_arch specified"
1010 exit 1
1011 fi
1012
1013
1014
1015 # First get the kernel build from the object store, or build it, if it's
1016 # not available.
1017
1018 echo "# Setup endpoint
1019 host_base = obj.internal.efficios.com
1020 host_bucket = obj.internal.efficios.com
1021 bucket_location = us-east-1
1022 use_https = True
1023
1024 # Setup access keys
1025 access_key = jenkins
1026 secret_key = echo123456
1027
1028 # Enable S3 v4 signature APIs
1029 signature_v2 = False" > "$WORKSPACE/.s3cfg"
1030
1031 url_hash="$(echo -n "$kgitrepo" | md5sum | awk '{ print $1 }')"
1032 obj_name="linux.tar.bz2"
1033
1034 if [ -z "${cross_arch}" ]; then
1035 obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platforms}/$arch/native"
1036 else
1037 obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platforms}/${cross_arch}"
1038 fi
1039
1040 obj_url="$obj_url_prefix/$obj_name"
1041
1042 set +e
1043 # In s3cmd 2.3, the return code of get when an object does not exist (64)
1044 # is different than in 2.2 (12). The return codes of 's3cmd info' are
1045 # consistent between 2.2 and 2.3.
1046 s3cmd -c "$WORKSPACE/.s3cfg" info "$obj_url"
1047 ret=$?
1048 set -e
1049
1050 case "$ret" in
1051 "0")
1052 s3cmd -c "$WORKSPACE/.s3cfg" get "$obj_url"
1053 extract_archive_obj
1054 ;;
1055
1056 "12")
1057 echo "File not found"
1058
1059 # Build all the things and upload
1060 # then finish the module build...
1061
1062 git_clone_linux_sources
1063 git_export_linux_sources
1064
1065 select_compiler
1066
1067 ## PREPARE FULL LINUX SOURCE TREE
1068 build_linux_kernel
1069
1070 ## EXTRACT DISTRO STYLE KERNEL HEADERS / DEVEL
1071 extract_distro_headers
1072
1073 tar_archive_obj
1074
1075 upload_archive_obj
1076
1077 ;;
1078
1079 *)
1080 echo "Unknown error? Abort"
1081 exit 1
1082 ;;
1083 esac
1084
1085 select_compiler
1086
1087 selected_cc_version="$(echo "${selected_cc}" | cut -d'-' -f2)"
1088 # lttng-modules requires gcc >= 5.1 for aarch64
1089 # @see https://github.com/lttng/lttng-modules/commit/be06402dbdbea2f3394e60ec15c5d3356e2be416
1090 if { verlt "${selected_cc_version}" "5.1"; } && [ "${cross_arch}" = "arm64" ] ; then
1091 echo "Building lltng-modules on aarch64 requires gcc >= 5.1"
1092 exit 0
1093 fi
1094
1095 ## BUILD modules
1096 # Either we downloaded a pre-build kernel or we built it and uploaded
1097 # the archive for future builds.
1098
1099 cd "$WORKSPACE"
1100
1101 # Build modules against full kernel sources
1102 build_modules "${LINUX_SRCOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}"
1103
1104 # Build modules against kernel headers
1105 build_modules "${LINUX_HDROBJ_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
1106
1107 # Make sure some modules were actually built
1108 tree "${MODULES_OUTPUT_KSRC_DIR}"
1109 if [ "x$(find "${MODULES_OUTPUT_KSRC_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
1110 echo "No modules built!"
1111 exit 1
1112 fi
1113
1114 tree "${MODULES_OUTPUT_KHDR_DIR}"
1115 if [ "x$(find "${MODULES_OUTPUT_KHDR_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
1116 echo "No modules built!"
1117 exit 1
1118 fi
1119
1120 # EOF
This page took 0.053637 seconds and 5 git commands to generate.