summaryrefslogtreecommitdiff
path: root/util/xcompile
diff options
context:
space:
mode:
authorAlan Green <avg@google.com>2019-05-22 11:12:44 +1000
committerPatrick Georgi <pgeorgi@google.com>2019-05-28 20:33:37 +0000
commit1470c7367b8fca24c86c8912aa65e969e63ff521 (patch)
tree8f60d62a4464bec1552b7efe721bd8a58b496c8f /util/xcompile
parent9637856b533ee6eaa7cd3e1c1b2ec4d816f58dff (diff)
util/xcompile/xcompile: apply -march to clang as well as gcc
For x64 and x86_32 configurations, apply the -march flag to both GCC and Clang flags. This solves the problem of Clang-compiled coreboot failing due to Clang emitting SSE instructions for code that is executed while SSE is not enabled. This patch takes functionality targeted for GCC configurations and moves it down a few lines, modifying CFLAGS instead of GCC_CFLAGS in order that it applies to both GCC and Clang. This is an alternate patch to CB:32887. Signed-off-by: Alan Green <avg@google.com> Change-Id: I6a6a6136b01a64d46f730ed19ebbeaadaf2183df Reviewed-on: https://review.coreboot.org/c/coreboot/+/32923 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'util/xcompile')
-rwxr-xr-xutil/xcompile/xcompile51
1 files changed, 26 insertions, 25 deletions
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index 4a29cdd647..40356d93d9 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -227,6 +227,29 @@ GCC_CC_${TARCH}:=${GCC}
GCC_CFLAGS_${TARCH}:=${CFLAGS_GCC}
GCC_COMPILER_RT_${TARCH}:=${CC_RT_GCC}
GCC_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_GCC}
+
+# Clang
+CLANG_CC_${TARCH}:=${CLANG}
+CLANG_CFLAGS_${TARCH}:=${CFLAGS_CLANG}
+CLANG_CFLAGS_${TARCH}+=-Qunused-arguments -m${TWIDTH}
+# tone down clang compiler warnings
+CLANG_CFLAGS_${TARCH}+=-Wno-unused-variable -Wno-unused-function -Wno-tautological-compare
+CLANG_CFLAGS_${TARCH}+=-Wno-shift-overflow -Wno-address-of-packed-member -Wno-initializer-overrides
+CLANG_COMPILER_RT_${TARCH}:=${CC_RT_CLANG}
+CLANG_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_CLANG}
+
+# GCC/Clang Common
+ifeq (\$(CONFIG_COMPILER_GCC)\$(CONFIG_LP_COMPILER_GCC),y)
+ CC_${TARCH}:=\$(GCC_CC_${TARCH})
+ CFLAGS_${TARCH}:=\$(GCC_CFLAGS_${TARCH})
+ COMPILER_RT_${TARCH}:=\$(GCC_COMPILER_RT_${TARCH})
+ COMPILER_RT_FLAGS_${TARCH}:=\$(GCC_COMPILER_RT_FLAGS_${TARCH})
+else
+ CC_${TARCH}:=\$(CLANG_CC_${TARCH})
+ CFLAGS_${TARCH}:=\$(CLANG_CFLAGS_${TARCH})
+ COMPILER_RT_${TARCH}:=\$(CLANG_COMPILER_RT_${TARCH})
+ COMPILER_RT_FLAGS_${TARCH}:=\$(CLANG_COMPILER_RT_FLAGS_${TARCH})
+endif
EOF
# Generally the x86 should build for i686 -- no sse/mmx
@@ -238,7 +261,7 @@ EOF
# to use i586 instead.
if [ "${TARCH}" = "x86_64" ]; then
cat <<EOF
- GCC_CFLAGS_${TARCH} += -march=nocona -malign-data=abi
+ CFLAGS_${TARCH} += -march=nocona -malign-data=abi
EOF
fi
@@ -246,37 +269,15 @@ if [ "${TARCH}" = "x86_32" ]; then
cat <<EOF
ifneq (\$(CONFIG_USE_MARCH_586)\$(CONFIG_LP_USE_MARCH_586),)
- GCC_CFLAGS_${TARCH} += -march=i586
+ CFLAGS_${TARCH} += -march=i586
else
- GCC_CFLAGS_${TARCH} += -march=i686
+ CFLAGS_${TARCH} += -march=i686
endif
EOF
fi
cat <<EOF
-# Clang
-CLANG_CC_${TARCH}:=${CLANG}
-CLANG_CFLAGS_${TARCH}:=${CFLAGS_CLANG}
-CLANG_CFLAGS_${TARCH}+=-Qunused-arguments -m${TWIDTH}
-# tone down clang compiler warnings
-CLANG_CFLAGS_${TARCH}+=-Wno-unused-variable -Wno-unused-function -Wno-tautological-compare
-CLANG_CFLAGS_${TARCH}+=-Wno-shift-overflow -Wno-address-of-packed-member -Wno-initializer-overrides
-CLANG_COMPILER_RT_${TARCH}:=${CC_RT_CLANG}
-CLANG_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_CLANG}
-
-ifeq (\$(CONFIG_COMPILER_GCC)\$(CONFIG_LP_COMPILER_GCC),y)
- CC_${TARCH}:=\$(GCC_CC_${TARCH})
- CFLAGS_${TARCH}:=\$(GCC_CFLAGS_${TARCH})
- COMPILER_RT_${TARCH}:=\$(GCC_COMPILER_RT_${TARCH})
- COMPILER_RT_FLAGS_${TARCH}:=\$(GCC_COMPILER_RT_FLAGS_${TARCH})
-else
- CC_${TARCH}:=\$(CLANG_CC_${TARCH})
- CFLAGS_${TARCH}:=\$(CLANG_CFLAGS_${TARCH})
- COMPILER_RT_${TARCH}:=\$(CLANG_COMPILER_RT_${TARCH})
- COMPILER_RT_FLAGS_${TARCH}:=\$(CLANG_COMPILER_RT_FLAGS_${TARCH})
-endif
-
CPP_${TARCH}:=${GCCPREFIX}cpp
AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}
LD_${TARCH}:=${GCCPREFIX}ld${LINKER_SUFFIX} ${LDFLAGS}