From 1470c7367b8fca24c86c8912aa65e969e63ff521 Mon Sep 17 00:00:00 2001 From: Alan Green Date: Wed, 22 May 2019 11:12:44 +1000 Subject: util/xcompile/xcompile: apply -march to clang as well as gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: I6a6a6136b01a64d46f730ed19ebbeaadaf2183df Reviewed-on: https://review.coreboot.org/c/coreboot/+/32923 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Patrick Georgi Reviewed-by: Kyösti Mälkki --- util/xcompile/xcompile | 51 +++++++++++++++++++++++++------------------------- 1 file 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 <