Skip to contentSkip to conversation

standalone-examples: support custom GCC lib

U-Boot In review Jack Mitchell 3 participants 6 messages Jul 16, 2013 – Sep 10, 2013

lore
Share & tools
lore
#0 lore raw

Fighting with compiling u-boot today and dealing with problems related to using a custom built openembedded toolchain, I found the need to specify a custom location for the GCC lib.

This is well supported when building u-boot, but my compile was failing in the standalone examples, as there was no support for a custom GCC lib in the standalone examples Makefile.

I am no toolchain or u-boot expert, and as such to avoid the firey pits of flamewar hell, this is an RFC ;)

Signature · 5 lines
  Jack Mitchell (jack at embed.me.uk)
  Embedded Systems Engineer
  http://www.embed.me.uk

-- 
#1 lore raw

PATCH 1/1 standalone-examples: support custom GCC lib

From: Jack Mitchell <[email protected]>

Add support for defining the gcc lib in standalone examples as is done in the main u-boot Makefile

---
 examples/standalone/Makefile | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
examples/standalone/Makefile +13 -2
index baaa2fb..b1be527 100644
@@ -68,7 +68,18 @@ ELF	:= $(addprefix $(obj),$(ELF))
 BIN	:= $(addprefix $(obj),$(BIN))
 SREC	:= $(addprefix $(obj),$(SREC))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
+# Add GCC lib
+ifdef USE_PRIVATE_LIBGCC
+ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
+PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
+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
 
 CPPFLAGS += -I..
 
@@ -98,7 +109,7 @@ $(ELF):
 $(obj)%:	$(obj)%.o $(LIB)
 		$(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
 			-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
-			-L$(gcclibdir) -lgcc
+			$(PLATFORM_LIBS)
 
 $(SREC):
 $(obj)%.srec:	$(obj)%
Signature · 1 line
1.8.3.2
#2 lore raw
Quoted 6 lines · Jack Mitchell

From: Jack Mitchell <[email protected]>

Add support for defining the gcc lib in standalone examples as is done in the main u-boot Makefile

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130906/5221462a/attachment.pgp>
#3 lore raw
In reply to Jack Mitchell
Quoted 22 lines · Jack Mitchell

From: Jack Mitchell <[email protected]>

Add support for defining the gcc lib in standalone examples as is done in the main u-boot Makefile

---
examples/standalone/Makefile | 15 +++++++++++++--

 1 file changed, 13 insertions(+), 2 deletions(-)
examples/standalone/Makefile +2 -1
index baaa2fb..b1be527 100644
@@ -68,7 +68,18 @@ ELF	:= $(addprefix $(obj),$(ELF))
 BIN	:= $(addprefix $(obj),$(BIN))
 SREC	:= $(addprefix $(obj),$(SREC))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
+# Add GCC lib
+ifdef USE_PRIVATE_LIBGCC

examples/standalone/Makefile ELF := $(addprefix $(obj),$(ELF)) · line 82

Quoted 10 lines
examples/standalone/Makefile +10 -0
+ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
+PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o
+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

We already inherit this logic from the top level Makefile, so this leads to duplicating $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o in PLATFORM_LIBS. Second, currently for ARM, libgcc.o ends up requring 'hang' to be provided.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130910/220241f1/attachment.pgp>
#4 lore raw
In reply to Jack Mitchell

Hi Jack,

Quoted 10 lines · Jack Mitchell

Fighting with compiling u-boot today and dealing with problems related to using a custom built openembedded toolchain, I found the need to specify a custom location for the GCC lib.

This is well supported when building u-boot, but my compile was failing in the standalone examples, as there was no support for a custom GCC lib in the standalone examples Makefile.

I am no toolchain or u-boot expert, and as such to avoid the firey pits of flamewar hell, this is an RFC ;)

... which wasn't tagged '[RFC]', apparently. :)

Amicalement,

Signature · 1 line
Albert.
#5 lore raw
Quoted 13 lines · Albert ARIBAUD

Hi Jack,

Quoted 8 lines · Jack Mitchell

Fighting with compiling u-boot today and dealing with problems related to using a custom built openembedded toolchain, I found the need to specify a custom location for the GCC lib.

This is well supported when building u-boot, but my compile was failing in the standalone examples, as there was no support for a custom GCC lib in the standalone examples Makefile.

Quoted 7 lines
Quoted 2 lines

I am no toolchain or u-boot expert, and as such to avoid the firey pits of flamewar hell, this is an RFC ;)

... which wasn't tagged '[RFC]', apparently. :)

Amicalement,

The great plans of mice and men, huh? I intended for the RFC tag to go on, but in all my excitement it was forgotten.

Signature · 5 lines
   Jack Mitchell (jack at embed.me.uk)
   Embedded Systems Engineer
   http://www.embed.me.uk

--