Martin L Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/75031?usp=email )
Change subject: util/xcompile: Add target architecture to CPPFLAGS ......................................................................
util/xcompile: Add target architecture to CPPFLAGS
In order to preprocess linker scripts the target architecture needs to be specified. With clang this needs to be set via a cli argument.
Signed-off-by: Arthur Heymans arthur@aheymans.xyz Change-Id: I4340681e30059d6f18a49a49937668cd3dd39ce1 Reviewed-on: https://review.coreboot.org/c/coreboot/+/75031 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org --- M src/arch/arm/armv7/Makefile.mk M src/arch/arm64/armv8/Makefile.mk M util/xcompile/xcompile 3 files changed, 7 insertions(+), 23 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved
diff --git a/src/arch/arm/armv7/Makefile.mk b/src/arch/arm/armv7/Makefile.mk index 53261ee..56309d7b 100644 --- a/src/arch/arm/armv7/Makefile.mk +++ b/src/arch/arm/armv7/Makefile.mk @@ -10,11 +10,6 @@ armv7_asm_flags += -Wa,-mno-warn-deprecated else # CLANG armv7_flags += -mfpu=none -bootblock-ld-ccopts += -target arm-eabi -verstage-ld-ccopts += -target arm-eabi -romstage-ld-ccopts += -target arm-eabi -ramstage-ld-ccopts += -target arm-eabi -rmodule_arm-ld-ccopts += -target arm-eabi endif armv7-r_asm_flags = $(armv7-r_flags) $(armv7_asm_flags)
diff --git a/src/arch/arm64/armv8/Makefile.mk b/src/arch/arm64/armv8/Makefile.mk index 61961ff..15d80e6 100644 --- a/src/arch/arm64/armv8/Makefile.mk +++ b/src/arch/arm64/armv8/Makefile.mk @@ -13,11 +13,6 @@ ################################################################################ ifeq ($(CONFIG_ARCH_BOOTBLOCK_ARMV8_64),y)
-ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -decompressor-ld-ccopts += -target arm64-elf -bootblock-ld-ccopts += -target arm64-elf -endif - ifneq ($(CONFIG_BOOTBLOCK_CUSTOM),y) decompressor-y += bootblock.S ifneq ($(CONFIG_COMPRESS_BOOTBLOCK),y) @@ -49,10 +44,6 @@ ################################################################################ ifeq ($(CONFIG_ARCH_VERSTAGE_ARMV8_64),y)
-ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -verstage-ld-ccopts += -target arm64-elf -endif - verstage-y += cache.c verstage-y += cpu.S verstage-y += exception.c @@ -66,10 +57,6 @@ ################################################################################ ifeq ($(CONFIG_ARCH_ROMSTAGE_ARMV8_64),y)
-ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -romstage-ld-ccopts += -target arm64-elf -endif - romstage-y += cache.c romstage-y += cpu.S romstage-y += exception.c @@ -86,10 +73,6 @@ ################################################################################ ifeq ($(CONFIG_ARCH_RAMSTAGE_ARMV8_64),y)
-ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y) -ramstage-ld-ccopts += -target arm64-elf -endif - ramstage-y += cache.c ramstage-y += cpu.S ramstage-y += exception.c diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile index 1eecc7e..68b3705 100755 --- a/util/xcompile/xcompile +++ b/util/xcompile/xcompile @@ -262,6 +262,9 @@ CLANG_CFLAGS_${TARCH}+=-fbracket-depth=2048 -mllvm -asm-macro-max-nesting-depth=1000 CLANG_COMPILER_RT_${TARCH}:=${CC_RT_CLANG} CLANG_COMPILER_RT_FLAGS_${TARCH}:=${CC_RT_EXTRA_CLANG} +# Leak the target arch into the preprocessor flags with clang. +# This is needed to preprocess linker scripts +CLANG_CPPFLAGS_${TARCH}:=${CPPFLAGS_CLANG}
# GCC/Clang Common ifeq ($(CONFIG_COMPILER_GCC)$(CONFIG_LP_COMPILER_GCC),y) @@ -272,6 +275,7 @@ else CC_${TARCH}:=$(CLANG_CC_${TARCH}) CFLAGS_${TARCH}:=$(CLANG_CFLAGS_${TARCH}) + CPPFLAGS_${TARCH}:=$(CLANG_CPPFLAGS_${TARCH}) COMPILER_RT_${TARCH}:=$(CLANG_COMPILER_RT_${TARCH}) COMPILER_RT_FLAGS_${TARCH}:=$(CLANG_COMPILER_RT_FLAGS_${TARCH}) endif @@ -471,7 +475,9 @@ # but that's more of a clang limitation. Let's be optimistic # that this will change in the future. CLANG="${clang_prefix}clang" - CFLAGS_CLANG="-target ${clang_arch}-${TABI} $CFLAGS_CLANG" + CLANG_TARGET="-target ${clang_arch}-${TABI}" + CFLAGS_CLANG="$CLANG_TARGET $CFLAGS_CLANG" + CPPFLAGS_CLANG="$CLANG_TARGET $CPPFLAGS_CLANG" fi }