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