From f772acf8a584067033eff1e231fcd1fb3a00d3d9 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Mon, 17 Aug 2009 13:17:29 +0200 Subject: ARM: compiler options cleanup - improve tool chain support For some time there have been repeated reports about build problems with some ARM (cross) tool chains. Especially issues about (in)compatibility with the tool chain provided runtime support library libgcc.a caused to add and support a private implementation of such runtime support code in U-Boot. A closer look at the code indicated that some of these issues are actually home-made. This patch attempts to clean up some of the most obvious problems and make building of U-Boot with different tool chains easier: - Even though all ARM systems basicy used the same compiler options to select a specific ABI from the tool chain, the code for this was distributed over all cpu/*/config.mk files. We move this one level up into lib_arm/config.mk instead. - So far, we only checked if "-mapcs-32" was supported by the tool chain; if yes, this was used, if not, "-mabi=apcs-gnu" was selected, no matter if the tool chain actually understood this option. There was no support for EABI conformant tool chains. This patch implements the following logic: 1) If the tool chain supports "-mabi=aapcs-linux -mno-thumb-interwork" we use these options (EABI conformant tool chain). 2) Otherwise, we check first if "-mapcs-32" is supported, and then check for "-mabi=apcs-gnu" If one test succeeds, we use the first found option. 3) In case 2), we also test if "-mno-thumb-interwork", and use this if the test succeeds. [For "-mabi=aapcs-linux" we set "-mno-thumb-interwork" mandatorily.] This way we use a similar logic for the compile options as the Linux kernel does. - Some EABI conformant tool chains cause external references to utility functions like raise(); such functions are provided in the new file lib_arm/eabi_compat.c Note that lib_arm/config.mk gets parsed several times, so we must make sure to add eabi_compat.o only once to the linker list. Signed-off-by: Wolfgang Denk Cc: Jean-Christophe PLAGNIOL-VILLARD Cc: Dirk Behme Cc: Magnus Lilja Cc: Tom Rix Cc: Prafulla Wadaskar Acked-by: Sergey Kubushyn Tested-by: Magnus Lilja Tested-by: Andrzej Wolski Tested-by: Gaye Abdoulaye Walsimou Tested-by: Tom Rix Tested-by: Jean-Christophe PLAGNIOL-VILLARD --- lib_arm/config.mk | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib_arm/config.mk') diff --git a/lib_arm/config.mk b/lib_arm/config.mk index a13603e409..705dfc306c 100644 --- a/lib_arm/config.mk +++ b/lib_arm/config.mk @@ -25,4 +25,32 @@ CROSS_COMPILE ?= arm-linux- PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__ +# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb: +PLATFORM_CPPFLAGS += $(call cc-option,-marm,) + +# Try if EABI is supported, else fall back to old API, +# i. e. for example: +# - with ELDK 4.2 (EABI supported), use: +# -mabi=aapcs-linux -mno-thumb-interwork +# - with ELDK 4.1 (gcc 4.x, no EABI), use: +# -mabi=apcs-gnu -mno-thumb-interwork +# - with ELDK 3.1 (gcc 3.x), use: +# -mapcs-32 -mno-thumb-interwork +PLATFORM_CPPFLAGS += $(call cc-option,\ + -mabi=aapcs-linux -mno-thumb-interwork,\ + $(call cc-option,\ + -mapcs-32,\ + $(call cc-option,\ + -mabi=apcs-gnu,\ + )\ + ) $(call cc-option,-mno-thumb-interwork,)\ + ) + +# For EABI, make sure to provide raise() +ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) +# This file is parsed several times; make sure to add only once. +ifeq (,$(findstring lib_arm/eabi_compat.o,$(PLATFORM_LIBS))) +PLATFORM_LIBS += $(OBJTREE)/lib_arm/eabi_compat.o +endif +endif LDSCRIPT := $(SRCTREE)/cpu/$(CPU)/u-boot.lds -- cgit