Mailing List Archive

[xen master] CI: Fix build script when CROSS_COMPILE is in use
commit df57a2c8da7acb14f3feac823f2fcbeef56899b2
Author: Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Dec 29 21:46:50 2022 +0000
Commit: Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Jan 4 13:22:59 2023 +0000

CI: Fix build script when CROSS_COMPILE is in use

Some testcases use a cross compiler. Presently it's only arm32 and due to
previous cleanup the only thing which is now wrong is printing the compiler
version at the start of day.

Construct $cc to match what `make` will eventually choose given CROSS_COMPILE,
taking care not to modify $CC. Use $cc throughout the rest of the script.

Also correct the compiler detection logic. Plain "gcc" was wrong, and
"clang"* was a bodge highlighting the issue, but neither survive the
CROSS_COMPILE correction. Instead, construct cc_is_{gcc,clang} booleans like
we do elsewhere in the build system, by querying the --version text for gcc or
clang.

While making this change, adjust cc_ver to be calculated once at the same time
as cc_is_* are calculated.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
automation/scripts/build | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/automation/scripts/build b/automation/scripts/build
index 4c6d1f3b70..206312ecc7 100755
--- a/automation/scripts/build
+++ b/automation/scripts/build
@@ -2,13 +2,12 @@

test -f /etc/os-release && cat "$_"

-$CC --version
+# Construct $cc such that it matches what `make` will chose when taking
+# CROSS_COMPILE into account. Do not modify $CC directly, as that will cause
+# `make` to double-account CROSS_COMPILE.
+cc="${CROSS_COMPILE}${CC}"

-# Express the compiler version as an integer. e.g. GCC 4.9.2 => 0x040902
-cc-ver()
-{
- $CC -dumpversion | awk -F. '{ printf "0x%02x%02x%02x", $1, $2, $3 }'
-}
+$cc --version

# random config or default config
if [[ "${RANDCONFIG}" == "y" ]]; then
@@ -50,7 +49,14 @@ else
cfgargs=()
cfgargs+=("--enable-docs")

- if [[ "${CC}" == "clang"* ]]; then
+ # booleans for which compiler is in use
+ cc_is_gcc="$($cc --version | grep -q gcc && echo "y" || :)"
+ cc_is_clang="$($cc --version | grep -q clang && echo "y" || :)"
+
+ # The compiler version as an integer. e.g. GCC 4.9.2 => 0x040902
+ cc_ver="$($cc -dumpversion | awk -F. '{ printf "0x%02x%02x%02x", $1, $2, $3 }')"
+
+ if [[ "${cc_is_clang}" == "y" ]]; then
# SeaBIOS cannot be built with clang
cfgargs+=("--with-system-seabios=/usr/share/seabios/bios.bin")
# iPXE cannot be built with clang
@@ -73,7 +79,7 @@ else
fi

# SeaBIOS requires GCC 4.6 or later
- if [[ "${CC}" == "gcc" && `cc-ver` -lt 0x040600 ]]; then
+ if [[ "${cc_is_gcc}" == "y" && "${cc_ver}" -lt 0x040600 ]]; then
cfgargs+=("--with-system-seabios=/bin/false")
fi

--
generated by git-patchbot for /home/xen/git/xen.git#master