summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Balsini <balsini@google.com>2019-07-24 15:06:20 +0100
committerAlessio Balsini <balsini@google.com>2019-07-24 17:14:17 +0100
commitf9394cfcf59ef8d16ebcdef50e0fe4bc45bbf99c (patch)
tree8932db486aaa1a4926d9deb6979fc7c5cc0b1ee4
parente415a7116f105d94ca8d78619994f35815d9e6c0 (diff)
build.sh: Fix the behavior of specifying CC
Update the behavior of specifying CC. The following cases are covered: - CC == gcc: special case in which we fall back to the default triplet defined by CROSS_COMPILE; - CC == XXX != gcc != "": force the use of the specified XXX compiler; - CC defined both in env and in BUILD_CONFIG: env has higher priority than BUILD_CONFIG. This patch solves this unexpected behavior of having the CC value specified in the environment overwritten by the one defined in BUILD_CONFIG, preserving the behavior of the other cases. Test: manual build Change-Id: I1193d15bb810f4e7989f58381f742f7cab23c6c2 Signed-off-by: Alessio Balsini <balsini@google.com>
-rwxr-xr-xbuild.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/build.sh b/build.sh
index 21a8802..9a7bc76 100755
--- a/build.sh
+++ b/build.sh
@@ -152,6 +152,10 @@ SIGN_SEC=certs/signing_key.pem
SIGN_CERT=certs/signing_key.x509
SIGN_ALGO=sha512
+# Save environment parameters before being overwritten by sourcing
+# BUILD_CONFIG.
+CC_ARG=$CC
+
source "${ROOT_DIR}/build/envsetup.sh"
export MAKE_ARGS=$@
@@ -164,10 +168,14 @@ cd ${ROOT_DIR}
export CLANG_TRIPLE CROSS_COMPILE CROSS_COMPILE_ARM32 ARCH SUBARCH
+# Restore the previously saved CC argument that might have been overridden by
+# the BUILD_CONFIG.
+[ -n $CC_ARG ] && CC=$CC_ARG
+
# 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
+# triplets. An absolute path (e.g., CC=/usr/bin/gcc) must be specified to use a
+# custom compiler.
+[ "$CC" == "gcc" ] && unset CC && unset CC_ARG
if [ -n "${CC}" ]; then
CC_ARG="CC=${CC} HOSTCC=${CC}"