summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Maennich <maennich@google.com>2019-03-20 11:03:51 +0000
committerMatthias Maennich <maennich@google.com>2019-03-21 18:17:03 +0000
commit0646c8d257cd668ecd1480cde1b152aed0177a84 (patch)
treefe586d96931cc311cc45b5d5611444b239df88ce
parent263c177c983a63b256547227a36119c50091d9be (diff)
build.sh: use a gcc with target triplet from PATH if CC=gcc is set
The motivation of this change is to be able to use the gcc version from PATH (e.g. the bundled prebuilt) even in case CC=clang has been set as default by the build.config: -- Build with Clang from $PATH $ ./build/build.sh -- Build with GCC from $PATH $ CC=gcc ./build/build.sh In case of build/build.sh, $PATH is usually setup for a prebuilt cross-compiler toolchain. In order to accomodate any cross compiler settings when falling back to gcc, simply unset CC to let kbuild figure out the correct compiler from PATH. It appears a bit hacky, but only breaks backward compatibility for the case that somebody uses CC=gcc and expects the gcc from PATH to be used. That case is still supported by passing an absolute path. Change-Id: I537192168a27bdda9b288443de88ed45d7c4ec68 Signed-off-by: Matthias Maennich <maennich@google.com>
-rwxr-xr-xbuild.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/build.sh b/build.sh
index c4a5772..2c20ade 100755
--- a/build.sh
+++ b/build.sh
@@ -46,7 +46,10 @@
# for debugging purposes.
#
# CC
-# Override compiler to be used. (e.g. CC=clang)
+# Override compiler to be used. (e.g. CC=clang) Specifying CC=gcc
+# effectively unsets CC to fall back to the default gcc detected by kbuild
+# (including any target triplet). To use a custom 'gcc' from PATH, use an
+# absolute path, e.g. CC=/usr/local/bin/gcc
#
# LD
# Override linker (flags) to be used.
@@ -139,6 +142,11 @@ cd ${ROOT_DIR}
export CLANG_TRIPLE CROSS_COMPILE CROSS_COMPILE_ARM32 ARCH SUBARCH
+# CC=gcc is effectively a fallback to the default gcc including any target
+# triplets. If the user wants to use a custom compiler, they are still able to
+# pass an absolute path, e.g. CC=/usr/bin/gcc.
+[ "${CC}" == "gcc" ] && unset CC
+
if [ -n "${CC}" ]; then
CC_ARG="CC=${CC}"
fi