Skip to contentSkip to conversation

toolchain: add user defined target LDFLAGS options

PATCH New Baruch Siach 3 participants 9 messages Jun 23, 2011 – Jul 26, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Allow the user to specify additional options for the target LDFLAGS.

I use this to pass the -te500v2 option to the linker, when using the CodeSourcery toolchain for PowerPC. This chooses the correct CRT for e500 hard float. Otherwise I get errors like

undefined reference to `_save32gpr_31'
undefined reference to `_rest32gpr_31_x'

at final link time.

---
 package/Makefile.in           |    2 +-
 toolchain/toolchain-common.in |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
package/Makefile.in +1 -1
index 2ca8c31..a6cee06 100644
@@ -81,7 +81,7 @@ ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
 TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
 endif
 
-TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib
+TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib $(BR2_TARGET_LDFLAGS)
 TARGET_CXXFLAGS=$(TARGET_CFLAGS)
 TARGET_SYSROOT_OPT=--sysroot=$(STAGING_DIR)
 
toolchain/toolchain-common.in +5 -0
index f67c30a..8a87493 100644
@@ -173,3 +173,8 @@ config BR2_TARGET_OPTIMIZATION
 	help
 	  Optimizations to use when building for the target host.
 	  NOTE: gcc optimization level is defined in build options.
+
+config BR2_TARGET_LDFLAGS
+	string "Target linker options"
+	help
+	  Options to pass to the linker when buiding for the target host.
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Hi,

Baruch> Allow the user to specify additional options for the target Baruch> LDFLAGS. I use this to pass the -te500v2 option to the linker, Baruch> when using the CodeSourcery toolchain for PowerPC. This chooses Baruch> the correct CRT for e500 hard float. Otherwise I get errors Baruch> like

Committed, thanks.

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

Baruch> ---

 Baruch>  package/Makefile.in           |    2 +-
 Baruch>  toolchain/toolchain-common.in |    5 +++++

Baruch> 2 files changed, 6 insertions(+), 1 deletions(-)

Baruch> diff --git a/package/Makefile.in b/package/Makefile.in Baruch> index 2ca8c31..a6cee06 100644
Baruch> --- a/package/Makefile.in
Baruch> +++ b/package/Makefile.in
Baruch> @@ -81,7 +81,7 @@ ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) Baruch> TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include Baruch> endif

Baruch> -TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib Baruch> +TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib $(BR2_TARGET_LDFLAGS)

You need to use qstrip as otherwise all the flags will be handled as a single argument.

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Hi Peter,

Quoted 11 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Baruch> Allow the user to specify additional options for the target Baruch> LDFLAGS. I use this to pass the -te500v2 option to the linker, Baruch> when using the CodeSourcery toolchain for PowerPC. This chooses Baruch> the correct CRT for e500 hard float. Otherwise I get errors Baruch> like

Committed, thanks.

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

I mistakenly based this patch on version 2010.11.

Actually, since I use an external toolchain, the patch of Matias Garcia
(http://lists.busybox.net/pipermail/buildroot/2011-July/043944.html, not merged yet) solves the -te500v2 problem for me without this patch, so I've dropped it locally.

Quoted 13 lines

Baruch> ---

 Baruch>  package/Makefile.in           |    2 +-
 Baruch>  toolchain/toolchain-common.in |    5 +++++

Baruch> 2 files changed, 6 insertions(+), 1 deletions(-)

Baruch> diff --git a/package/Makefile.in b/package/Makefile.in Baruch> index 2ca8c31..a6cee06 100644
Baruch> --- a/package/Makefile.in
Baruch> +++ b/package/Makefile.in
Baruch> @@ -81,7 +81,7 @@ ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y) Baruch> TARGET_CFLAGS+=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include Baruch> endif

Quoted 5 lines

Baruch> -TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib Baruch> +TARGET_LDFLAGS+=-L$(STAGING_DIR)/lib -L$(STAGING_DIR)/usr/lib $(BR2_TARGET_LDFLAGS)

You need to use qstrip as otherwise all the flags will be handled as a single argument.

Ah, something new learnt. Thanks for noticing and fixing, and thanks again for your great work.

(Back to my cross Poco C++ build attempts)

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#3 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

Baruch> I mistakenly based this patch on version 2010.11.

