[U-Boot] [PATCH v2] Make linking against libgcc configurable
Wolfgang Denk
wd at denx.de
Thu Jul 23 13:15:59 CEST 2009
Many (especially ARM) tool chains seem to come with broken or
otherwise unusable (for the purposes of builing U-Boot) run-time
support libraries `libgcc.a'. By using the "USE_PRIVATE_LIBGCC"
setting we allow to use alternative libraries instead.
"USE_PRIVATE_LIBGCC" can either be set as an environment variable in
the shell, or as a command line argument when running "make", i. e.
$ make USE_PRIVATE_LIBGCC=yes
or
$ USE_PRIVATE_LIBGCC=yes
$ export USE_PRIVATE_LIBGCC
$ make
The value of "USE_PRIVATE_LIBGCC" is the name of the directory which
contains the alternative run-time support library `libgcc.a'. The
special value "yes" selects the directory $(OBJTREE)/lib_$(ARCH) .
Note that not all architectures provide an alternative `libgcc.a' in
their lib_$(ARCH) directories - so far, only ARM does.
Signed-off-by: Wolfgang Denk <wd at denx.de>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
Cc: Prafulla Wadaskar <prafulla at marvell.com>
cc: Stefan Roese <sr at denx.de>
---
v2: Removed crap left over from testing.
Makefile | 12 +++++++++++-
board/trab/Makefile | 4 +---
lib_arm/Makefile | 30 ++++++++++++++++++++++--------
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 25a6254..7c99ac2 100644
--- a/Makefile
+++ b/Makefile
@@ -247,7 +247,17 @@ LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).a
LIBBOARD := $(addprefix $(obj),$(LIBBOARD))
# Add GCC lib
-PLATFORM_LIBS += -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
+ifdef USE_PRIVATE_LIBGCC
+ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
+PLATFORM_LIBGCC = -L $(OBJTREE)/lib_$(ARCH) -lgcc
+else
+PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
+endif
+else
+PLATFORM_LIBGCC = -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
+endif
+PLATFORM_LIBS += $(PLATFORM_LIBGCC)
+export PLATFORM_LIBS
ifeq ($(CONFIG_NAND_U_BOOT),y)
NAND_SPL = nand_spl
diff --git a/board/trab/Makefile b/board/trab/Makefile
index 3a92c0d..2afad88 100644
--- a/board/trab/Makefile
+++ b/board/trab/Makefile
@@ -36,8 +36,6 @@ SOBJS := $(addprefix $(obj),$(SOBJS))
OBJS_FKT := $(addprefix $(obj),$(COBJS_FKT))
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
-
LOAD_ADDR = 0xc100000
#########################################################################
@@ -52,7 +50,7 @@ $(obj)trab_fkt.srec: $(OBJS_FKT) $(LIB)
-L$(obj)../../examples/standalone -lstubs \
-L$(obj)../../lib_generic -lgeneric \
$(obj)../../lib_arm/div0.o \
- $(obj)../../lib_arm/_*.o
+ $(PLATFORM_LIBS)
$(OBJCOPY) -O srec $(<:.o=) $@
$(obj)trab_fkt.bin: $(obj)trab_fkt.srec
diff --git a/lib_arm/Makefile b/lib_arm/Makefile
index 4469361..241782c 100644
--- a/lib_arm/Makefile
+++ b/lib_arm/Makefile
@@ -24,13 +24,16 @@
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(ARCH).a
+LIBGCC = $(obj)libgcc.a
-SOBJS-y += _ashldi3.o
-SOBJS-y += _ashrdi3.o
-SOBJS-y += _divsi3.o
-SOBJS-y += _modsi3.o
-SOBJS-y += _udivsi3.o
-SOBJS-y += _umodsi3.o
+GLSOBJS += _ashldi3.o
+GLSOBJS += _ashrdi3.o
+GLSOBJS += _divsi3.o
+GLSOBJS += _modsi3.o
+GLSOBJS += _udivsi3.o
+GLSOBJS += _umodsi3.o
+
+GLCOBJS += div0.o
COBJS-y += board.o
COBJS-y += bootm.o
@@ -38,16 +41,27 @@ COBJS-y += cache.o
ifndef CONFIG_SYS_NO_CP15_CACHE
COBJS-y += cache-cp15.o
endif
-COBJS-y += div0.o
COBJS-y += interrupts.o
COBJS-y += reset.o
-SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \
+ $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+LGOBJS := $(addprefix $(obj),$(GLSOBJS)) \
+ $(addprefix $(obj),$(GLCOBJS))
+
+ifdef USE_PRIVATE_LIBGCC
+all: $(LIB) $(LIBGCC)
+else
+all: $(LIB)
+endif
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
+$(LIBGCC): $(obj).depend $(LGOBJS)
+ $(AR) $(ARFLAGS) $@ $(LGOBJS)
+
#########################################################################
# defines $(obj).depend target
--
1.6.0.6
More information about the U-Boot
mailing list