Commit | Line | Data |
---|---|---|
51c9c62d | 1 | #!/bin/bash |
f3d8604b | 2 | # |
53300bf0 | 3 | # Copyright (C) 2016-2023 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 |
18 | set -exu |
19 | ||
39961776 | 20 | # Parameters |
53300bf0 MJ |
21 | platform=${platforms:-} |
22 | cross_arch=${cross_arch:-} | |
23 | ktag=${ktag:-} | |
24 | kgitrepo=${kgitrepo:-} | |
25 | mversion=${mversion:-} | |
26 | mgitrepo=${mgitrepo:-} | |
27 | make_args=() | |
28 | ||
29 | DEBUG=${DEBUG:-} | |
30 | ||
447eaf93 KS |
31 | # Derive arch from label if it isn't set |
32 | if [ -z "${arch:-}" ] ; then | |
33 | # Labels may be platform specific, eg. jammy-amd64, deb12-armhf | |
34 | regex='[[:alnum:]]+-([[:alnum:]]+)' | |
53300bf0 | 35 | if [[ "${platform}" =~ ${regex} ]] ; then |
447eaf93 KS |
36 | arch="${BASH_REMATCH[1]}" |
37 | else | |
53300bf0 | 38 | arch="${platform:-}" |
447eaf93 KS |
39 | fi |
40 | fi | |
a86b55bc | 41 | |
39961776 | 42 | |
339db64d MJ |
43 | ## FUNCTIONS ## |
44 | ||
f3d8604b MJ |
45 | # Kernel version compare functions |
46 | verlte() { | |
51fa2ab3 | 47 | [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | head -n1)" ] |
f3d8604b MJ |
48 | } |
49 | ||
50 | verlt() { | |
28b10e79 | 51 | # shellcheck disable=SC2015 |
51fa2ab3 | 52 | [ "$1" = "$2" ] && return 1 || verlte "$1" "$2" |
f3d8604b MJ |
53 | } |
54 | ||
55 | vergte() { | |
51fa2ab3 | 56 | [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -V | tail -n1)" ] |
f3d8604b MJ |
57 | } |
58 | ||
59 | vergt() { | |
28b10e79 | 60 | # shellcheck disable=SC2015 |
51fa2ab3 | 61 | [ "$1" = "$2" ] && return 1 || vergte "$1" "$2" |
f3d8604b MJ |
62 | } |
63 | ||
53300bf0 MJ |
64 | print_header() { |
65 | set +x | |
66 | ||
67 | local message=" $1 " | |
68 | local message_len | |
69 | local padding_len | |
70 | ||
71 | message_len="${#message}" | |
72 | padding_len=$(( (80 - (message_len)) / 2 )) | |
73 | ||
74 | printf '\n'; printf -- '#%.0s' {1..80}; printf '\n' | |
75 | printf -- '-%.0s' {1..80}; printf '\n' | |
76 | printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n' | |
77 | printf -- '-%.0s' {1..80}; printf '\n' | |
78 | printf -- '#%.0s' {1..80}; printf '\n\n' | |
79 | ||
80 | set -x | |
81 | } | |
82 | ||
5a196804 MJ |
83 | git_clone_modules_sources() { |
84 | mkdir -p "$MODULES_GIT_DIR" | |
28b10e79 MJ |
85 | |
86 | # If the version starts with "refs/", checkout the specific git ref, otherwise treat it | |
87 | # as a branch name. | |
88 | if [ "${mversion:0:5}" = "refs/" ]; then | |
89 | git clone --no-tags --depth=1 "${mgitrepo}" "$MODULES_GIT_DIR" | |
90 | (cd "$MODULES_GIT_DIR" && git fetch origin "${mversion}" && git checkout FETCH_HEAD) | |
91 | else | |
92 | git clone --no-tags --depth=1 -b "${mversion}" "${mgitrepo}" "$MODULES_GIT_DIR" | |
93 | fi | |
5a196804 MJ |
94 | } |
95 | ||
96 | # Checkout a shallow kernel tree of the specified tag | |
97 | git_clone_linux_sources() { | |
98 | mkdir -p "$LINUX_GIT_DIR" | |
06e52597 | 99 | git clone --depth=1 -b "${ktag}" --reference-if-able "$LINUX_GIT_REF_REPO_DIR" "${kgitrepo}" "$LINUX_GIT_DIR" |
5a196804 | 100 | } |
7e02032c | 101 | |
7e02032c | 102 | |
5a196804 MJ |
103 | # Export the kernel sources from the git repo |
104 | git_export_linux_sources() { | |
105 | cd "$LINUX_GIT_DIR" | |
106 | git archive "${ktag}" | tar -x -C "$LINUX_SRCOBJ_DIR" | |
107 | } | |
108 | ||
109 | ||
110 | # Upload the tar archive to the object store | |
111 | upload_archive_obj() { | |
112 | s3cmd -c "$WORKSPACE/.s3cfg" put "$WORKSPACE/$obj_name" "$obj_url_prefix/" | |
113 | rm -f "$WORKSPACE/$obj_name" | |
114 | } | |
115 | ||
116 | ||
117 | extract_archive_obj() { | |
02c6a56a | 118 | tar -xf "$WORKSPACE/$obj_name" -C "$LINUX_OBJ_DIR" -I pbzip2 |
5a196804 MJ |
119 | rm -f "$WORKSPACE/$obj_name" |
120 | } | |
121 | ||
122 | ||
123 | tar_archive_obj() { | |
124 | cd "$LINUX_OBJ_DIR" | |
125 | tar -cf "$WORKSPACE/$obj_name" -I pbzip2 . | |
126 | cd - | |
127 | } | |
128 | ||
53300bf0 | 129 | # List all GCC versions present in the PATH |
6c0b2710 KS |
130 | list_gccs() { |
131 | local gccs | |
132 | gccs=() | |
133 | IFS=: read -r -a path_array <<< "$PATH" | |
134 | while read -r gcc ; do | |
135 | gccs+=("$gcc") | |
136 | done < <(find "${path_array[@]}" -maxdepth 1 -regex '.*/gcc-[0-9\.]+$' -printf '%f\n' | sort -t- -k2 -V -r) | |
137 | echo "${gccs[@]}" | |
138 | } | |
139 | ||
5a196804 MJ |
140 | # Find the most recent GCC version supported by the kernel sources |
141 | select_compiler() { | |
5a196804 | 142 | |
53300bf0 | 143 | # Enter linux source dir |
5a196804 MJ |
144 | cd "$LINUX_SRCOBJ_DIR" |
145 | ||
ae365617 MJ |
146 | # Get the kernel version using the host toolchain, some cross-compiled arch may be broken |
147 | kversion=$(unset ARCH; unset CROSS_COMPILE; make -s kernelversion) | |
148 | ||
149 | if [ "${cross_arch}" = "riscv64" ] && verlt "${kversion}" "5.12"; then | |
150 | 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." | |
151 | exit 0 | |
152 | fi | |
5a196804 | 153 | |
4f6c1ba9 KS |
154 | if [ "${cross_arch}" = "arm64" ] && verlt "${kversion}" "3.7"; then |
155 | echo "ARM64 support was added as of v3.7. Don't try to build it." | |
156 | exit 0 | |
157 | fi | |
158 | ||
159 | if [ "${cross_arch}" = "arm64" ] && verlt "${kversion}" "3.18"; then | |
160 | echo "lttng-modules requires gcc >= 5.1 for ARM64 due to compiler bugs in gcc." | |
161 | echo "gcc-5 support was added to the kernel as of v3.18. Don't this to build it." | |
162 | exit 0 | |
163 | fi | |
164 | ||
a86b55bc | 165 | if { verlt "$kversion" "4.4"; }; then |
53300bf0 | 166 | # Force gcc-4.8 for kernels before 4.4 |
a86b55bc | 167 | selected_cc='gcc-4.8' |
4f6c1ba9 KS |
168 | # Due to compiler bugs in gcc on arm64, lttng-modules disallows |
169 | # compilation with gcc < 5.1. | |
170 | if [[ "${cross_arch}" == "arm64" ]] ; then | |
171 | selected_cc='gcc-5.5' | |
172 | export PATH="${PATH:-}:/usr/local/gcc5.5/bin" | |
173 | export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:/usr/local/gcc5.5/lib" | |
174 | fi | |
53300bf0 MJ |
175 | selected_cc_version=$(echo "${selected_cc}" | cut -d'-' -f2) |
176 | else | |
177 | for cc in $(list_gccs) ; do | |
178 | if "${CROSS_COMPILE:-}${cc}" -I include/ -D__LINUX_COMPILER_H -D__LINUX_COMPILER_TYPES_H -E include/linux/compiler-gcc.h; then | |
179 | cc_version=$(echo "${cc}" | cut -d'-' -f2) | |
180 | if { verlt "${kversion}" "5.17"; } && { vergt "${cc_version}" "11"; } ; then | |
181 | # Using gcc-12+ with '-Wuse-after-free' breaks the build of older | |
182 | # kernels (in particular, objtool). Some releases on LTS | |
183 | # branches between 4.x and 5.15 can be built with gcc-12. | |
184 | # @see https://lore.kernel.org/lkml/20494.1643237814@turing-police/ | |
185 | # @see https://gitlab.com/linux-kernel/stable/-/commit/52a9dab6d892763b2a8334a568bd4e2c1a6fde66 | |
186 | continue | |
187 | fi | |
188 | selected_cc="$cc" | |
189 | selected_cc_version="$cc_version" | |
190 | break | |
191 | fi | |
192 | done | |
a86b55bc KS |
193 | fi |
194 | ||
efdab1b7 | 195 | if [ -z "$selected_cc" ]; then |
5a196804 MJ |
196 | echo "Found no suitable compiler." |
197 | exit 1 | |
198 | fi | |
199 | ||
53300bf0 MJ |
200 | # lttng-modules requires gcc >= 5.1 for aarch64 |
201 | # @see https://github.com/lttng/lttng-modules/commit/be06402dbdbea2f3394e60ec15c5d3356e2be416 | |
202 | if { verlt "${selected_cc_version}" "5.1"; } && [ "${cross_arch}" = "arm64" ] ; then | |
203 | echo "Building lttng-modules on aarch64 requires gcc >= 5.1" | |
204 | exit 1 | |
205 | fi | |
206 | ||
207 | cd - | |
208 | } | |
209 | ||
210 | export_kbuild_flags() { | |
211 | local _KAFLAGS | |
212 | local _KCFLAGS | |
213 | local _KCPPFLAGS | |
214 | local _HOSTCFLAGS | |
215 | ||
a86b55bc KS |
216 | _KAFLAGS=() |
217 | _KCFLAGS=() | |
218 | _KCPPFLAGS=() | |
219 | _HOSTCFLAGS=() | |
53300bf0 | 220 | |
4f6c1ba9 | 221 | if { vergte "$selected_cc_version" "6"; }; then |
425e4992 | 222 | # Older kernel Makefiles do not expect the compiler to default to PIE |
a86b55bc KS |
223 | _KAFLAGS+=(-fno-pie) |
224 | _KCFLAGS+=( | |
225 | -fno-pie | |
226 | -no-pie | |
227 | -fno-stack-protector | |
228 | ) | |
229 | _KCPPFLAGS+=(-fno-pie) | |
230 | fi | |
231 | ||
a86b55bc KS |
232 | if { vergte "${selected_cc_version}" "10"; } && { verlt "${kversion}" "5.10"; } ; then |
233 | # gcc-10 changed the default from '-fcommon' to '-fno-common', which | |
234 | # causes a linker failure. '-fcommon' can be set on the HOSTCFLAGS | |
235 | # to avoid the issue. | |
236 | # @see https://gitlab.com/linux-kernel/stable/-/commit/e33a814e772cdc36436c8c188d8c42d019fda639 | |
237 | _HOSTCFLAGS+=(-fcommon) | |
238 | fi | |
239 | ||
53300bf0 MJ |
240 | if { verlt "${kversion}" "5.14"; } && [ "${cross_arch:-}" == "armhf" ] ; then |
241 | # Work-around for producing instructions that aren't valid for the | |
242 | # default architectures. | |
243 | # Eg. Error: selected processor does not support `cpsid i' in ARM mode | |
244 | _KCFLAGS+=(-march=armv7-a -mfpu=vfpv3-d16) | |
245 | _KCPPFLAGS+=(-march=armv7-a -mfpu=vfpv3-d16) | |
a86b55bc KS |
246 | fi |
247 | ||
248 | if { vergt "${selected_cc_version}" "8"; } && { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.17"; } ; then | |
249 | # This was added to -Wall in gcc 9 but some kernels do not include the fixes | |
250 | # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88583 | |
251 | _KCFLAGS+=(-Wno-error=packed-not-aligned) | |
425e4992 MJ |
252 | fi |
253 | ||
a86b55bc KS |
254 | export KAFLAGS="${_KAFLAGS[*]}" |
255 | export KCFLAGS="${_KCFLAGS[*]}" | |
256 | export KCPPFLAGS="${_KCPPFLAGS[*]}" | |
257 | export HOSTCFLAGS="${_HOSTCFLAGS[*]}" | |
5a196804 | 258 | export CC="${CROSS_COMPILE:-}${selected_cc}" |
1d5a0a3c | 259 | export HOSTCC="${selected_cc}" |
5a196804 | 260 | |
a86b55bc KS |
261 | make_args=( |
262 | CC="${CC}" | |
263 | HOSTCC="${HOSTCC}" | |
264 | HOSTCFLAGS="${HOSTCFLAGS:-}" | |
265 | ) | |
53300bf0 | 266 | |
a86b55bc KS |
267 | if [ -n "${DEBUG}" ] ; then |
268 | make_args+=( | |
269 | V=1 | |
270 | ) | |
271 | fi | |
5a196804 MJ |
272 | } |
273 | ||
a86b55bc KS |
274 | patch_linux_kernel() { |
275 | local commit_hash | |
276 | commit_hash="$1" | |
53300bf0 MJ |
277 | |
278 | # Show the title of the patch in the build log | |
279 | git -C "${LINUX_GIT_REF_REPO_DIR}" show --oneline -s "${commit_hash}" | |
280 | ||
281 | # Apply patch, don't fail if it doesn't apply cleanly | |
a86b55bc KS |
282 | set +e |
283 | git -C "${LINUX_GIT_REF_REPO_DIR}" format-patch -n1 --stdout "${commit_hash}" | patch -p1 | |
284 | set -e | |
53300bf0 | 285 | |
a86b55bc KS |
286 | if [ "$?" -gt 1 ] ; then |
287 | echo "Serious issue patching" | |
288 | exit 1 | |
289 | fi | |
290 | } | |
5a196804 MJ |
291 | |
292 | build_linux_kernel() { | |
293 | cd "$LINUX_SRCOBJ_DIR" | |
294 | ||
a86b55bc | 295 | kversion=$(make -s kernelversion "${make_args[@]}") |
23ebcd4b | 296 | pahole_version="$(pahole --version | tr -d 'v')" |
a86b55bc KS |
297 | |
298 | if { verlt "${kversion}" "3.3"; } && [ "${vanilla_config}" = "imx_v6_v7_defconfig" ] ; then | |
299 | # imx_v6_v7 didn't exist before 06965c39b4c63933fa0a1cde2237ef85477c5655 | |
300 | if { verlt "${kversion}" "3.2"; } ; then | |
301 | vanilla_config='mx5_defconfig' | |
302 | else | |
303 | vanilla_config='mx51_defconfig' | |
304 | fi | |
305 | fi | |
306 | ||
307 | if { verlt "${kversion}" "3.13"; } && [ "${vanilla_config}" = "pseries_le_defconfig" ] ; then | |
308 | # pseries_le_deconfig was introduced in f53e462e907cbaed29c49c0f10f5b8f614e1bf1d | |
309 | vanilla_config='pseries_defconfig' | |
310 | fi | |
5a196804 | 311 | |
7e02032c | 312 | # Generate kernel configuration |
a1ae361e | 313 | case "$ktag" in |
7e02032c | 314 | Ubuntu*) |
f16755cf MJ |
315 | if [ "${cross_arch}" = "powerpc" ] && vergte "${kversion}" "4.10"; then |
316 | echo "Ubuntu removed big endian powerpc configuration from kernel >= 4.10. Don't try to build it." | |
317 | exit 0 | |
318 | fi | |
319 | ||
320 | if [ "${cross_arch}" = "riscv64" ] && verlt "${kversion}" "6.2"; then | |
321 | echo "Ubuntu added RISC-V config to their 'regular' kernels in v6.2. Don't try to build it." | |
322 | exit 0 | |
39961776 | 323 | fi |
af101606 | 324 | |
009efde7 KS |
325 | FAKEROOT_ARGS=( |
326 | 'KW_DEFCONFIG_DIR=.' | |
327 | ) | |
328 | fakeroot debian/rules clean "${FAKEROOT_ARGS[@]}" | |
0c1bde3d | 329 | |
073dc82c | 330 | # Hack for kernel Ubuntu-hwe-5.8 |
0c1bde3d KS |
331 | # The debian/control file is produced by the clean target above, so this |
332 | # check needs to happen afterwards. | |
333 | if [ ! -f "debian/compat" ] && ! grep -q debhelper-compat debian/control; then | |
073dc82c MJ |
334 | echo "10" > "debian/compat" |
335 | fi | |
336 | ||
0c1bde3d KS |
337 | # genconfigs check can fail in certain cases, eg. when a more recent |
338 | # compiler exposes kernel configuration flags which aren't set in the | |
339 | # Ubuntu annotations. | |
340 | # In any case, the configuration will be updated with any missing values | |
341 | # later in our build script. | |
009efde7 KS |
342 | FAKEROOT_ARGS+=('do_skip_checks=true') |
343 | ||
344 | # Some Ubuntu tags default the toolchain using `gcc?=gcc-XX` in | |
345 | # `debian/rules.d/0-common-vars.mk`. This may fail if the gcc version | |
346 | # used as a default isn't available. | |
347 | # For example, Ubuntu-6.8.0-7.7 sets `gcc?=gcc-13`, and that version | |
348 | # of gcc isn't available on the deb12-amd64 ci-nodes. | |
349 | # Work has also already been done in `select_compiler` to make our | |
350 | # own decision of which compiler to use. As a result of both cases, | |
351 | # our compiler choice should be passed into genconfigs. | |
352 | FAKEROOT_ARGS+=("gcc=${selected_cc}") | |
353 | ||
354 | fakeroot debian/rules genconfigs "${FAKEROOT_ARGS[@]}" | |
5a196804 | 355 | cp CONFIGS/"${ubuntu_config}" .config |
7e02032c | 356 | ;; |
c45b04df | 357 | |
7e02032c | 358 | *) |
16844a6d MJ |
359 | # Force 32bit build on i386, default is 64bit |
360 | if [ "$arch" = "i386" ]; then | |
5a196804 MJ |
361 | export ARCH="i386" |
362 | fi | |
363 | ||
a86b55bc | 364 | make "${vanilla_config}" "${make_args[@]}" |
7e02032c MJ |
365 | ;; |
366 | esac | |
367 | ||
a86b55bc KS |
368 | if [ "${vanilla_config}" = "pseries_defconfig" ] && [ "${cross_arch}" = "ppc64el" ] ; then |
369 | # @see diff <(git show v3.13:arch/powerpc/configs/pseries_defconfig) <(git show v3.13:arch/powerpc/configs/pseries_le_defconfig) | |
370 | scripts/config --enable CONFIG_CPU_LITTLE_ENDIAN | |
371 | scripts/config --enable CONFIG_CMA | |
372 | scripts/config --disable CONFIG_XMON_DEFAULT | |
373 | # scripts/config --disable CONFIG_VIRTUALIZATION | |
374 | # scripts/config --disable CONFIG_KVM_BOOK3S_64 | |
375 | scripts/config --disable CONFIG_KVM_BOOK3S_64_HV | |
376 | fi | |
377 | ||
4d8b6258 KS |
378 | if [ -f "init/Kconfig.suse" ] ; then |
379 | # Get values from git tag, eg. 'rpm-5.14.21-150400.24.108' | |
380 | # Note: the "150400" type of SUSE major version is only present on tags | |
381 | # from 2022 and newer (about half-way through SLE15SP3). | |
382 | # This will not work as expected on earlier tags. | |
383 | SLES_RELEASE="$(echo "${ktag}" | cut -d '-' -f 3 | cut -d'.' -f 1)" | |
384 | scripts/config --set-val CONFIG_SUSE_VERSION $((10#"$(echo "${SLES_RELEASE}" | head -c 2)")) | |
385 | scripts/config --set-val CONFIG_SUSE_PATCHLEVEL $((10#"$(echo "${SLES_RELEASE}" | head -c 4 | tail -c 2)")) | |
386 | ||
387 | # Disable the renesas clk driver that has build issues, | |
388 | # eg. drivers/clk/renesas/renesas-rzg2l-cpg.c:185:17: error: ‘clk’ undeclared (first use in this function) | |
389 | scripts/config --disable CONFIG_CLK_RENESAS | |
390 | ||
391 | # From drives/spi/spi-atmel.c | |
392 | # ./include/linux/gpio/consumer.h:141:49: note: expected ‘struct gpio_desc *’ but argument is of type 'int' | |
393 | scripts/config --disable CONFIG_SPI_ATMEL | |
394 | scripts/config --disable CONFIG_SPI_AT91_USART | |
395 | scripts/config --disable CONFIG_SPI_ATMEL_QUADSPI | |
396 | ||
397 | # drivers/net/wireless/mediatek/mt76/mt7915/testmode.c: In function ‘mt7915_tm_set_wmm_qid’: | |
398 | # drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:176:30: error: ‘struct mt7915_vif’ has no member named ‘mt76’ | |
399 | scripts/config --disable CONFIG_WLAN_VENDOR_MEDIATEK | |
400 | ||
401 | # drivers/net/wireless/microchip/wilc1000/cfg80211.c: In function ‘wilc_wfi_cfg_parse_ch_attr’: | |
402 | # drivers/net/wireless/microchip/wilc1000/cfg80211.c:970:17: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode | |
403 | scripts/config --disable CONFIG_WLAN_VENDOR_MICROCHIP | |
404 | ||
405 | # fs/f2fs/file.c: In function ‘punch_hole’: | |
406 | # fs/f2fs/file.c:1093:49: error: ‘mapping’ undeclared (first use in this function) | |
407 | scripts/config --disable CONFIG_F2FS_FS | |
408 | fi | |
409 | ||
53b51a15 | 410 | # oldnoconfig was renamed in 4.19 |
5a196804 | 411 | if vergte "$kversion" "4.19"; then |
53b51a15 | 412 | update_conf_target="olddefconfig" |
5a196804 | 413 | else |
53b51a15 | 414 | update_conf_target="oldnoconfig" |
5a196804 MJ |
415 | fi |
416 | ||
417 | # Fix 'defined(@array)' was removed from recent perl | |
418 | if [ -f "kernel/timeconst.pl" ]; then | |
419 | sed -i 's/defined(\@\(.*\))/@\1/' kernel/timeconst.pl | |
420 | fi | |
421 | ||
422 | # Fix syntax of inline assembly which is confused with C++11 raw strings on gcc >= 5 | |
53b51a15 | 423 | if [ "$HOSTCC" != "gcc-4.8" ]; then |
5a196804 MJ |
424 | if [ -f "arch/x86/kvm/svm.c" ]; then |
425 | sed -i 's/ R"/ R "/g; s/"R"/" R "/g' arch/x86/kvm/svm.c | |
426 | fi | |
427 | ||
428 | if [ -f "arch/x86/kvm/vmx.c" ]; then | |
429 | sed -i 's/ R"/ R "/g; s/"R"/" R "/g' arch/x86/kvm/vmx.c | |
430 | fi | |
431 | fi | |
432 | ||
a86b55bc KS |
433 | if { verlt "${kversion}" "5.11"; } && { vergte "${kversion}" "4.10"; } ; then |
434 | # Binutils > 2.35 strips empty symbol tables, causing obltool to fail | |
435 | # in certain cases when files are empty. | |
436 | # @see https://gitlab.com/linux-kernel/stable/-/commit/1d489151e9f9d1647110277ff77282fe4d96d09b | |
437 | # | |
438 | # There doesn't seem to be any LD/AS/AR flags to control this behaviour, | |
439 | # therefore patching tools/objtool/elf.c is attempted. | |
440 | patch_linux_kernel 1d489151e9f9d1647110277ff77282fe4d96d09b | |
441 | if { verlt "${kversion}" "4.18"; } ; then | |
442 | patch_linux_kernel e81e0724432542af8d8c702c31e9d82f57b1ff31 | |
443 | fi | |
444 | fi | |
445 | ||
9383502e | 446 | if { vergt "${selected_cc_version}" "7"; } && { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.17"; } ; then |
a86b55bc KS |
447 | # Builds fail due to -Werror=restrict in pager.o and str_error_r.o |
448 | if { verlt "${kversion}" "4.16"; } ; then | |
449 | # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS | |
450 | # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ad343a98e74e85aa91d844310e797f96fee6983b | |
451 | patch_linux_kernel ad343a98e74e85aa91d844310e797f96fee6983b | |
452 | fi | |
453 | if { verlt "${kversion}" "4.17"; } ; then | |
454 | # This is patched since objtool's Makefile doesn't respect HOSTCFLAGS | |
455 | # @see https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=854e55ad289ef8888e7991f0ada85d5846f5afb9 | |
456 | patch_linux_kernel 854e55ad289ef8888e7991f0ada85d5846f5afb9 | |
457 | fi | |
458 | ||
ad23f63b KS |
459 | fi |
460 | ||
461 | if { vergt "${selected_cc_version}" "9"; } && { verlt "${kversion}" "5.6"; } ; then | |
a86b55bc KS |
462 | # Duplicate decalarations of __force_order |
463 | # @see https://gitlab.com/linux-kernel/stable/-/commit/df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc | |
464 | # However, kaslr_64.c doesn't exit in 4.15, 4.16, it's named pagetable.c | |
465 | if [ -f arch/x86/boot/compressed/pagetable.c ] ; then | |
466 | sed -i '/^unsigned long __force_order;$/d' arch/x86/boot/compressed/pagetable.c | |
467 | fi | |
9ae537d7 KS |
468 | if [ -f arch/x86/boot/compressed/kaslr_64.c ] ; then |
469 | patch_linux_kernel df6d4f9db79c1a5d6f48b59db35ccd1e9ff9adfc | |
470 | fi | |
471 | fi | |
472 | ||
473 | if { vergte "${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then | |
474 | # In some cases, compiling net/bpfilter can fail with the following error: | |
475 | # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory | |
476 | # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1 | |
477 | # | |
478 | # While the issue is potentially in a number of old versions, it has only | |
479 | # been observed in v4.18-rt | |
480 | # | |
481 | patch_linux_kernel 303a339f30a9441c4695d3d2cc78f1b33cd959ff | |
482 | fi | |
483 | ||
484 | if { vergte "${kversion}" "4.18"; } && { verlt "${kversion}" "4.19"; } ; then | |
485 | # In some cases, compiling net/bpfilter can fail with the following error: | |
486 | # net/bpfilter/main.c:9:10: fatal error: include/uapi/linux/bpf.h: No such file or directory | |
487 | # make[2]: *** [scripts/Makefile.host:107: net/bpfilter/main.o] Error 1 | |
488 | # | |
489 | # While the issue is potentially in a number of old versions, it has only | |
490 | # been observed in v4.18-rt | |
491 | # | |
492 | patch_linux_kernel 303a339f30a9441c4695d3d2cc78f1b33cd959ff | |
a86b55bc KS |
493 | fi |
494 | ||
495 | if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ; then | |
496 | # Some old kernels fail to build when make is too new | |
497 | # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583 | |
498 | patch_linux_kernel 9564a8cf422d7b58f6e857e3546d346fa970191e | |
9383502e MJ |
499 | fi |
500 | ||
501 | if { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.55"; } ; then | |
502 | # Some old kernels fail to build when make is too new | |
503 | # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583 | |
504 | patch_linux_kernel e82885490a611f2b75a6c27cd7bb09665c1740be | |
505 | fi | |
506 | ||
507 | if ( { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.18"; } ) || \ | |
508 | ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.56"; } ) ; then | |
509 | # Some old kernels fail to build when make is too new | |
a86b55bc KS |
510 | # @see https://gitlab.com/linux-kernel/stable/-/commit/9feeb638cde083c737e295c0547f1b4f28e99583 |
511 | patch_linux_kernel 9feeb638cde083c737e295c0547f1b4f28e99583 | |
512 | fi | |
513 | ||
c0849ee1 MJ |
514 | if ( { vergte "${kversion}" "4.12"; } && { verlt "${kversion}" "4.20.17"; } ) || \ |
515 | ( { vergte "${kversion}" "5.0"; } && { verlt "${kversion}" "5.0.12"; } ) ; then | |
7b15f9fa KS |
516 | # Old kernels can fail to build while on newer host kernels with errors |
517 | # such as: | |
518 | # In file included from scripts/selinux/genheaders/genheaders.c:19: | |
519 | # ./security/selinux/include/classmap.h:249:2: error: #error New address family defined, please update secclass_map. | |
a86b55bc KS |
520 | # @see https://gitlab.com/linux-kernel/stable/-/commit/dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e |
521 | # | |
522 | patch_linux_kernel dfbd199a7cfe3e3cd8531e1353cdbd7175bfbc5e | |
523 | fi | |
524 | ||
c05bf06f MJ |
525 | # Compatibility with binutils >= ~ 2.31 |
526 | if { vergte "${kversion}" "3.19"; } && { verlt "${kversion}" "4.16"; } ; then | |
a86b55bc KS |
527 | patch_linux_kernel b21ebf2fb4cde1618915a97cc773e287ff49173e |
528 | fi | |
c05bf06f MJ |
529 | if { vergte "${kversion}" "3.17"; } && { verlt "${kversion}" "3.18.69"; } ; then |
530 | patch_linux_kernel edb9d2d5e647e7a8521b0d35f8452deb02dfd138 | |
531 | fi | |
532 | if { vergte "${kversion}" "3.17"; } && { verlt "${kversion}" "3.18.100"; } ; then | |
533 | patch_linux_kernel 3be6583f0b6f1bf1ee650ebf473d9dee36836527 | |
534 | patch_linux_kernel 12d839211d080f6a9c370398c41a260365d34c62 | |
535 | fi | |
536 | if { vergte "${kversion}" "3.16"; } && { verlt "${kversion}" "3.16.82"; } ; then | |
537 | patch_linux_kernel ad10e6d464796f2a481de4039a43b9cfca034e1c | |
a86b55bc KS |
538 | fi |
539 | ||
4d7942d1 | 540 | if ( { vergte "${kversion}" "3.14"; } && { verlt "${kversion}" "4.4"; } ) || |
9ae537d7 | 541 | ( { vergte "${kversion}" "4.8"; } && { verlt "${kversion}" "4.18"; } ); then |
a86b55bc | 542 | # While the original motivation of this patch is for fixing builds using |
4d7942d1 | 543 | # clang, the same error occurs between linux >= 3.14 and < 4.4, and in |
a86b55bc | 544 | # 4.15, 4.16. |
9ae537d7 | 545 | # For rt-linux, the error has been observed in 4.8, 4.11, and 4.13. |
a86b55bc KS |
546 | # |
547 | # This patch only partially applies due to changes in kernel/Makefile, | |
548 | # so a supplementary patch is needed | |
549 | # | |
550 | # Without this patch, builds fail with | |
551 | # Cannot find symbol for section 2: .text. | |
552 | # kernel/elfcore.o: failed | |
553 | # | |
554 | # @see https://github.com/linuxppc/issues/issues/388 | |
555 | # @see https://lore.kernel.org/lkml/20201204165742.3815221-2-arnd@kernel.org/ | |
556 | # | |
557 | patch_linux_kernel 6e7b64b9dd6d96537d816ea07ec26b7dedd397b9 | |
558 | if grep -q elfcore.o kernel/Makefile ; then | |
559 | sed -i '/^.* += elfcore.o$/d' kernel/Makefile | |
560 | fi | |
561 | fi | |
9bbfa9db MJ |
562 | # Same as above for the v4.4 branch |
563 | if ( { vergte "${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.257"; } ); then | |
564 | patch_linux_kernel 3140b0740b31cc63cf2ee08bc3f746b423eb068d | |
565 | if grep -q elfcore.o kernel/Makefile ; then | |
566 | sed -i '/^.* += elfcore.o$/d' kernel/Makefile | |
567 | fi | |
568 | fi | |
a86b55bc | 569 | |
15ef760e | 570 | if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ; then |
53300bf0 MJ |
571 | # Kernels between v4.5 and v4.8 built with gcc >= 8 on arm will hit an |
572 | # assembler error : | |
15ef760e MJ |
573 | # |
574 | # kernel/.tmp_fork.s: Assembler messages: | |
575 | # kernel/.tmp_fork.s:1790: Error: .err encountered | |
53300bf0 MJ |
576 | # |
577 | # @see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85745 | |
15ef760e MJ |
578 | # |
579 | patch_linux_kernel 9f73bd8bb445e0cbe4bcef6d4cfc788f1e184007 | |
580 | fi | |
581 | ||
c0849ee1 MJ |
582 | if ( { vergte "${kversion}" "4.4"; } && { verlt "${kversion}" "4.4.136"; } ) || |
583 | ( { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.8"; } ); then | |
9ae537d7 KS |
584 | # Hacky patch to deal with the following build error: |
585 | # Cannot find symbol for section 7: .text.unlikely. | |
586 | # kernel/kexec_file.o: failed | |
587 | # make[1]: *** [scripts/Makefile.build:291: kernel/kexec_file.o] Error 1 | |
588 | # | |
589 | # This error happens with binutils 2.36 and 2.37, but should probably not | |
590 | # be an issue with binutils 2.38. | |
591 | # @see https://github.com/linuxppc/issues/issues/388 | |
592 | # @see https://github.com/bminor/binutils-gdb/commit/c09c8b42021180eee9495bd50d8b35e683d3901b | |
593 | # | |
594 | # There is some sort of config (unspecified in past discussions) which | |
595 | # provokes the error, and there was never a potential fix merged in | |
596 | # this discussion, in part because the build systems of the kernel | |
597 | # switched to objtool instead. | |
598 | # | |
599 | # @see https://lore.kernel.org/all/20210215162209.5e2a475b@gandalf.local.home/ | |
600 | # | |
601 | sed -i 's/return txtname;/return shdr0->sh_size ? txtname : NULL;/' scripts/recordmcount.h | |
602 | ||
603 | # After applying the above patch, the build continues but fails with | |
604 | # head64.c:(.text.exit+0x5): undefined reference to `__gcov_exit' | |
605 | # | |
606 | scripts/config --disable CONFIG_GCOV_KERNEL | |
607 | fi | |
608 | ||
c0849ee1 MJ |
609 | if { vergte "${kversion}" "4.5"; } && { verlt "${kversion}" "4.5.5"; } ; then |
610 | # drivers/staging/wilc1000/wilc_spi.c:123:34: error: storage size of ‘wilc1000_spi_ops’ isn’t known | |
611 | patch_linux_kernel ce7b516f3f9e11fe4ee06fad0d7e853bb6e8f160 | |
612 | fi | |
613 | ||
53b51a15 MJ |
614 | # Newer binutils don't accept 3 operand 'cmp' instructions on ppc64 |
615 | # Convert them to 'cmpw' which was previously done silently | |
616 | if verlt "$kversion" "4.9"; then | |
53300bf0 MJ |
617 | 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/" |
618 | 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/" | |
619 | sed -i "s/\$pie \-o \"\$ofile\"/\$pie --no-dynamic-linker -o \"\$ofile\"/" arch/powerpc/boot/wrapper | |
53b51a15 MJ |
620 | fi |
621 | ||
9ae537d7 KS |
622 | if [ "$(scripts/config --state CONFIG_EXTCON_ADC_JACK)" != "n" ] && |
623 | ( { vergte "${kversion}" "4.2"; } && { verlt "${kversion}" "4.12"; } ); then | |
624 | # 73b6ecdb93e8e77752cae9077c424fcdc6f23c39 introduced a change where | |
625 | # extcon-adc-jack.h has an incompatible pointer type. | |
626 | # In GCC >= 5 this will provoke a warning and build failure. | |
627 | # Eg. | |
628 | # drivers/extcon/extcon-adc-jack.c: In function ‘adc_jack_probe’: | |
629 | # 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] | |
630 | # make[2]: *** [scripts/Makefile.build:295: drivers/extcon/extcon-adc-jack.o] Error 1 | |
631 | # | |
632 | # 8a522bf2d4f788306443d36b26b54f0aedcdfdbe (in 4.11) has a fix for this warning | |
633 | # | |
634 | patch_linux_kernel 8a522bf2d4f788306443d36b26b54f0aedcdfdbe | |
635 | fi | |
636 | ||
9383502e MJ |
637 | if ( { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.15.2"; } ) || \ |
638 | ( { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.18"; } ) ; then | |
639 | # Fix an objtool Segmentation fault | |
640 | patch_linux_kernel dd12561854824fd1f05baf2a1b794faa046e2425 | |
641 | fi | |
642 | ||
643 | if { vergte "${kversion}" "4.14"; } && { verlt "${kversion}" "4.14.268"; } ; then | |
644 | # Builds fail due to -Werror=use-after-free in sigchain.o and help.o | |
645 | patch_linux_kernel e89bb266b710ce056f141f29f091fd468a4a8185 | |
646 | fi | |
647 | ||
5a196804 MJ |
648 | # Fix a typo in v2.6.36.x |
649 | if [ -f "arch/x86/kernel/entry_64.S" ]; then | |
650 | sed -i 's/END(do_hypervisor_callback)/END(xen_do_hypervisor_callback)/' arch/x86/kernel/entry_64.S | |
651 | fi | |
652 | ||
53b51a15 MJ |
653 | # Fix compiler switch in vdso Makefile for 2.6.36 to 2.6.36.2 |
654 | if { vergte "$kversion" "2.6.36" && verlte "$kversion" "2.6.36.3"; }; then | |
655 | sed -i 's/-m elf_x86_64/-m64/' arch/x86/vdso/Makefile | |
656 | sed -i 's/-m elf_i386/-m32/' arch/x86/vdso/Makefile | |
657 | fi | |
658 | ||
5a196804 MJ |
659 | # Fix kernel < 3.0 with gcc >= 4.7 |
660 | if verlt "$kversion" "3.0"; then | |
661 | sed -i '/linux\/compiler.h/a #include <linux\/linkage.h> \/* For asmregparm *\/' arch/x86/include/asm/ptrace.h | |
662 | sed -i 's/extern long syscall_trace_enter/extern asmregparm long syscall_trace_enter/' arch/x86/include/asm/ptrace.h | |
663 | sed -i 's/extern void syscall_trace_leave/extern asmregparm void syscall_trace_leave/' arch/x86/include/asm/ptrace.h | |
664 | echo "header-y += linkage.h" >> include/linux/Kbuild | |
665 | fi | |
666 | ||
a86b55bc KS |
667 | if [ "${cross_arch}" = "powerpc" ] ; then |
668 | if { vergte "${kversion}" "4.15"; } && { verlt "${kversion}" "4.16"; } ; then | |
669 | # Avoid register errors such as | |
670 | # aes_generic.c:(.text+0x4e0): undefined reference to `_restgpr_31_x' | |
671 | # @see https://gitlab.com/linux-kernel/stable/-/commit/148b974deea927f5dbb6c468af2707b488bfa2de | |
672 | make_args+=( | |
673 | CFLAGS_aes_generic.o='' | |
674 | ) | |
675 | fi | |
676 | fi | |
677 | ||
23ebcd4b KS |
678 | if [ "$(scripts/config --state CONFIG_DEBUG_INFO_BTF)" == "y" ] && |
679 | { vergte "${pahole_version}" "1.24"; } && | |
680 | { vergte "${kversion}" "5.10"; } && { verlt "${kversion}" "6.0"; } ;then | |
681 | # Some kernels Eg. Ubuntu-hwe-5.13-5.13.0-52.59_20.04.1 | |
682 | # fail with the following error: | |
683 | # BTFIDS vmlinux | |
684 | # FAILED: load BTF from vmlinux: Invalid argument | |
685 | # | |
686 | # When CONFIG_DEBUG_INFO_BTF is set, certain versions of pahole require | |
687 | # `--skip_encoding_btf_enum64` to be passed as the kernel doesn't define | |
688 | # BTF_KIND_ENUM64. | |
689 | # | |
690 | # Introduced in 341dfcf8d78eaa3a2dc96dea06f0392eb2978364 (~v5.10) | |
691 | # @see https://lore.kernel.org/bpf/20220825171620.cioobudss6ovyrkc@altlinux.org/t/ | |
692 | # | |
693 | if [ -f "scripts/pahole-flags.sh" ] ; then | |
53300bf0 | 694 | # shellcheck disable=SC2016 |
23ebcd4b KS |
695 | sed -i 's/ -J ${PAHOLE_FLAGS} / -J ${PAHOLE_FLAGS} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh |
696 | else | |
53300bf0 | 697 | # shellcheck disable=SC2016 |
23ebcd4b KS |
698 | sed -i 's/ -J ${extra_paholeopt} / -J ${extra_paholeopt} --skip_encoding_btf_enum64 /' scripts/link-vmlinux.sh |
699 | fi | |
700 | fi | |
701 | ||
7e02032c | 702 | # GCC 4.8 |
53b51a15 | 703 | if [ "$HOSTCC" == "gcc-4.8" ]; then |
a86b55bc KS |
704 | scripts/config --disable CONFIG_CC_STACKPROTECTOR_STRONG |
705 | scripts/config --disable CONFIG_PPC_OF_BOOT_TRAMPOLINE | |
53b51a15 | 706 | fi |
7e02032c MJ |
707 | |
708 | # Don't try to sign modules | |
53b51a15 | 709 | scripts/config --disable CONFIG_MODULE_SIG |
7e02032c | 710 | |
9ef18fa2 | 711 | # Disable kernel stack frame correctness validation, introduced in 4.6.0 and currently fails |
53b51a15 | 712 | scripts/config --disable CONFIG_STACK_VALIDATION |
5a196804 MJ |
713 | |
714 | # Cause problems with inline assembly on i386 | |
53b51a15 | 715 | scripts/config --disable CONFIG_DEBUG_SECTION_MISMATCH |
5a196804 | 716 | |
1d5a0a3c | 717 | # Don't build samples, they are broken on some kernel releases |
53b51a15 MJ |
718 | scripts/config --disable CONFIG_SAMPLES |
719 | scripts/config --disable CONFIG_BUILD_DOCSRC | |
c45b04df MJ |
720 | |
721 | # Disable kcov | |
53b51a15 | 722 | scripts/config --disable CONFIG_KCOV |
c45b04df MJ |
723 | |
724 | # Broken on some RT kernels | |
53b51a15 | 725 | scripts/config --disable CONFIG_HYPERV |
1d5a0a3c | 726 | |
1e300ea9 | 727 | # Broken drivers |
53b51a15 MJ |
728 | scripts/config --disable CONFIG_RAPIDIO_TSI721 |
729 | scripts/config --disable CONFIG_SGI_XP | |
730 | scripts/config --disable CONFIG_MFD_WM8994 | |
731 | scripts/config --disable CONFIG_DRM_RADEON | |
732 | scripts/config --disable CONFIG_SND_SOC_WM5100 | |
a9aea01c KS |
733 | # More recent compiler optimizations (from gcc 8 onwards )expose build errors |
734 | # with netronome on older kernels. | |
735 | # Observed in 4.11-rt, 4.15-4.17, 5.0-rt - 5.16-rt | |
736 | # It seems easier to disable the driver than to attempt patching. | |
737 | # Eg. | |
738 | # In function ‘ur_load_imm_any’, | |
739 | # inlined from ‘jeq_imm’ at drivers/net/ethernet/netronome/nfp/bpf/jit.c:3146:13: | |
740 | # ./include/linux/compiler.h:350:45: error: call to ‘__compiletime_assert_1062’ declared with attribute error: FIELD_FIT: value too large for the field | |
741 | # 350 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | |
742 | # | |
743 | scripts/config --disable CONFIG_NET_VENDOR_NETRONOME | |
744 | # Eg. | |
745 | # In function ‘memcpy’, | |
746 | # inlined from ‘kszphy_get_strings’ at drivers/net/phy/micrel.c:664:3: | |
747 | # ./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 | |
748 | # 305 | __read_overflow2(); | |
749 | # | ^~~~~~~~~~~~~~~~~~ | |
750 | # make[3]: *** [scripts/Makefile.build:308: drivers/net/phy/micrel.o] Error 1 | |
751 | # | |
752 | scripts/config --disable CONFIG_MICREL_PHY | |
753 | ||
1e300ea9 | 754 | |
5a196804 MJ |
755 | # IGBVF won't build with recent gcc on 2.6.38.x |
756 | if { vergte "$kversion" "2.6.37" && verlt "$kversion" "2.6.38"; }; then | |
53b51a15 | 757 | scripts/config --disable CONFIG_IGBVF |
5a196804 | 758 | fi |
9ef18fa2 | 759 | |
c72041eb MJ |
760 | # Don't fail the build on warnings |
761 | scripts/config --disable CONFIG_WERROR | |
a86b55bc | 762 | scripts/config --enable CONFIG_PPC_DISABLE_WERROR |
c72041eb | 763 | |
51fa2ab3 | 764 | # Set required options |
53b51a15 MJ |
765 | scripts/config --enable CONFIG_TRACEPOINTS |
766 | scripts/config --enable CONFIG_KALLSYMS | |
767 | scripts/config --enable CONFIG_HIGH_RES_TIMERS | |
768 | scripts/config --enable CONFIG_KPROBES | |
769 | scripts/config --enable CONFIG_FTRACE | |
770 | scripts/config --enable CONFIG_BLK_DEV_IO_TRACE | |
771 | scripts/config --enable CONFIG_KALLSYMS_ALL | |
772 | scripts/config --enable CONFIG_HAVE_SYSCALL_TRACEPOINTS | |
773 | scripts/config --enable CONFIG_PERF_EVENTS | |
774 | scripts/config --enable CONFIG_EVENT_TRACING | |
775 | scripts/config --enable CONFIG_KRETPROBES | |
7e02032c | 776 | |
a86b55bc KS |
777 | if [ -n "${DEBUG}" ] ; then |
778 | cat .config | |
779 | fi | |
5a196804 | 780 | |
a86b55bc KS |
781 | make "$update_conf_target" "${make_args[@]}" |
782 | make -j"$NPROC" "${make_args[@]}" | |
5a196804 | 783 | |
80eda7bb | 784 | krelease=$(make -s kernelrelease "${make_args[@]}") |
5a196804 MJ |
785 | |
786 | # Save the kernel and modules | |
787 | mkdir -p "$LINUX_INSTOBJ_DIR/boot" | |
a86b55bc KS |
788 | make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_MOD_STRIP=1 modules_install "${make_args[@]}" |
789 | make INSTALL_MOD_PATH="$LINUX_INSTOBJ_DIR" INSTALL_PATH="$LINUX_INSTOBJ_DIR/boot" install "${make_args[@]}" | |
5a196804 MJ |
790 | rm -f "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/build" |
791 | ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" | |
792 | ln -s ../../../../sources "$LINUX_INSTOBJ_DIR/lib/modules/${krelease}/source" | |
793 | } | |
794 | ||
795 | ||
796 | extract_distro_headers() { | |
797 | ||
798 | # Enter linux source dir | |
799 | cd "${LINUX_SRCOBJ_DIR}" | |
800 | ||
801 | ||
802 | # For RT kernels, copy version file | |
803 | if [ -s localversion-rt ]; then | |
804 | cp -a localversion-rt "${LINUX_HDROBJ_DIR}" | |
805 | fi | |
806 | ||
807 | # Copy all Makefile related stuff | |
808 | find . -path './include/*' -prune \ | |
809 | -o -path './scripts/*' -prune -o -type f \ | |
810 | \( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \ | |
811 | -name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \ | |
812 | -print | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}" | |
813 | ||
814 | # Copy base scripts and include dirs | |
815 | cp -a scripts include "${LINUX_HDROBJ_DIR}" | |
7e02032c | 816 | |
5a196804 MJ |
817 | # Copy arch includes |
818 | (find arch -name include -type d -print0 | \ | |
efdab1b7 | 819 | xargs -0 -n1 -I '{}' find '{}' -type f) | \ |
5a196804 MJ |
820 | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}" |
821 | ||
822 | # Copy arch scripts | |
823 | (find arch -name scripts -type d -print0 | \ | |
efdab1b7 | 824 | xargs -0 -n1 -I '{}' find '{}' -type f) | \ |
5a196804 MJ |
825 | cpio -pd --preserve-modification-time "${LINUX_HDROBJ_DIR}" |
826 | ||
827 | # Cleanup scripts | |
828 | rm -f "${LINUX_HDROBJ_DIR}/scripts/*.o" | |
829 | rm -f "${LINUX_HDROBJ_DIR}/scripts/*/*.o" | |
830 | ||
04873cc3 | 831 | # On powerpc 32bits this object is required to link modules |
5a196804 | 832 | if [ "${karch}" = "powerpc" ]; then |
efdab1b7 | 833 | if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then |
10528202 MJ |
834 | : |
835 | else | |
04873cc3 MJ |
836 | cp -a --parents arch/powerpc/lib/crtsavres.[So] "${LINUX_HDROBJ_DIR}/" |
837 | fi | |
5a196804 MJ |
838 | fi |
839 | ||
840 | # On arm64 between 4.13 and 1.15 this object is required to build with ftrace support | |
841 | if [ "${karch}" = "arm64" ]; then | |
842 | if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then | |
843 | cp -a --parents arch/arm64/kernel/ftrace-mod.[So] "${LINUX_HDROBJ_DIR}/" | |
844 | fi | |
845 | fi | |
846 | ||
ae365617 MJ |
847 | # On riscv with 5.14 the vsdo objects are required |
848 | if [ "${karch}" = "riscv" ] && \ | |
849 | ( { vergte "${kversion}" "5.14"; } && { verlt "${kversion}" "5.15"; } ); then | |
850 | cp -a --parents arch/riscv/kernel/vdso/*.o "${LINUX_HDROBJ_DIR}/" | |
851 | fi | |
852 | ||
5a196804 MJ |
853 | # Newer kernels need objtool to build modules when CONFIG_STACK_VALIDATION=y |
854 | if [ -f tools/objtool/objtool ]; then | |
855 | cp -a --parents tools/objtool/objtool "${LINUX_HDROBJ_DIR}/" | |
856 | fi | |
857 | ||
858 | if [ -f "arch/x86/kernel/macros.s" ]; then | |
859 | cp -a --parents arch/x86/kernel/macros.s "${LINUX_HDROBJ_DIR}/" | |
860 | fi | |
861 | ||
862 | # Copy modules related stuff, if available | |
863 | if [ -s Module.symvers ]; then | |
864 | cp Module.symvers "${LINUX_HDROBJ_DIR}" | |
865 | fi | |
866 | ||
867 | if [ -s System.map ]; then | |
868 | cp System.map "${LINUX_HDROBJ_DIR}" | |
869 | fi | |
870 | ||
871 | if [ -s Module.markers ]; then | |
872 | cp Module.markers "${LINUX_HDROBJ_DIR}" | |
873 | fi | |
874 | ||
875 | # Copy config file | |
876 | cp .config "${LINUX_HDROBJ_DIR}" | |
877 | ||
878 | # Make sure the Makefile and version.h have a matching timestamp so that | |
879 | # external modules can be built | |
880 | if [ -s "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" ]; then | |
881 | touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/generated/uapi/linux/version.h" | |
882 | elif [ -s "${LINUX_HDROBJ_DIR}/include/linux/version.h" ]; then | |
883 | touch -r "${LINUX_HDROBJ_DIR}/Makefile" "${LINUX_HDROBJ_DIR}/include/linux/version.h" | |
884 | else | |
885 | echo "Missing version.h" | |
886 | exit 1 | |
887 | fi | |
888 | touch -r "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/generated/autoconf.h" | |
889 | ||
890 | # Copy .config to include/config/auto.conf so "make prepare" is unnecessary. | |
780f6285 MJ |
891 | if [ ! -f "${LINUX_HDROBJ_DIR}/include/config/auto.conf" ]; then |
892 | cp "${LINUX_HDROBJ_DIR}/.config" "${LINUX_HDROBJ_DIR}/include/config/auto.conf" | |
893 | fi | |
5a196804 MJ |
894 | |
895 | # Finally clean the object files from the full source tree | |
896 | make clean | |
897 | ||
898 | # And regen the modules support files | |
a86b55bc | 899 | make modules_prepare "${make_args[@]}" |
51fa2ab3 | 900 | |
04873cc3 | 901 | # On powerpc 32bits this object is required to link modules |
d815b018 | 902 | if [ "${karch}" = "powerpc" ]; then |
efdab1b7 | 903 | if [ "$(scripts/config -s CONFIG_PPC64)" = "y" ] && vergte "${kversion}" "5.4"; then |
10528202 MJ |
904 | : |
905 | else | |
a86b55bc | 906 | make arch/powerpc/lib/crtsavres.o "${make_args[@]}" |
04873cc3 | 907 | fi |
d815b018 MJ |
908 | fi |
909 | ||
7a76a4d0 | 910 | # On arm64 between 4.13 and 4.15 this object is required to build with ftrace support |
a1ae361e | 911 | if [ "${karch}" = "arm64" ]; then |
c236528e | 912 | if [ -f "arch/arm64/kernel/ftrace-mod.S" ]; then |
a86b55bc | 913 | make arch/arm64/kernel/ftrace-mod.o "${make_args[@]}" |
a1ae361e MJ |
914 | fi |
915 | fi | |
916 | ||
7e02032c | 917 | # Version specific tasks |
a1ae361e | 918 | case "$ktag" in |
7e02032c MJ |
919 | Ubuntu*) |
920 | # Add Ubuntu ABI number to kernel headers, this is normally done by the packaging code | |
a1ae361e | 921 | ABINUM="$(echo "$ktag" | grep -P -o 'Ubuntu-(lts-)?.*-\K\d+(?=\..*)')" |
5a196804 MJ |
922 | echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> include/generated/utsrelease.h |
923 | echo "#define UTS_UBUNTU_RELEASE_ABI $ABINUM" >> "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h" | |
7e02032c | 924 | ;; |
4d8b6258 KS |
925 | rpm-*) |
926 | # Update the definition of UTS_RELEASE to match something akin to '5.14.21-150400.24.108-default' | |
927 | if [ -f "init/Kconfig.suse" ] ; then | |
928 | SLESVERSION="$(echo "${ktag}" | cut -d'-' -f 3)-default" | |
929 | sed -E -i "s%^(#define UTS_RELEASE \"[\.a-z0-9]+)(\")%\1-${SLESVERSION}\2%g" include/generated/utsrelease.h | |
930 | sed -E -i "s%^(#define UTS_RELEASE \"[\.a-z0-9]+)(\")%\1-${SLESVERSION}\2%g" "${LINUX_HDROBJ_DIR}/include/generated/utsrelease.h" | |
931 | fi | |
932 | ;; | |
7e02032c | 933 | esac |
7e02032c MJ |
934 | } |
935 | ||
936 | ||
339db64d MJ |
937 | build_modules() { |
938 | ||
5a196804 MJ |
939 | local kdir="$1" |
940 | local outdir="$2" | |
941 | local kversion | |
942 | ||
943 | kversion=$(make -C "$LINUX_HDROBJ_DIR" -s kernelversion) | |
339db64d | 944 | |
2456f978 MJ |
945 | # Try to catch some compatibility problems by turning some |
946 | # warnings into errors. | |
999a2aa0 | 947 | #export KCFLAGS="$KCFLAGS -Wall -Werror" |
2456f978 | 948 | |
339db64d | 949 | # Enter lttng-modules source dir |
5a196804 | 950 | cd "${MODULES_GIT_DIR}" |
339db64d MJ |
951 | |
952 | # kernels 3.10 to 3.10.13 and 3.11 to 3.11.2 introduce a deadlock in the | |
953 | # timekeeping subsystem. We want those build to fail. | |
5a196804 MJ |
954 | if { vergte "$kversion" "3.10" && verlte "$kversion" "3.10.13"; } || \ |
955 | { vergte "$kversion" "3.11" && verlte "$kversion" "3.11.2"; }; then | |
339db64d MJ |
956 | |
957 | set +e | |
958 | ||
959 | # Build modules | |
a86b55bc | 960 | KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}" |
53300bf0 | 961 | ret=$? |
339db64d | 962 | |
5a196804 MJ |
963 | set -e |
964 | ||
339db64d | 965 | # We expect this build to fail, if it doesn't, fail the job. |
0f71a764 | 966 | if [ "$ret" -eq 0 ]; then |
e9b44189 | 967 | echo "This build should have failed." |
339db64d MJ |
968 | exit 1 |
969 | fi | |
970 | ||
971 | # We have to publish at least one file or the build will fail | |
5a196804 | 972 | echo "This kernel is broken, there is a deadlock in the timekeeping subsystem." > "${outdir}/BROKEN.txt.ko" |
339db64d | 973 | |
5a196804 | 974 | KERNELDIR="${kdir}" make clean |
7e02032c | 975 | |
339db64d MJ |
976 | else # Regular build |
977 | ||
978 | # Build modules against full kernel sources | |
a86b55bc | 979 | KERNELDIR="${kdir}" make -j"${NPROC}" V=1 "${make_args[@]}" |
339db64d MJ |
980 | |
981 | # Install modules to build dir | |
5a196804 | 982 | KERNELDIR="${kdir}" make INSTALL_MOD_PATH="${outdir}" modules_install |
339db64d MJ |
983 | |
984 | # Clean build dir | |
5a196804 | 985 | KERNELDIR="${kdir}" make clean |
339db64d MJ |
986 | fi |
987 | } | |
988 | ||
989 | ||
990 | ## MAIN ## | |
991 | ||
f3d8604b MJ |
992 | # Use all CPU cores |
993 | NPROC=$(nproc) | |
994 | ||
5a196804 MJ |
995 | MODULES_GIT_DIR="${WORKSPACE}/src/lttng-modules" |
996 | LINUX_GIT_DIR="${WORKSPACE}/src/linux" | |
339db64d | 997 | |
5a196804 MJ |
998 | LINUX_OBJ_DIR="${WORKSPACE}/linux" |
999 | LINUX_SRCOBJ_DIR="${LINUX_OBJ_DIR}/sources" | |
1000 | LINUX_HDROBJ_DIR="${LINUX_OBJ_DIR}/headers" | |
1001 | LINUX_INSTOBJ_DIR="${LINUX_OBJ_DIR}/install" | |
339db64d | 1002 | |
5a196804 MJ |
1003 | MODULES_OUTPUT_KSRC_DIR="${WORKSPACE}/build/lttng-modules-ksrc" |
1004 | MODULES_OUTPUT_KHDR_DIR="${WORKSPACE}/build/lttng-modules-khdr" | |
339db64d | 1005 | |
5a196804 MJ |
1006 | LINUX_GIT_REF_REPO_DIR="$HOME/gitcache/linux-stable.git/" |
1007 | ||
1008 | OBJ_STORE_URL="s3://jenkins" | |
1009 | ||
1010 | cd "$WORKSPACE" | |
1011 | ||
1012 | # Create build directories | |
1013 | mkdir -p "${LINUX_SRCOBJ_DIR}" "${LINUX_HDROBJ_DIR}" "${LINUX_INSTOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}" "${MODULES_OUTPUT_KHDR_DIR}" | |
1014 | ||
53300bf0 | 1015 | print_header "Clone LTTng-modules sources" |
5a196804 | 1016 | git_clone_modules_sources |
339db64d | 1017 | |
7e02032c | 1018 | # Setup cross compile env if available |
39961776 | 1019 | if [ "x${cross_arch}" != "x" ]; then |
7e02032c MJ |
1020 | |
1021 | case "$cross_arch" in | |
1022 | "armhf") | |
1023 | karch="arm" | |
1024 | cross_compile="arm-linux-gnueabihf-" | |
53b51a15 | 1025 | vanilla_config="imx_v6_v7_defconfig" |
7e02032c MJ |
1026 | ubuntu_config="armhf-config.flavour.generic" |
1027 | ;; | |
1028 | ||
1029 | "arm64") | |
1030 | karch="arm64" | |
1031 | cross_compile="aarch64-linux-gnu-" | |
53b51a15 | 1032 | vanilla_config="defconfig" |
7e02032c MJ |
1033 | ubuntu_config="arm64-config.flavour.generic" |
1034 | ;; | |
1035 | ||
1036 | "powerpc") | |
1037 | karch="powerpc" | |
1038 | cross_compile="powerpc-linux-gnu-" | |
e9b44189 | 1039 | vanilla_config="ppc44x_defconfig" |
7e02032c MJ |
1040 | ubuntu_config="powerpc-config.flavour.powerpc-smp" |
1041 | ;; | |
1042 | ||
1043 | "ppc64el") | |
1044 | karch="powerpc" | |
1045 | cross_compile="powerpc64le-linux-gnu-" | |
e9b44189 | 1046 | vanilla_config="pseries_le_defconfig" |
7e02032c MJ |
1047 | ubuntu_config="ppc64el-config.flavour.generic" |
1048 | ;; | |
1049 | ||
ae365617 MJ |
1050 | "riscv64") |
1051 | karch="riscv" | |
1052 | cross_compile="riscv64-linux-gnu-" | |
1053 | vanilla_config="defconfig" | |
1054 | ubuntu_config="riscv64-config.flavour.generic" | |
1055 | ;; | |
1056 | ||
7e02032c | 1057 | *) |
51fa2ab3 | 1058 | echo "Unsupported cross arch $cross_arch" |
7e02032c MJ |
1059 | exit 1 |
1060 | ;; | |
1061 | esac | |
339db64d | 1062 | |
7e02032c MJ |
1063 | # Export variables used by Kbuild for cross compilation |
1064 | export ARCH="${karch}" | |
1065 | export CROSS_COMPILE="${cross_compile}" | |
339db64d | 1066 | |
7e02032c | 1067 | # Set arch specific values if we are not cross compiling |
39961776 | 1068 | elif [ "x${arch}" != "x" ]; then |
e9b44189 | 1069 | |
7e02032c | 1070 | case "$arch" in |
16844a6d | 1071 | "i386") |
7e02032c | 1072 | karch="x86" |
1490b049 | 1073 | vanilla_config="allmodconfig" |
7e02032c MJ |
1074 | ubuntu_config="i386-config.flavour.generic" |
1075 | ;; | |
1076 | ||
16844a6d | 1077 | "amd64") |
7e02032c | 1078 | karch="x86" |
1490b049 | 1079 | vanilla_config="allmodconfig" |
7e02032c MJ |
1080 | ubuntu_config="amd64-config.flavour.generic" |
1081 | ;; | |
1082 | ||
1083 | "armhf") | |
1084 | karch="arm" | |
1490b049 | 1085 | vanilla_config="allmodconfig" |
7e02032c MJ |
1086 | ubuntu_config="armhf-config.flavour.generic" |
1087 | ;; | |
1088 | ||
1089 | "arm64") | |
1090 | karch="arm64" | |
1490b049 | 1091 | vanilla_config="allmodconfig" |
7e02032c MJ |
1092 | ubuntu_config="arm64-config.flavour.generic" |
1093 | ;; | |
1094 | ||
1095 | "powerpc") | |
1096 | karch="powerpc" | |
1490b049 | 1097 | vanilla_config="allmodconfig" |
7e02032c MJ |
1098 | ubuntu_config="powerpc-config.flavour.powerpc-smp" |
1099 | ;; | |
1100 | ||
1101 | "ppc64el") | |
1102 | karch="powerpc" | |
1490b049 | 1103 | vanilla_config="allmodconfig" |
7e02032c MJ |
1104 | ubuntu_config="ppc64el-config.flavour.generic" |
1105 | ;; | |
1106 | ||
ae365617 MJ |
1107 | "riscv64") |
1108 | karch="riscv" | |
1109 | vanilla_config="allmodconfig" | |
1110 | ubuntu_config="riscv64-config.flavour.generic" | |
1111 | ;; | |
1112 | ||
7e02032c MJ |
1113 | *) |
1114 | echo "Unsupported arch $arch" | |
1115 | exit 1 | |
1116 | ;; | |
1117 | esac | |
1118 | else | |
04873cc3 | 1119 | echo "No arch or cross_arch specified" |
7e02032c MJ |
1120 | exit 1 |
1121 | fi | |
339db64d | 1122 | |
339db64d | 1123 | |
b214d997 | 1124 | |
5a196804 MJ |
1125 | # First get the kernel build from the object store, or build it, if it's |
1126 | # not available. | |
339db64d | 1127 | |
53300bf0 | 1128 | set +x |
5a196804 MJ |
1129 | echo "# Setup endpoint |
1130 | host_base = obj.internal.efficios.com | |
1131 | host_bucket = obj.internal.efficios.com | |
1132 | bucket_location = us-east-1 | |
1133 | use_https = True | |
7e02032c | 1134 | |
5a196804 MJ |
1135 | # Setup access keys |
1136 | access_key = jenkins | |
1137 | secret_key = echo123456 | |
339db64d | 1138 | |
5a196804 MJ |
1139 | # Enable S3 v4 signature APIs |
1140 | signature_v2 = False" > "$WORKSPACE/.s3cfg" | |
53300bf0 | 1141 | set -x |
339db64d | 1142 | |
c45b04df | 1143 | url_hash="$(echo -n "$kgitrepo" | md5sum | awk '{ print $1 }')" |
5a196804 | 1144 | obj_name="linux.tar.bz2" |
87445931 | 1145 | |
efdab1b7 | 1146 | if [ -z "${cross_arch}" ]; then |
53300bf0 | 1147 | obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platform}/$arch/native" |
87445931 | 1148 | else |
53300bf0 | 1149 | obj_url_prefix="$OBJ_STORE_URL/linux-build/$url_hash/$ktag/platform-${platform}/${cross_arch}" |
87445931 MJ |
1150 | fi |
1151 | ||
5a196804 | 1152 | obj_url="$obj_url_prefix/$obj_name" |
339db64d | 1153 | |
5a196804 | 1154 | set +e |
e18b6e95 KS |
1155 | # In s3cmd 2.3, the return code of get when an object does not exist (64) |
1156 | # is different than in 2.2 (12). The return codes of 's3cmd info' are | |
1157 | # consistent between 2.2 and 2.3. | |
1158 | s3cmd -c "$WORKSPACE/.s3cfg" info "$obj_url" | |
5a196804 MJ |
1159 | ret=$? |
1160 | set -e | |
339db64d | 1161 | |
5a196804 MJ |
1162 | case "$ret" in |
1163 | "0") | |
53300bf0 | 1164 | print_header "Get sources and prebuilt kernel" |
e18b6e95 | 1165 | s3cmd -c "$WORKSPACE/.s3cfg" get "$obj_url" |
5a196804 | 1166 | extract_archive_obj |
53300bf0 MJ |
1167 | |
1168 | print_header "Select compiler and set build flags" | |
1169 | select_compiler | |
1170 | export_kbuild_flags | |
5a196804 | 1171 | ;; |
a1ae361e | 1172 | |
5a196804 | 1173 | "12") |
53300bf0 | 1174 | print_header "Clone kernel sources" |
339db64d | 1175 | |
5a196804 MJ |
1176 | # Build all the things and upload |
1177 | # then finish the module build... | |
339db64d | 1178 | |
5a196804 MJ |
1179 | git_clone_linux_sources |
1180 | git_export_linux_sources | |
339db64d | 1181 | |
53300bf0 | 1182 | print_header "Select compiler and set build flags" |
5a196804 | 1183 | select_compiler |
53300bf0 | 1184 | export_kbuild_flags |
a1ae361e | 1185 | |
5a196804 | 1186 | ## PREPARE FULL LINUX SOURCE TREE |
53300bf0 | 1187 | print_header "Build kernel from source" |
5a196804 | 1188 | build_linux_kernel |
d138fc44 | 1189 | |
5a196804 MJ |
1190 | ## EXTRACT DISTRO STYLE KERNEL HEADERS / DEVEL |
1191 | extract_distro_headers | |
339db64d | 1192 | |
53300bf0 | 1193 | print_header "Upload kernel to object storage" |
5a196804 | 1194 | tar_archive_obj |
5a196804 | 1195 | upload_archive_obj |
339db64d | 1196 | |
5a196804 | 1197 | ;; |
339db64d | 1198 | |
5a196804 MJ |
1199 | *) |
1200 | echo "Unknown error? Abort" | |
1201 | exit 1 | |
1202 | ;; | |
1203 | esac | |
339db64d | 1204 | |
a86b55bc | 1205 | |
7e02032c | 1206 | ## BUILD modules |
5a196804 MJ |
1207 | # Either we downloaded a pre-build kernel or we built it and uploaded |
1208 | # the archive for future builds. | |
1209 | ||
1210 | cd "$WORKSPACE" | |
f3d8604b | 1211 | |
53300bf0 | 1212 | print_header "Build modules against full kernel sources" |
5a196804 | 1213 | build_modules "${LINUX_SRCOBJ_DIR}" "${MODULES_OUTPUT_KSRC_DIR}" |
f3d8604b | 1214 | |
53300bf0 | 1215 | print_header "Build modules against kernel headers" |
5a196804 | 1216 | build_modules "${LINUX_HDROBJ_DIR}" "${MODULES_OUTPUT_KHDR_DIR}" |
f3d8604b | 1217 | |
53300bf0 MJ |
1218 | |
1219 | print_header "Check for built modules in install directory" | |
1220 | ||
5a196804 MJ |
1221 | # Make sure some modules were actually built |
1222 | tree "${MODULES_OUTPUT_KSRC_DIR}" | |
1223 | if [ "x$(find "${MODULES_OUTPUT_KSRC_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then | |
7e02032c MJ |
1224 | echo "No modules built!" |
1225 | exit 1 | |
1226 | fi | |
1227 | ||
5a196804 MJ |
1228 | tree "${MODULES_OUTPUT_KHDR_DIR}" |
1229 | if [ "x$(find "${MODULES_OUTPUT_KHDR_DIR}" -name '*.ko*' -printf yes -quit)" != "xyes" ]; then | |
7e02032c MJ |
1230 | echo "No modules built!" |
1231 | exit 1 | |
1232 | fi | |
b214d997 | 1233 | |
f3d8604b | 1234 | # EOF |