]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ARM: compiler options cleanup - improve tool chain support
authorWolfgang Denk <wd@denx.de>
Mon, 17 Aug 2009 11:17:29 +0000 (13:17 +0200)
committerWolfgang Denk <wd@denx.de>
Fri, 21 Aug 2009 21:11:53 +0000 (23:11 +0200)
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 <wd@denx.de>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Dirk Behme <dirk.behme@googlemail.com>
Cc: Magnus Lilja <lilja.magnus@gmail.com>
Cc: Tom Rix <Tom.Rix@windriver.com>
Cc: Prafulla Wadaskar <prafulla@marvell.com>
Acked-by: Sergey Kubushyn <ksi@koi8.net>
Tested-by: Magnus Lilja <lilja.magnus@gmail.com>
Tested-by: Andrzej Wolski <awolski@poczta.fm>
Tested-by: Gaye Abdoulaye Walsimou <walsimou@walsimou.com>
Tested-by: Tom Rix <Tom.Rix@windriver.com>
Tested-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
21 files changed:
config.mk
cpu/arm1136/config.mk
cpu/arm1176/config.mk
cpu/arm1176/s3c64xx/config.mk
cpu/arm720t/config.mk
cpu/arm920t/config.mk
cpu/arm925t/config.mk
cpu/arm926ejs/config.mk
cpu/arm926ejs/davinci/config.mk
cpu/arm946es/config.mk
cpu/arm_cortexa8/config.mk
cpu/arm_cortexa8/omap3/board.c
cpu/arm_intcm/config.mk
cpu/ixp/config.mk
cpu/lh7a40x/config.mk
cpu/pxa/config.mk
cpu/s3c44b0/config.mk
cpu/sa1100/config.mk
lib_arm/Makefile
lib_arm/config.mk
lib_arm/eabi_compat.c [new file with mode: 0644]

index fd56621fefe1602a21562291276152c47f8246c2..0c6d1d1aa76cdd15afd2658537b7e790e33f3594 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -86,7 +86,7 @@ ifdef ARCH
 sinclude $(TOPDIR)/lib_$(ARCH)/config.mk       # include architecture dependend rules
 endif
 ifdef  CPU
-sinclude $(TOPDIR)/cpu/$(CPU)/config.mk        # include  CPU  specific rules
+sinclude $(TOPDIR)/cpu/$(CPU)/config.mk                # include  CPU  specific rules
 endif
 ifdef  SOC
 sinclude $(TOPDIR)/cpu/$(CPU)/$(SOC)/config.mk # include  SoC  specific rules
index 295e8a5b87afaf029084ced6e850f63bb178e66d..61d5a382ed82816456c1c90f61abde19219cd969 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv5
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index d2f057bf74fd18ea4aa8c22e229356c5ad6cebce..a31c7b0f8979d1d0bffa292c3a38a7bbcf73a4e7 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv5t
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 4f3b66c5d743205f5f962eb136f00dcc49ae82c5..a31c7b0f8979d1d0bffa292c3a38a7bbcf73a4e7 100644 (file)
@@ -30,5 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv5t
 # Supply options according to compiler version
 #
 # =========================================================================
-#PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 3cae1dc8f7326d50f0ccbefda7ddb4009659100c..74d52831edef9961fd8e3f7b3aeaf1d5b112f37f 100644 (file)
@@ -31,6 +31,4 @@ PLATFORM_CPPFLAGS += -march=armv4 -mtune=arm7tdmi
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 5d8a10ff6281282af6c659d685502cff40e9e275..a43b15671106fb113cb03c3e3ce6cbac5be6397f 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv4
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 5d8a10ff6281282af6c659d685502cff40e9e275..a43b15671106fb113cb03c3e3ce6cbac5be6397f 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv4
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 885d5c134e904f8acd53a3832c7628620014b437..90eb3c0edec62332e0553e0aa04da6e13d6f2341 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv5te
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index a57d03aa01de733f2f3ad6e1da577d111e56981c..7757be398ae59546553d023dda9e0ebb0d6774a6 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv5te
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 9d62ba8e3f486507e9f3b3e3ace002d5f60fffc9..a81321bd3ccff634c8671f04f7fd51040d0fbc5c 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS +=  -march=armv4
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 3bfe3db20c9dce7dd6c15730896a567da513167c..da5ee162c5f2971cbf1a91a7b4780e16bf74654d 100644 (file)
@@ -30,6 +30,5 @@ PLATFORM_CPPFLAGS += -march=armv5
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
                    $(call cc-option,-malignment-traps,))