Baruch> Actually, since I use an external toolchain, the patch of Baruch> Matias Garcia
Baruch> (http://lists.busybox.net/pipermail/buildroot/2011-July/043944.html,
Baruch> not merged yet) solves the -te500v2 problem for me without this Baruch> patch, so I've dropped it locally.

Ok. That patch still needs some work (E.G. it only works with a single argument).

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Hi Peter,

Quoted 7 lines · Peter Korsgaard
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

Baruch> I mistakenly based this patch on version 2010.11.

Quoted 8 lines

Baruch> Actually, since I use an external toolchain, the patch of Baruch> Matias Garcia
Baruch> (http://lists.busybox.net/pipermail/buildroot/2011-July/043944.html,
Baruch> not merged yet) solves the -te500v2 problem for me without this Baruch> patch, so I've dropped it locally.

Ok. That patch still needs some work (E.G. it only works with a single argument).

I see. Any other issue with that patch?

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#5 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Ok. That patch still needs some work (E.G. it only works with a single argument).

Baruch> I see. Any other issue with that patch?

Not really. I think we should cleanup a bit all these options for setting compiler/linker flags, but that's more of a long term goal.

The plan is to put out 2011.08-rc1 at the end of the week, so I would like to keep big changes for the next cycle.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

In reply to Peter Korsgaard
Quoted 7 lines · Peter Korsgaard
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

Baruch> I mistakenly based this patch on version 2010.11.

Quoted 8 lines

Baruch> Actually, since I use an external toolchain, the patch of Baruch> Matias Garcia
Baruch> (http://lists.busybox.net/pipermail/buildroot/2011-July/043944.html,
Baruch> not merged yet) solves the -te500v2 problem for me without this Baruch> patch, so I've dropped it locally.

Ok. That patch still needs some work (E.G. it only works with a single argument).

Ah, that's something I hadn't considered. Thanks for the feedback. I was assuming one could pass something like "-fee -fi -fo -fum" in the text block, and this would be passed on to the wrapper.

I won't have time in the next while to work on it. Can you suggest a way to do it if/when I do? I'm not a make expert by any means.

Cheers,
Matias

#7 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Hi Matias,

Quoted 14 lines · Matias Garcia
Quoted 13 lines · Peter Korsgaard
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

What tree did you create this patch against? package/Makefile.in hasn't looked like that since April, so I had to apply the patch manually.

Baruch> I mistakenly based this patch on version 2010.11.

Baruch> Actually, since I use an external toolchain, the patch of Baruch> Matias Garcia
Baruch> (http://lists.busybox.net/pipermail/buildroot/2011-July/043944.html,
Baruch> not merged yet) solves the -te500v2 problem for me without this Baruch> patch, so I've dropped it locally.

Quoted 6 lines
Quoted 2 lines

Ok. That patch still needs some work (E.G. it only works with a single argument).

Ah, that's something I hadn't considered. Thanks for the feedback. I was assuming one could pass something like "-fee -fi -fo -fum" in the text block, and this would be passed on to the wrapper.

Well, this string will be passed to the wrapper, but the whole string will get stored in the same args[] entry. This means that the compiler sees it as one long argument, not one argument per word as should be.

A possible solution might be to split this string with strtok() at run-time, but it looks inefficient, since we have all the information we need at compile time.

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#8 lore raw

PATCH 1/1 toolchain: add user defined target LDFLAGS options

Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Baruch" == Baruch Siach <[email protected]> writes:

Ah, that's something I hadn't considered. Thanks for the feedback. I was assuming one could pass something like "-fee -fi -fo -fum" in the text block, and this would be passed on to the wrapper.

Baruch> Well, this string will be passed to the wrapper, but the whole Baruch> string will get stored in the same args[] entry. This means Baruch> that the compiler sees it as one long argument, not one Baruch> argument per word as should be.

Baruch> A possible solution might be to split this string with strtok() Baruch> at run-time, but it looks inefficient, since we have all the Baruch> information we need at compile time.

I think it would be simpler to generate an include file containing

"arg1", "arg2", ... "argn"

instead and then simply #include that from ext-toolchain-wrapper.c instead of passing all these options on the compiler cmdline.

This list could be created with something like:

$(patsubst %,\"%\"$(comma),$(CFLAGS))

Signature · 1 line
Bye, Peter Korsgaard