3 # Copyright (C) 2016-2023 Michael Jeanson <mjeanson@efficios.com>
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.
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.
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/>.
21 platform
=${platforms:-}
22 cross_arch
=${cross_arch:-}
24 kgitrepo
=${kgitrepo:-}
25 mversion
=${mversion:-}
26 mgitrepo
=${mgitrepo:-}
30 FAIL_ON_WARNINGS
="${FAIL_ON_WARNINGS:-}"
31 if [[ "${FAIL_ON_WARNINGS}" == "false" ]] ; then
35 # Derive arch from label if it isn't set
36 if [ -z "${arch:-}" ] ; then
37 # Labels may be platform specific, eg. jammy-amd64, deb12-armhf
38 regex
='[[:alnum:]]+-([[:alnum:]]+)'
39 if [[ "${platform}" =~
${regex} ]] ; then
40 arch
="${BASH_REMATCH[1]}"
49 # Kernel version compare functions
51 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ]
55 # shellcheck disable=SC2015
56 [ "$1" = "$2" ] && return 1 || verlte
"$1" "$2"
60 [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -n1)" ]
64 # shellcheck disable=SC2015
65 [ "$1" = "$2" ] && return 1 || vergte
"$1" "$2"
75 message_len
="${#message}"
76 padding_len
=$
(( (80 - (message_len
)) / 2 ))
78 printf '\n'; printf -- '#%.0s' {1.
.80}; printf '\n'
79 printf -- '-%.0s' {1.
.80}; printf '\n'
80 printf -- '#%.0s' $
(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $
(seq 1 $padding_len); printf '\n'
81 printf -- '-%.0s' {1.
.80}; printf '\n'
82 printf -- '#%.0s' {1.
.80}; printf '\n\n'
87 git_clone_modules_sources
() {
88 mkdir
-p "$MODULES_GIT_DIR"
90 # If the version starts with "refs/" or looks like a commit hash,
91 # checkout the specific git ref, otherwise treat it as a branch name.
92 pattern
="^[0-9a-f]{40}$"
93 if [ "${mversion:0:5}" = "refs/" ] ||
[[ "${mversion}" =~
$pattern ]]; then
94 git clone
--no-tags --depth=1 "${mgitrepo}" "$MODULES_GIT_DIR"
95 (cd "$MODULES_GIT_DIR" && git fetch origin
"${mversion}" && git checkout FETCH_HEAD
)
97 git clone
--no-tags --depth=1 -b "${mversion}" "${mgitrepo}" "$MODULES_GIT_DIR"
101 # Checkout a shallow kernel tree of the specified tag
102 git_clone_linux_sources
() {
103 mkdir
-p "$LINUX_GIT_DIR"
104 case "${distroversion:-}" in
106 git clone
-b "${ktag}" "${kgitrepo}" src
/linux-rpm
108 # Get the source files
110 "${WORKSPACE}/src/getsrc/getsrc/getsrc.sh"
111 tar -x -C "${LINUX_GIT_DIR}" --strip-components=1 -f SOURCES
/linux-
*.
tar.xz
114 # Pretend we're a repo like the default expects
115 pushd "${LINUX_GIT_DIR}"
117 git config user.name
'Jenkins'
118 git config user.email
'jenkins@efficios.com'
120 git commit
-a -m 'Initial commit'
122 echo "${LINUX_GIT_REF_REPO_DIR}" > .git
/objects
/info
/alternates
127 git clone
--depth=1 -b "${ktag}" --reference-if-able "$LINUX_GIT_REF_REPO_DIR" "${kgitrepo}" "$LINUX_GIT_DIR"
133 # Export the kernel sources from the git repo
134 git_export_linux_sources
() {
136 git archive
"${ktag}" |
tar -x -C "$LINUX_SRCOBJ_DIR"
140 # Upload the tar archive to the object store
141 upload_archive_obj
() {
142 s3cmd
-c "$WORKSPACE/.s3cfg" put
"$WORKSPACE/$obj_name" "$obj_url_prefix/"
143 rm -f "$WORKSPACE/$obj_name"
147 extract_archive_obj
() {
148 tar -xf "$WORKSPACE/$obj_name" -C "$LINUX_OBJ_DIR" -I pbzip2
149 rm -f "$WORKSPACE/$obj_name"
155 tar -cf "$WORKSPACE/$obj_name" -I pbzip2 .
159 # List all GCC versions present in the PATH
163 IFS
=: read -r -a path_array
<<< "$PATH"
164 while read -r gcc
; do
166 done < <(find "${path_array[@]}" -maxdepth 1 -regex '.*/gcc-[0-9\.]+$' -printf '%f\n' |
sort -t- -k2 -V -r)
170 # Find the most recent GCC version supported by the kernel sources
173 # Enter linux source dir
174 cd "$LINUX_SRCOBJ_DIR"
176 # Get the kernel version using the host toolchain, some cross-compiled arch may be broken
177 kversion
=$
(unset ARCH
; unset CROSS_COMPILE
; make -s kernelversion
)
179 if [ "${cross_arch}" = "riscv64" ] && verlt
"${kversion}" "5.12"; then
180 echo "RISC-V support was upstreamed in kernel v4.19 but kprobes support was only added in v5.12. Don't try to build it."
184 if [ "${cross_arch}" = "arm64" ] && verlt
"${kversion}" "3.7"; then
185 echo "ARM64 support was added as of v3.7. Don't try to build it."
189 if [ "${cross_arch}" = "arm64" ] && verlt
"${kversion}" "3.18"; then
190 echo "lttng-modules requires gcc >= 5.1 for ARM64 due to compiler bugs in gcc."
191 echo "gcc-5 support was added to the kernel as of v3.18. Don't this to build it."
195 if { verlt
"$kversion" "4.4"; }; then
196 # Force gcc-4.8 for kernels before 4.4
197 selected_cc
='gcc-4.8'
198 # Due to compiler bugs in gcc on arm64, lttng-modules disallows
199 # compilation with gcc < 5.1.
200 if [[ "${cross_arch}" == "arm64" ]] ; then
201 selected_cc
='gcc-5.5'
202 export PATH
="${PATH:-}:/usr/local/gcc5.5/bin"
203 export LD_LIBRARY_PATH
="${LD_LIBRARY_PATH:-}:/usr/local/gcc5.5/lib"
205 selected_cc_version
=$
(echo "${selected_cc}" | cut
-d'-' -f2)
207 for cc
in $
(list_gccs
) ; do
208 if "${CROSS_COMPILE:-}${cc}" -I include
/ -D__LINUX_COMPILER_H -D__LINUX_COMPILER_TYPES_H -E include
/linux
/compiler-gcc.h
; then
209 cc_version
=$
(echo "${cc}" | cut
-d'-' -f2)
210 if { verlt
"${kversion}" "5.17"; } && { vergt "${cc_version}" "11"; } ; then
211 # Using gcc-12+ with '-Wuse-after-free' breaks the build of older
212 # kernels (in particular, objtool). Some releases on LTS
213 # branches between 4.x and 5.15 can be built with gcc-12.
214 # @see https://lore.kernel.org/lkml/20494.1643237814@turing-police/
215 # @see https://gitlab.com/linux-kernel/stable/-/commit/52a9dab6d892763b2a8334a568bd4e2c1a6fde66
219 selected_cc_version="$cc_version"
225 if [ -z "$selected_cc" ]; then
226 echo "Found no suitable compiler.
"
230 # lttng-modules requires gcc >= 5.1 for aarch64
231 # @see https://github.com/lttng/lttng-modules/commit/be06402dbdbea2f3394e60ec15c5d3356e2be416
232 if { verlt "${selected_cc_version}" "5.1"; } && [ "${cross_arch}" = "arm64
" ] ; then
233 echo "Building lttng-modules on aarch64 requires gcc
>= 5.1"
240 export_kbuild_flags() {
251 if { vergte "$selected_cc_version" "6"; }; then
252 # Older kernel Makefiles do not expect the compiler to default to PIE
259 _KCPPFLAGS+=(-fno-pie)
262 if { vergte "${selected_cc_version}" "10"; } && { verlt "${kversion}" "5.10"; } ; then
263 # gcc-10 changed the default from '-fcommon' to '-fno-common', which
264 # causes a linker failure. '-fcommon' can be set on the HOSTCFLAGS
265 # to avoid the issue.
266 # @see https://gitlab.com/linux-kernel/stable/-/commit/e33a814e772cdc36436c8c188d8c42d019fda639
267 _HOSTCFLAGS
+=(-fcommon)
270 if { verlt
"${kversion}" "5.14"; } && [ "${cross_arch:-}" == "armhf" ] ; then
271 # Work-around for producing instructions that aren't valid for the
272 # default architectures.
273 # Eg. Error: selected processor does not support `cpsid i' in ARM mode
274 _KCFLAGS
+=(-march=armv7-a
-mfpu=vfpv3-d16
)
275 _KCPPFLAGS
+=(-march=armv7-a
-mfpu=vfpv3-d16
)
278 if { vergt
"${selected_cc_version}" "8"; } && { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.17"; } ; then
279 # This was added to -Wall in gcc 9 but some kernels do not include the fixes
280 # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88583
281 _KCFLAGS+=(-Wno-error=packed-not-aligned)
284 export KAFLAGS="${_KAFLAGS[*]}"
285 export KCFLAGS="${_KCFLAGS[*]}"
286 export KCPPFLAGS="${_KCPPFLAGS[*]}"
287 export HOSTCFLAGS="${_HOSTCFLAGS[*]}"
288 export CC="${CROSS_COMPILE:-}${selected_cc}"
289 export HOSTCC="${selected_cc}"
294 HOSTCFLAGS="${HOSTCFLAGS:-}"
297 if [ -n "${DEBUG}" ] ; then
304 patch_linux_kernel() {
308 # Show the title of the patch in the build log
309 git -C "${LINUX_GIT_REF_REPO_DIR}" show --oneline -s "${commit_hash}"
311 # Apply patch, don't fail if it doesn't apply cleanly
313 git -C "${LINUX_GIT_REF_REPO_DIR}" format-patch -n1 --stdout "${commit_hash}" | patch -p1
316 if [ "$?
" -gt 1 ] ; then
317 echo "Serious issue patching
"
322 build_linux_kernel() {
323 cd "$LINUX_SRCOBJ_DIR"
325 kversion=$(make -s kernelversion "${make_args[@]}")
326 pahole_version="$
(pahole
--version |
tr -d 'v')"
328 if { verlt "${kversion}" "3.3"; } && [ "${vanilla_config}" = "imx_v6_v7_defconfig
" ] ; then
329 # imx_v6_v7 didn't exist before 06965c39b4c63933fa0a1cde2237ef85477c5655
330 if { verlt "${kversion}" "3.2"; } ; then
331 vanilla_config='mx5_defconfig'
333 vanilla_config='mx51_defconfig'
337 if { verlt "${kversion}" "3.13"; } && [ "${vanilla_config}" = "pseries_le_defconfig
" ] ; then
338 # pseries_le_deconfig was introduced in f53e462e907cbaed29c49c0f10f5b8f614e1bf1d
339 vanilla_config='pseries_defconfig'
342 # Generate kernel configuration
345 # Copy the EL kernel configuration
346 el_arch="${cross_arch:-$arch}"
360 ls "${WORKSPACE}/src
/linux-rpm
/SOURCES
/"
361 if [ -f "${WORKSPACE}/src
/linux-rpm
/SOURCES
/kernel-
${el_arch}.config
" ] ; then
362 cp "${WORKSPACE}/src
/linux-rpm
/SOURCES
/kernel-
${el_arch}.config
" .config
363 elif [ -f "${WORKSPACE}/src
/linux-rpm
/SOURCES
/kernel-
${el_arch}-rhel.config
" ] ; then
364 cp "${WORKSPACE}/src
/linux-rpm
/SOURCES
/kernel-
${el_arch}-rhel.config
" .config
368 # mm/mempolicy.c: In function ‘mpol_parse_str’:
369 # mm/mempolicy.c:2980:26: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
370 export KCFLAGS="${KCFLAGS} -Wno-error -Wno-all -Wno-error=stringop-overflow
-Wno-error=address-of-packed-member
"
374 if [ "${cross_arch}" = "powerpc
" ] && vergte "${kversion}" "4.10"; then
375 echo "Ubuntu removed big endian powerpc configuration from kernel
>= 4.10. Don
't try to build it."
379 if [ "${cross_arch}" = "riscv64" ] && verlt "${kversion}" "6.2"; then
380 echo "Ubuntu added RISC-V config to their 'regular
' kernels in v6.2. Don't try to build it.
"
387 fakeroot debian/rules clean "${FAKEROOT_ARGS[@]}"
389 # Hack for kernel Ubuntu-hwe-5.8
390 # The debian/control file is produced by the clean target above, so this
391 # check needs to happen afterwards.
392 if [ ! -f "debian
/compat
" ] && ! grep -q debhelper-compat debian/control; then
393 echo "10" > "debian
/compat
"
396 # genconfigs check can fail in certain cases, eg. when a more recent
397 # compiler exposes kernel configuration flags which aren't set in the
398 # Ubuntu annotations.
399 # In any case, the configuration will be updated with any missing values
400 # later in our build script.
401 FAKEROOT_ARGS+=('do_skip_checks=true')
403 # Some Ubuntu tags default the toolchain using `gcc?=gcc-XX` in
404 # `debian/rules.d/0-common-vars.mk`. This may fail if the gcc version
405 # used as a default isn't available.
406 # For example, Ubuntu-6.8.0-7.7 sets `gcc?=gcc-13`, and that version
407 # of gcc isn't available on the deb12-amd64 ci-nodes.
408 # Work has also already been done in `select_compiler` to make our
409 # own decision of which compiler to use. As a result of both cases,
410 # our compiler choice should be passed into genconfigs.
411 FAKEROOT_ARGS+=("gcc
=${selected_cc}")
413 fakeroot debian/rules genconfigs "${FAKEROOT_ARGS[@]}"
414 cp CONFIGS/"${ubuntu_config}" .config
418 # Force 32bit build on i386, default is 64bit
419 if [ "$arch" = "i386
" ]; then
423 make "${vanilla_config}" "${make_args[@]}"
427 if [ "${vanilla_config}" = "pseries_defconfig
" ] && [ "${cross_arch}" = "ppc64el
" ] ; then
428 # @see diff <(git show v3.13:arch/powerpc/configs/pseries_defconfig) <(git show v3.13:arch/powerpc/configs/pseries_le_defconfig)
429 scripts/config --enable CONFIG_CPU_LITTLE_ENDIAN
430 scripts/config --enable CONFIG_CMA
431 scripts/config --disable CONFIG_XMON_DEFAULT
432 # scripts/config --disable CONFIG_VIRTUALIZATION
433 # scripts/config --disable CONFIG_KVM_BOOK3S_64
434 scripts/config --disable CONFIG_KVM_BOOK3S_64_HV
437 if [ -f "init
/Kconfig.suse
" ] ; then
438 # Get values from git tag, eg. 'rpm-5.14.21-150400.24.108'
439 # Note: the "150400" type of SUSE major version is only present on tags
440 # from 2022 and newer (about half-way through SLE15SP3).
441 # This will not work as expected on earlier tags.
442 SLES_RELEASE="$
(echo "${ktag}" | cut
-d '-' -f 3 | cut
-d'.' -f 1)"
443 scripts/config --set-val CONFIG_SUSE_VERSION $((10#"$
(echo "${SLES_RELEASE}" |
head -c 2)"))
444 scripts/config --set-val CONFIG_SUSE_PATCHLEVEL $((10#"$
(echo "${SLES_RELEASE}" |
head -c 4 |
tail -c 2)"))
446 # Disable the renesas clk driver that has build issues,
447 # eg. drivers/clk/renesas/renesas-rzg2l-cpg.c:185:17: error: ‘clk’ undeclared (first use in this function)
448 scripts/config --disable CONFIG_CLK_RENESAS
450 # From drives/spi/spi-atmel.c
451 # ./include/linux/gpio/consumer.h:141:49: note: expected ‘struct gpio_desc *’ but argument is of type 'int'
452 scripts/config --disable CONFIG_SPI_ATMEL
453 scripts/config --disable CONFIG_SPI_AT91_USART
454 scripts/config --disable CONFIG_SPI_ATMEL_QUADSPI
456 # drivers/net/wireless/mediatek/mt76/mt7915/testmode.c: In function ‘mt7915_tm_set_wmm_qid’:
457 # drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:176:30: error: ‘struct mt7915_vif’ has no member named ‘mt76’
458 scripts/config --disable CONFIG_WLAN_VENDOR_MEDIATEK
460 # drivers/net/wireless/microchip/wilc1000/cfg80211.c: In function ‘wilc_wfi_cfg_parse_ch_attr’:
461 # drivers/net/wireless/microchip/wilc1000/cfg80211.c:970:17: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
462 scripts/config --disable CONFIG_WLAN_VENDOR_MICROCHIP
464 # fs/f2fs/file.c: In function ‘punch_hole’:
465 # fs/f2fs/file.c:1093:49: error: ‘mapping’ undeclared (first use in this function)
466 scripts/config --disable CONFIG_F2FS_FS
469 # oldnoconfig was renamed in 4.19
470 if vergte "$kversion" "4.19"; then
471 update_conf_target="olddefconfig
"
473 update_conf_target="oldnoconfig
"
476 # Fix 'defined(@array)' was removed from recent perl
477 if [ -f "kernel
/timeconst.pl
" ]; then
478 sed -i 's/defined(\@\(.*\))/@\1/' kernel/timeconst.pl
481 # Fix syntax of inline assembly which is confused with C++11 raw strings on gcc >= 5
482 if [ "$HOSTCC" != "gcc-4.8
" ]; then
483 if [ -f "arch
/x86
/kvm
/svm.c
" ]; then
484 sed -i 's/ R"/ R
"/g; s/"R
"/" R
"/g' arch/x86/kvm/svm.c
487 if [ -f "arch
/x86
/kvm
/vmx.c
" ]; then
488 sed -i 's/ R"/ R
"/g; s/"R
"/" R
"/g' arch/x86/kvm/vmx.c
492 if { verlt "${kversion}" "5.11"; } && { vergte "${kversion}" "4.10"; } ; then
493 # Binutils > 2.35 strips empty symbol tables, causing obltool to fail
494 # in certain cases when files are empty.
495 # @see https://gitlab.com/linux-kernel/stable/-/commit/1d489151e9f9d1647110277ff77282fe4d96d09b
497 # There doesn't seem to be any LD/AS/AR flags to control this behaviour,
498 # therefore patching tools/objtool/elf.c is attempted.
499 patch_linux_kernel
1d489151e9f9d1647110277ff77282fe4d96d09b
500 if { verlt
"${kversion}" "4.18"; } ; then
501 patch_linux_kernel e81e0724432542af8d8c702c31e9d82f57b1ff31
505 if { vergt
"${selected_cc_version}" "7"; } && { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.17"; } ; then
506 # Builds fail due to -Werror=restrict in pager.o and str_error_r.o
507 if { verlt "${kversion}" "4.16"; } ; then
508 # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS
509 # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ad343a98e74e85aa91d844310e797f96fee6983b
510 patch_linux_kernel ad343a98e74e85aa91d844310e797f96fee6983b
512 if { verlt "${kversion}" "4.17"; } ; then
513 # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS
514 # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=854e55ad289ef8888e7991f0ada85d5846f5afb9
515 patch_linux_kernel 854e55ad289ef8888e7991f0ada85d5846f5afb9
520 if { vergt "${selected_cc_version}" "9"; } && { verlt "${kversion}" "5.6"; } ; then
521 # Duplicate decalarations of __force_order
522 # @see https://gitlab.com/linux-kernel/stable/-/commit/df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
523 # However, kaslr_64.c doesn't exit in 4.15, 4.16, it's named pagetable.c
524 if [ -f arch
/x86
/boot
/compressed
/pagetable.c
] ; then
525 sed -i '/^unsigned long __force_order;$/d' arch
/x86
/boot
/compressed
/pagetable.c
527 if [ -f arch
/x86
/boot
/compressed
/kaslr_64.c
] ; then
528 patch_linux_kernel df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc
532 if { vergte
"${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then
533 # In some cases, compiling net/bpfilter can fail with the following error:
534 # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory
535 # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1
537 # While the issue is potentially in a number of old versions, it has only
538 # been observed in v4.18-rt
540 patch_linux_kernel 303a339f30a9441c4695d3d2cc78f1b33cd959ff
543 if { vergte "${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then
544 # In some cases, compiling net/bpfilter can fail with the following error:
545 # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory
546 # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1
548 # While the issue is potentially in a number of old versions, it has only
549 # been observed in v4.18-rt
551 patch_linux_kernel
303a339f30a9441c4695d3d2cc78f1b33cd959ff
554 if { vergte
"${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ; then
555 # Some old kernels fail to build when make is too new
556 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
557 patch_linux_kernel 9564a8cf422d7b58f6e857e3546d346fa970191e
560 if { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.55"; } ; then
561 # Some old kernels fail to build when make is too new
562 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
563 patch_linux_kernel e82885490a611f2b75a6c27cd7bb09665c1740be
566 if ( { vergte
"${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ) || \
567 ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.56"; } ) ; then
568 # Some old kernels fail to build when make is too new
569 # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583
570 patch_linux_kernel
9feeb638cde083c737e295c0547f1b4f28e99583
573 if ( { vergte
"${kversion}" "4.12"; } && { verlt "${kversion}" "4.20.17"; } ) || \
574 ( { vergte "${kversion}" "5.0"; } && { verlt "${kversion}" "5.0.12"; } ) ; then
575 # Old kernels can fail to build while on newer host kernels with errors
577 # In file included from scripts/selinux/genheaders/genheaders.c:19:
578 # ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map.
579 # @see https://gitlab.com/linux-kernel/stable/-/commit/dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
581 patch_linux_kernel dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e
584 # Compatibility with binutils >= ~ 2.31
585 if { vergte
"${kversion}" "3.19"; } && { verlt "${kversion}" "4.16"; } ; then
586 patch_linux_kernel b21ebf2fb4cde1618915a97cc773e287ff49173e
588 if { vergte "${kversion}" "3.17"; } && { verlt "${kversion}" "3.18.69"; } ; then
589 patch_linux_kernel edb9d2d5e647e7a8521b0d35f8452deb02dfd138
591 if { vergte
"${kversion}" "3.17"; } && { verlt "${kversion}" "3.18.100"; } ; then
592 patch_linux_kernel 3be6583f0b6f1bf1ee650ebf473d9dee36836527
593 patch_linux_kernel 12d839211d080f6a9c370398c41a260365d34c62
595 if { vergte "${kversion}" "3.16"; } && { verlt "${kversion}" "3.16.82"; } ; then
596 patch_linux_kernel ad10e6d464796f2a481de4039a43b9cfca034e1c
599 if ( { vergte
"${kversion}" "3.14"; } && { verlt "${kversion}" "4.4"; } ) ||
600 ( { vergte "${kversion}" "4.8"; } && { verlt "${kversion}" "4.18"; } ); then
601 # While the original motivation of this patch is for fixing builds using
602 # clang, the same error occurs between linux >= 3.14 and < 4.4, and in
604 # For rt-linux, the error has been observed in 4.8, 4.11, and 4.13.
606 # This patch only partially applies due to changes in kernel/Makefile,
607 # so a supplementary patch is needed
609 # Without this patch, builds fail with
610 # Cannot find symbol for section 2: .text.
611 # kernel/elfcore.o: failed
613 # @see https://github.com/linuxppc/issues/issues/388
614 # @see https://lore.kernel.org/lkml/20201204165742.3815221-2-arnd@kernel.org/
616 patch_linux_kernel
6e7b64b9dd6d96537d816ea07ec26b7dedd397b9
617 if grep -q elfcore.o kernel
/Makefile
; then
618 sed -i '/^.* += elfcore.o$/d' kernel
/Makefile
621 # Same as above for the v4.4 branch
622 if ( { vergte
"${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.257"; } ); then
623 patch_linux_kernel 3140b0740b31cc63cf2ee08bc3f746b423eb068d
624 if grep -q elfcore.o kernel/Makefile ; then
625 sed -i '/^.* += elfcore.o$/d' kernel/Makefile
629 if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ; then
630 # Kernels between v4.5 and v4.8 built with gcc >= 8 on arm will hit an
633 # kernel/.tmp_fork.s: Assembler messages:
634 # kernel/.tmp_fork.s:1790: Error: .err encountered
636 # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85745
638 patch_linux_kernel
9f73bd8bb445e0cbe4bcef6d4cfc788f1e184007
641 if ( { vergte
"${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.136"; } ) ||
642 ( { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ); then
643 # Hacky patch to deal with the following build error:
644 # Cannot find symbol for section 7: .text.unlikely.
645 # kernel/kexec_file.o: failed
646 # make[1]: *** [scripts/Makefile.build:291: kernel/kexec_file.o] Error 1
648 # This error happens with binutils 2.36 and 2.37, but should probably not
649 # be an issue with binutils 2.38.
650 # @see https://github.com/linuxppc/issues/issues/388
651 # @see https://github.com/bminor/binutils-gdb/commit/c09c8b42021180eee9495bd50d8b35e683d3901b
653 # There is some sort of config (unspecified in past discussions) which
654 # provokes the error, and there was never a potential fix merged in
655 # this discussion, in part because the build systems of the kernel
656 # switched to objtool instead.
658 # @see https://lore.kernel.org/all/20210215162209.5e2a475b@gandalf.local.home/
660 sed -i 's/return txtname;/return shdr0->sh_size ? txtname : NULL;/' scripts
/recordmcount.h
662 # After applying the above patch, the build continues but fails with
663 # head64.c:(.text.exit+0x5): undefined reference to `__gcov_exit'
665 scripts
/config
--disable CONFIG_GCOV_KERNEL
668 if { vergte
"${kversion}" "4.5"; } && { verlt "${kversion}" "4.5.5"; } ; then
669 # drivers/staging/wilc1000/wilc_spi.c:123:34: error: storage size of ‘wilc1000_spi_ops’ isn’t known
670 patch_linux_kernel ce7b516f3f9e11fe4ee06fad0d7e853bb6e8f160
673 # Newer binutils don't accept 3 operand 'cmp' instructions on ppc64
674 # Convert them to 'cmpw' which was previously done silently
675 if verlt "$kversion" "4.9"; then
676 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/"
677 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/"
678 sed -i "s
/\
$pie \
-o \"\
$ofile\"/\
$pie --no-dynamic-linker -o \"\
$ofile\"/" arch/powerpc/boot/wrapper
681 if [ "$
(scripts
/config
--state CONFIG_EXTCON_ADC_JACK
)" != "n
" ] &&
682 ( { vergte "${kversion}" "4.2"; } && { verlt "${kversion}" "4.12"; } ); then
683 # 73b6ecdb93e8e77752cae9077c424fcdc6f23c39 introduced a change where
684 # extcon-adc-jack.h has an incompatible pointer type.
685 # In GCC >= 5 this will provoke a warning and build failure.
687 # drivers/extcon/extcon-adc-jack.c: In function ‘adc_jack_probe’:
688 # 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]
689 # make[2]: *** [scripts/Makefile.build:295: drivers/extcon/extcon-adc-jack.o] Error 1
691 # 8a522bf2d4f788306443d36b26b54f0aedcdfdbe (in 4.11) has a fix for this warning
693 patch_linux_kernel
8a522bf2d4f788306443d36b26b54f0aedcdfdbe
696 if ( { vergte
"${kversion}" "4.15"; } && { verlt "${kversion}" "4.15.2"; } ) || \
697 ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.18"; } ) ; then
698 # Fix an objtool Segmentation fault
699 patch_linux_kernel dd12561854824fd1f05baf2a1b794faa046e2425
702 if { vergte
"${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.268"; } ; then
703 # Builds fail due to -Werror=use-after-free in sigchain.o and help.o
704 patch_linux_kernel e89bb266b710ce056f141f29f091fd468a4a8185
707 # Fix a typo in v2.6.36.x
708 if [ -f "arch
/x86
/kernel
/entry_64.S
" ]; then
709 sed -i 's/END(do_hypervisor_callback)/END(xen_do_hypervisor_callback)/' arch/x86/kernel/entry_64.S
712 # Fix compiler switch in vdso Makefile for 2.6.36 to 2.6.36.2
713 if { vergte "$kversion" "2.6.36" && verlte "$kversion" "2.6.36.3"; }; then
714 sed -i 's/-m elf_x86_64/-m64/' arch/x86/vdso/Makefile
715 sed -i 's/-m elf_i386/-m32/' arch/x86/vdso/Makefile
718 # Fix kernel < 3.0 with gcc >= 4.7
719 if verlt "$kversion" "3.0"; then
720 sed -i '/linux\/compiler.h/a #include <linux\/linkage.h> \/* For asmregparm *\/' arch/x86/include/asm/ptrace.h
721 sed -i 's/extern long syscall_trace_enter/extern asmregparm long syscall_trace_enter/' arch/x86/include/asm/ptrace.h
722 sed -i 's/extern void syscall_trace_leave/extern asmregparm void syscall_trace_leave/' arch/x86/include/asm/ptrace.h
723 echo "header-y
+= linkage.h
" >> include/linux/Kbuild
726 if [ "${cross_arch}" = "powerpc
" ] ; then
727 if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.16"; } ; then
728 # Avoid register errors such as
729 # aes_generic.c:(.text+0x4e0): undefined reference to `_restgpr_31_x'
730 # @see https://gitlab.com/linux-kernel/stable/-/commit/148b974deea927f5dbb6c468af2707b488bfa2de
732 CFLAGS_aes_generic.o
=''
737 if [ "$(scripts/config --state CONFIG_DEBUG_INFO_BTF)" == "y" ] &&
738 { vergte
"${pahole_version}" "1.24"; } &&
740 ( { vergte
"${kversion}" "5.10"; } && { verlt "${kversion}" "6.0"; } ) || [[ "${ktag}" =~ .el8 ]]
742 # Some kernels Eg. Ubuntu-hwe-5.13-5.13.0-52.59_20.04.1
743 # fail with the following error:
745 # FAILED: load BTF from vmlinux: Invalid argument
747 # When CONFIG_DEBUG_INFO_BTF is set, certain versions of pahole require
748 # `--skip_encoding_btf_enum64` to be passed as the kernel doesn't define
751 # Introduced in 341dfcf8d78eaa3a2dc96dea06f0392eb2978364 (~v5.10)
752 # @see https://lore.kernel.org/bpf/20220825171620.cioobudss6ovyrkc@altlinux.org/t/
754 if [ -f "scripts
/pahole-flags.sh
" ] ; then
755 # shellcheck disable=SC2016
756 sed -i 's/ -J ${PAHOLE_FLAGS} / -J ${PAHOLE_FLAGS} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
758 # shellcheck disable=SC2016
759 sed -i 's/ -J ${extra_paholeopt} / -J ${extra_paholeopt} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh
760 # Some older versions of RHEL don't have '${extra_paholeopt}'
761 sed -i 's/${PAHOLE} -J ${1}/${PAHOLE} -J --skip_encoding_btf_enum64 ${1}/' scripts/link-vmlinux.sh
766 if [ "$HOSTCC" == "gcc-4.8
" ]; then
767 scripts/config --disable CONFIG_CC_STACKPROTECTOR_STRONG
768 scripts/config --disable CONFIG_PPC_OF_BOOT_TRAMPOLINE
771 # Don't try to sign modules
772 scripts/config --disable CONFIG_MODULE_SIG
774 # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails
775 scripts/config --disable CONFIG_STACK_VALIDATION
777 # Cause problems with inline assembly on i386
778 scripts/config --disable CONFIG_DEBUG_SECTION_MISMATCH
780 # Don't build samples, they are broken on some kernel releases
781 scripts/config --disable CONFIG_SAMPLES
782 scripts/config --disable CONFIG_BUILD_DOCSRC
785 scripts/config --disable CONFIG_KCOV
787 # Broken on some RT kernels
788 scripts/config --disable CONFIG_HYPERV
791 scripts/config --disable CONFIG_RAPIDIO_TSI721
792 scripts/config --disable CONFIG_SGI_XP
793 scripts/config --disable CONFIG_MFD_WM8994
794 scripts/config --disable CONFIG_DRM_RADEON
795 scripts/config --disable CONFIG_SND_SOC_WM5100
796 # More recent compiler optimizations (from gcc 8 onwards )expose build errors
797 # with netronome on older kernels.
798 # Observed in 4.11-rt, 4.15-4.17, 5.0-rt - 5.16-rt
799 # It seems easier to disable the driver than to attempt patching.
801 # In function ‘ur_load_imm_any’,
802 # inlined from ‘jeq_imm’ at drivers/net/ethernet/netronome/nfp/bpf/jit.c:3146:13:
803 # ./include/linux/compiler.h:350:45: error: call to ‘__compiletime_assert_1062’ declared with attribute error: FIELD_FIT: value too large for the field
804 # 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
806 scripts/config --disable CONFIG_NET_VENDOR_NETRONOME
808 # In function ‘memcpy’,
809 # inlined from ‘kszphy_get_strings’ at drivers/net/phy/micrel.c:664:3:
810 # ./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
811 # 305 | __read_overflow2();
812 # | ^~~~~~~~~~~~~~~~~~
813 # make[3]: *** [scripts/Makefile.build:308: drivers/net/phy/micrel.o] Error 1
815 scripts/config --disable CONFIG_MICREL_PHY
818 # IGBVF won't build with recent gcc on 2.6.38.2
819 if { vergte "$kversion" "2.6.37" && verlt "$kversion" "2.6.38"; }; then
820 scripts/config --disable CONFIG_IGBVF
823 # Don't fail the build on warnings
824 scripts/config --disable CONFIG_WERROR
825 scripts/config --enable CONFIG_PPC_DISABLE_WERROR
827 # Set required options
828 scripts/config --enable CONFIG_TRACEPOINTS
829 scripts/config --enable CONFIG_KALLSYMS
830 scripts/config --enable CONFIG_HIGH_RES_TIMERS
831 scripts/config --enable CONFIG_KPROBES
832 scripts/config --enable CONFIG_FTRACE
833 scripts/config --enable CONFIG_BLK_DEV_IO_TRACE
834 scripts/config --enable CONFIG_KALLSYMS_ALL
835 scripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTS
836 scripts/config --enable CONFIG_PERF_EVENTS
837 scripts/config --enable CONFIG_EVENT_TRACING
838 scripts/config --enable CONFIG_KRETPROBES
840 # Starting in linux 6.9-rc1, TRIM_UNUSED_SYMS seems to be true
841 # for out build configurations. In earlier versions the default
842 # was set depending on the value of `COMPILE_TEST`.
843 # See upstream commit d2d5cba5d92c4ed23caa86228a1bc31b07e90fe9.
844 scripts/config --disable CONFIG_TRIM_UNUSED_KSYMS
846 if [ -n "${DEBUG}" ] ; then
850 make "$update_conf_target" "${make_args[@]}"
851 make -j"$NPROC" "${make_args[@]}"
853 krelease=$(make -s kernelrelease "${make_args[@]}")
855 # Save the kernel and modules
856 mkdir -p "$LINUX_INSTOBJ_DIR/boot
"
857 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install "${make_args[@]}"
858 make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot
" install "${make_args[@]}"
859 rm -f "$LINUX_INSTOBJ_DIR/lib
/modules
/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib
/modules
/${krelease}/build
"
860 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib
/modules
/${krelease}/source"
861 ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib
/modules
/${krelease}/source"
865 extract_distro_headers() {
867 # Enter linux source dir
868 cd "${LINUX_SRCOBJ_DIR}"
871 # For RT kernels, copy version file
872 if [ -s localversion-rt ]; then
873 cp -a localversion-rt "${LINUX_HDROBJ_DIR}"
876 # Copy all Makefile related stuff
877 find . -path './include/*' -prune \
878 -o -path './scripts/*' -prune -o -type f \
879 \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
880 -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
881 -print | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
883 # Copy base scripts and include dirs
884 cp -a scripts include "${LINUX_HDROBJ_DIR}"
887 (find arch -name include -type d -print0 | \
888 xargs -0 -n1 -I '{}' find '{}' -type f) | \
889 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
892 (find arch -name scripts -type d -print0 | \
893 xargs -0 -n1 -I '{}' find '{}' -type f) | \
894 cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}"
897 rm -f "${LINUX_HDROBJ_DIR}/scripts
/*.o
"
898 rm -f "${LINUX_HDROBJ_DIR}/scripts
/*/*.o
"
900 # On powerpc 32bits this object is required to link modules
901 if [ "${karch}" = "powerpc
" ]; then
902 if [ "$
(scripts
/config
-s CONFIG_PPC64
)" = "y
" ] && vergte "${kversion}" "5.4"; then
905 cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LINUX_HDROBJ_DIR}/"
909 # On arm64 between 4.13 and 1.15 this object is required to build with ftrace support
910 if [ "${karch}" = "arm64
" ]; then
911 if [ -f "arch
/arm64
/kernel
/ftrace-mod.S
" ]; then
912 cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LINUX_HDROBJ_DIR}/"
916 # On riscv with 5.14 the vsdo objects are required
917 if [ "${karch}" = "riscv
" ] && \
918 ( { vergte "${kversion}" "5.14"; } && { verlt "${kversion}" "5.15"; } ); then
919 cp -a --parents arch
/riscv
/kernel
/vdso
/*.o
"${LINUX_HDROBJ_DIR}/"
922 # Newer kernels need objtool to build modules when CONFIG_STACK_VALIDATION=y
923 if [ -f tools
/objtool
/objtool
]; then
924 cp -a --parents tools
/objtool
/objtool
"${LINUX_HDROBJ_DIR}/"
927 if [ -f "arch/x86/kernel/macros.s" ]; then
928 cp -a --parents arch
/x86
/kernel
/macros.s
"${LINUX_HDROBJ_DIR}/"
931 # Copy modules related stuff, if available
932 if [ -s Module.symvers
]; then
933 cp Module.symvers
"${LINUX_HDROBJ_DIR}"
936 if [ -s System.map
]; then
937 cp System.map
"${LINUX_HDROBJ_DIR}"
940 if [ -s Module.markers
]; then
941 cp Module.markers
"${LINUX_HDROBJ_DIR}"
945 cp .config
"${LINUX_HDROBJ_DIR}"
947 # Make sure the Makefile and version.h have a matching timestamp so that
948 # external modules can be built
949 if [ -s "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" ]; then
950 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h"
951 elif [ -s "${LINUX_HDROBJ_DIR}/include/linux/version.h" ]; then
952 touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/linux/version.h"
954 echo "Missing version.h"
957 touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h"
959 # Copy .config to include/config/auto.conf so "make prepare" is unnecessary.
960 if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then
961 cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf"
964 # Finally clean the object files from the full source tree
967 # And regen the modules support files
968 make modules_prepare
"${make_args[@]}"
970 # On powerpc 32bits this object is required to link modules
971 if [ "${karch}" = "powerpc" ]; then
972 if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte
"${kversion}" "5.4"; then
975 make arch
/powerpc
/lib
/crtsavres.o
"${make_args[@]}"
979 # On arm64 between 4.13 and 4.15 this object is required to build with ftrace support
980 if [ "${karch}" = "arm64" ]; then
981 if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then
982 make arch
/arm64
/kernel
/ftrace-mod.o
"${make_args[@]}"
986 # Version specific tasks
989 # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code
990 ABINUM
="$(echo "$ktag" | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')"
991 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> include
/generated
/utsrelease.h
992 echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h"
995 # Update the definition of UTS_RELEASE to match something akin to '5.14.21-150400.24.108-default'
996 if [ -f "init/Kconfig.suse" ] ; then
997 SLESVERSION
="$(echo "${ktag}" | cut -d'-' -f 3)-default"
998 sed -E -i "s%^(#define UTS_RELEASE \"[\.a-z0-9]+)(\")%\1-${SLESVERSION}\2%g" include
/generated
/utsrelease.h
999 sed -E -i "s%^(#define UTS_RELEASE \"[\.a-z0-9]+)(\")%\1-${SLESVERSION}\2%g" "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h"
1012 kversion
=$
(make -C "$LINUX_HDROBJ_DIR" -s kernelversion
)
1014 # Enter lttng-modules source dir
1015 cd "${MODULES_GIT_DIR}"
1017 # Try to catch some compatibility problems by turning some
1018 # warnings into errors, but only on -rc kernels.
1020 if [[ "${kversion}" =~ ${pattern} ]] || [[ -n "${FAIL_ON_WARNINGS:-}" ]] ; then
1021 export KCFLAGS
="${KCFLAGS} -Wall -Werror"
1022 # Without the verbose build, the warnings aren't visible.
1026 # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the
1027 # timekeeping subsystem. We want those build to fail.
1028 if { vergte
"$kversion" "3.10" && verlte
"$kversion" "3.10.13"; } || \
1029 { vergte
"$kversion" "3.11" && verlte
"$kversion" "3.11.2"; }; then
1034 KERNELDIR
="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
1039 # We expect this build to fail, if it doesn't, fail the job.
1040 if [ "$ret" -eq 0 ]; then
1041 echo "This build should have failed."
1045 # We have to publish at least one file or the build will fail
1046 echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${outdir}/BROKEN.txt.ko"
1048 KERNELDIR
="${kdir}" make clean
1050 else # Regular build
1052 # Build modules against full kernel sources
1053 KERNELDIR
="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}"
1055 # Install modules to build dir
1056 KERNELDIR
="${kdir}" make INSTALL_MOD_PATH
="${outdir}" modules_install
1059 KERNELDIR
="${kdir}" make clean
1069 MODULES_GIT_DIR
="${WORKSPACE}/src/lttng-modules"
1070 LINUX_GIT_DIR
="${WORKSPACE}/src/linux"
1072 LINUX_OBJ_DIR
="${WORKSPACE}/linux"
1073 LINUX_SRCOBJ_DIR
="${LINUX_OBJ_DIR}/sources"
1074 LINUX_HDROBJ_DIR
="${LINUX_OBJ_DIR}/headers"
1075 LINUX_INSTOBJ_DIR
="${LINUX_OBJ_DIR}/install"
1077 MODULES_OUTPUT_KSRC_DIR
="${WORKSPACE}/build/lttng-modules-ksrc"
1078 MODULES_OUTPUT_KHDR_DIR
="${WORKSPACE}/build/lttng-modules-khdr"
1080 LINUX_GIT_REF_REPO_DIR
="$HOME/gitcache/linux-stable.git/"
1082 OBJ_STORE_URL
="s3://jenkins"
1086 # Create build directories
1087 mkdir
-p "${LINUX_SRCOBJ_DIR}" "${LINUX_HDROBJ_DIR}" "${LINUX_INSTOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
1089 print_header
"Clone LTTng-modules sources"
1090 git_clone_modules_sources
1092 # Setup cross compile env if available
1093 if [ "x${cross_arch}" != "x" ]; then
1095 case "$cross_arch" in
1098 cross_compile
="arm-linux-gnueabihf-"
1099 vanilla_config
="imx_v6_v7_defconfig"
1100 ubuntu_config
="armhf-config.flavour.generic"
1105 cross_compile
="aarch64-linux-gnu-"
1106 vanilla_config
="defconfig"
1107 ubuntu_config
="arm64-config.flavour.generic"
1112 cross_compile
="powerpc-linux-gnu-"
1113 vanilla_config
="ppc44x_defconfig"
1114 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
1119 cross_compile
="powerpc64le-linux-gnu-"
1120 vanilla_config
="pseries_le_defconfig"
1121 ubuntu_config
="ppc64el-config.flavour.generic"
1126 cross_compile
="riscv64-linux-gnu-"
1127 vanilla_config
="defconfig"
1128 ubuntu_config
="riscv64-config.flavour.generic"
1132 echo "Unsupported cross arch $cross_arch"
1137 # Export variables used by Kbuild for cross compilation
1138 export ARCH
="${karch}"
1139 export CROSS_COMPILE
="${cross_compile}"
1141 # Set arch specific values if we are not cross compiling
1142 elif [ "x${arch}" != "x" ]; then
1147 vanilla_config
="allmodconfig"
1148 ubuntu_config
="i386-config.flavour.generic"
1153 vanilla_config
="allmodconfig"
1154 ubuntu_config
="amd64-config.flavour.generic"
1159 vanilla_config
="allmodconfig"
1160 ubuntu_config
="armhf-config.flavour.generic"
1165 vanilla_config
="allmodconfig"
1166 ubuntu_config
="arm64-config.flavour.generic"
1171 vanilla_config
="allmodconfig"
1172 ubuntu_config
="powerpc-config.flavour.powerpc-smp"
1177 vanilla_config
="allmodconfig"
1178 ubuntu_config
="ppc64el-config.flavour.generic"
1183 vanilla_config
="allmodconfig"
1184 ubuntu_config
="riscv64-config.flavour.generic"
1188 echo "Unsupported arch $arch"
1193 echo "No arch or cross_arch specified"
1199 # First get the kernel build from the object store, or build it, if it's
1203 echo "# Setup endpoint
1204 host_base = obj.internal.efficios.com
1205 host_bucket = obj.internal.efficios.com
1206 bucket_location = us-east-1
1210 access_key = jenkins
1211 secret_key = echo123456
1213 # Enable S3 v4 signature APIs
1214 signature_v2 = False" > "$WORKSPACE/.s3cfg"
1217 url_hash
="$(echo -n "$kgitrepo" | md5sum | awk '{ print $1 }')"
1218 obj_name
="linux.tar.bz2"
1220 if [ -z "${cross_arch}" ]; then
1221 obj_url_prefix
="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platform}/$arch/native"
1223 obj_url_prefix
="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platform}/${cross_arch}"
1226 obj_url
="$obj_url_prefix/$obj_name"
1229 # In s3cmd 2.3, the return code of get when an object does not exist (64)
1230 # is different than in 2.2 (12). The return codes of 's3cmd info' are
1231 # consistent between 2.2 and 2.3.
1232 s3cmd
-c "$WORKSPACE/.s3cfg" info
"$obj_url"
1238 print_header
"Get sources and prebuilt kernel"
1239 s3cmd
-c "$WORKSPACE/.s3cfg" get
"$obj_url"
1242 print_header
"Select compiler and set build flags"
1248 print_header
"Clone kernel sources"
1250 # Build all the things and upload
1251 # then finish the module build...
1253 git_clone_linux_sources
1254 git_export_linux_sources
1256 print_header
"Select compiler and set build flags"
1260 ## PREPARE FULL LINUX SOURCE TREE
1261 print_header
"Build kernel from source"
1264 ## EXTRACT DISTRO STYLE KERNEL HEADERS / DEVEL
1265 extract_distro_headers
1267 print_header
"Upload kernel to object storage"
1274 echo "Unknown error? Abort"
1281 # Either we downloaded a pre-build kernel or we built it and uploaded
1282 # the archive for future builds.
1286 print_header
"Build modules against full kernel sources"
1287 build_modules
"${LINUX_SRCOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}"
1289 print_header
"Build modules against kernel headers"
1290 build_modules
"${LINUX_HDROBJ_DIR}" "${MODULES_OUTPUT_KHDR_DIR}"
1293 print_header
"Check for built modules in install directory"
1295 # Make sure some modules were actually built
1296 tree
"${MODULES_OUTPUT_KSRC_DIR}"
1297 if [ "x$(find "${MODULES_OUTPUT_KSRC_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
1298 echo "No modules built!"
1302 tree
"${MODULES_OUTPUT_KHDR_DIR}"
1303 if [ "x$(find "${MODULES_OUTPUT_KHDR_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then
1304 echo "No modules built!"