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>
This commit is contained in:
Alan Green 2019-05-22 11:12:44 +10:00 committed by Patrick Georgi
parent 9637856b53
commit 1470c7367b
1 changed files with 28 additions and 27 deletions

View File

@ -227,33 +227,6 @@ 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}
EOF
# Generally the x86 should build for i686 -- no sse/mmx
# instructions since SMM modules are compiled using these
# flags. Note that this doesn't prevent a project using
# xcompile to explicitly specify -mmsse, etc flags.
# The Quark processor doesn't support the instructions
# introduced with the Pentium 6 architecture, so allow it
# to use i586 instead.
if [ "${TARCH}" = "x86_64" ]; then
cat <<EOF
GCC_CFLAGS_${TARCH} += -march=nocona -malign-data=abi
EOF
fi
if [ "${TARCH}" = "x86_32" ]; then
cat <<EOF
ifneq (\$(CONFIG_USE_MARCH_586)\$(CONFIG_LP_USE_MARCH_586),)
GCC_CFLAGS_${TARCH} += -march=i586
else
GCC_CFLAGS_${TARCH} += -march=i686
endif
EOF
fi
cat <<EOF
# Clang
CLANG_CC_${TARCH}:=${CLANG}
@ -265,6 +238,7 @@ CLANG_CFLAGS_${TARCH}+=-Wno-shift-overflow -Wno-address-of-packed-member -Wno-in
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})
@ -276,6 +250,33 @@ else
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
# instructions since SMM modules are compiled using these
# flags. Note that this doesn't prevent a project using
# xcompile to explicitly specify -mmsse, etc flags.
# The Quark processor doesn't support the instructions
# introduced with the Pentium 6 architecture, so allow it
# to use i586 instead.
if [ "${TARCH}" = "x86_64" ]; then
cat <<EOF
CFLAGS_${TARCH} += -march=nocona -malign-data=abi
EOF
fi
if [ "${TARCH}" = "x86_32" ]; then
cat <<EOF
ifneq (\$(CONFIG_USE_MARCH_586)\$(CONFIG_LP_USE_MARCH_586),)
CFLAGS_${TARCH} += -march=i586
else
CFLAGS_${TARCH} += -march=i686
endif
EOF
fi
cat <<EOF
CPP_${TARCH}:=${GCCPREFIX}cpp
AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}