index 233728762f9f00c862f4b385d694e1ff43337ffc..b8bd0524af9b527b689437293a0ea38fc7ae468f 100644 (file)
@@ -297,13 +297,6 @@ int dram_init(void)
        return 0;
 }
 
-/******************************************************************************
- * Dummy function to handle errors for EABI incompatibility
- *****************************************************************************/
-void raise(void)
-{
-}
-
 /******************************************************************************
  * Dummy function to handle errors for EABI incompatibility
  *****************************************************************************/
index 9d62ba8e3f486507e9f3b3e3ace002d5f60fffc9..a81321bd3ccff634c8671f04f7fd51040d0fbc5c 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS +=  -march=armv4
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index a71a20b822d61051f2de7f47c952b3fa459d23be..2c33b40a2cb20db2a3f8cf3b56e33c3e281e7439 100644 (file)
@@ -33,5 +33,4 @@ PLATFORM_CPPFLAGS += -mbig-endian -march=armv5te -mtune=strongarm1100
 # Supply options according to compiler version
 #
 # =========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index c0e7a1d0448ed9fbd917bc9b6cc22535be8c3779..27bc48126065b74abf4df3416b61c2c5106702a0 100644 (file)
@@ -30,6 +30,4 @@ PLATFORM_CPPFLAGS += -march=armv4
 # Supply options according to compiler version
 #
 # ========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index af910e2f67069b5df76aa8ccde304decf9e42189..f360478d0c287546366ebffa4d01d27927f00333 100644 (file)
@@ -31,6 +31,4 @@ PLATFORM_CPPFLAGS += -march=armv5te -mtune=xscale
 # Supply options according to compiler version
 #
 # ========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 01e7040d61d4830a16638eb5a9acfc3fe092d142..3623f2503e229c0451eaae14ac72e9db6f854452 100644 (file)
@@ -31,6 +31,4 @@ PLATFORM_CPPFLAGS += -march=armv4 -mtune=arm7tdmi -msoft-float
 # Supply options according to compiler version
 #
 # ========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index 9ef4a19d339d449c0038cbdd9e1aa75165f323bd..553cd0c9cfcbf51bcc20b0655d14cabdc20f960c 100644 (file)
@@ -31,6 +31,4 @@ PLATFORM_CPPFLAGS += -march=armv4 -mtune=strongarm1100
 # Supply options according to compiler version
 #
 # ========================================================================
-PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
-PLATFORM_CPPFLAGS +=$(call cc-option,-mno-thumb-interwork,)
 PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,))
index c37e2e0d8a989802dfef2b9b7b0efb43f07d1b4f..02933485cd16600f4f9dbae073a85184a40a7d8d 100644 (file)
@@ -51,12 +51,21 @@ OBJS        := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
 LGOBJS := $(addprefix $(obj),$(GLSOBJS)) \
           $(addprefix $(obj),$(GLCOBJS))
 
+# Always build libarm.a
+TARGETS        := $(LIB)
+
+# Build private libgcc only when asked for
 ifdef USE_PRIVATE_LIBGCC
-all:   $(LIB) $(LIBGCC)
-else
-all:   $(LIB)
+TARGETS        += $(LIBGCC)
+endif
+
+# For EABI conformant tool chains, provide eabi_compat()
+ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
+TARGETS        += $(obj)eabi_compat.o
 endif
 
+all:   $(TARGETS)
+
 $(LIB):        $(obj).depend $(OBJS)
        $(AR) $(ARFLAGS) $@ $(OBJS)
 
index a13603e40917b32db8b9703814bbd01f1e8d3c92..705dfc306c4d578d0142f70fc610dc8ddb15858b 100644 (file)
@@ -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
diff --git a/lib_arm/eabi_compat.c b/lib_arm/eabi_compat.c
new file mode 100644 (file)
index 0000000..86eacf1
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Utility functions needed for (some) EABI conformant tool chains.
+ *
+ * (C) Copyright 2009 Wolfgang Denk <wd@denx.de>
+ *
+ * This program is Free Software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ */
+
+#include <common.h>
+
+int raise (int signum)
+{
+       printf("raise: Signal # %d caught\n", signum);
+       return 0;
+}