Skip to contentSkip to conversation

external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

PATCH New Matias Garcia 2 participants 5 messages May 6, 2011 – May 18, 2011 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

CodeSourcery uses non-standard arguments to determine which sysroot to use and to set other optimizations (e.g. which floating point ABI to use). This patch allows one to pass an arbitrary argument to the sysroot discovery in ext-tool.mk and adds the same option to the argument list in ext-toolchain-wrapper.c. I have not tested it with an empty option. Use at your own risk as this is my first open-source patch ever... (Am I supposed to write 'signed-off by...'?)

Cheers,
Matias

(quoted diff) +0 -0

b/toolchain/toolchain-external/Config.in
index ca9892b..3b8ed2c 100644

toolchain/toolchain-external/Config.in +2 -0
@@ -125,6 +125,14 @@ config BR2_TOOLCHAIN_EXTERNAL_PATH
      help
        Path to where the external toolchain is installed.
 
+config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_ARGS
+    string "Custom toolchain arguments (e.g. for selecting 

sysroot/optimizations)"
+ default ""
+ help

+      These arguments will be passed to the external toolchain
+      to determine its sysroot, and also passed to the toolchain
+      when calling the wrapper generated in $(HOST_DIR)/usr/bin.

+
config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX
string "Toolchain prefix"
depends on BR2_TOOLCHAIN_EXTERNAL_CUSTOM

(quoted diff) +0 -0

b/toolchain/toolchain-external/ext-tool.mk
index 328f908..019bf30 100644

toolchain/toolchain-external/ext-tool.mk +0 -0
@@ -132,6 +132,10 @@ CC_TARGET_ABI_:=$(call qstrip,$(BR2_GCC_TARGET_ABI))
 
  # march/mtune/floating point mode needs to be passed to the external 

toolchain

  # to select the right multilib variant
+ifneq ($(BR2_TOOLCHAIN_EXTERNAL_CUSTOM_ARGS),)
+TOOLCHAIN_EXTERNAL_CFLAGS += $(BR2_TOOLCHAIN_EXTERNAL_CUSTOM_ARGS)
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += 
-DBR_OPT='$(BR2_TOOLCHAIN_EXTERNAL_CUSTOM_ARGS)'
+endif
  ifneq ($(CC_TARGET_TUNE_),)
  TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
  TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
(quoted diff) +0 -0

b/toolchain/toolchain-external/ext-toolchain-wrapper.c index a485e74..2fc22c4 100644

toolchain/toolchain-external/ext-toolchain-wrapper.c +3 -0
@@ -22,6 +22,9 @@ static char path[PATH_MAX] = BR_CROSS_PATH;
  static char *args[MAXARGS] = {
      path,
      "--sysroot", BR_SYSROOT,
+#ifdef BR_OPT
+    BR_OPT,
+#endif /* BR_OPT */
  #ifdef BR_ARCH
      "-march=" BR_ARCH,
  #endif /* BR_ARCH */
Signature · 4 lines
	*Matias Garcia*
/Embedded Software Developer/
Ross Video | Live Production Technology
www.rossvideo.com <http://www.rossvideo.com>
#1 lore raw

PATCH 1/1 external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

Hello Mathias,

Quoted 7 lines · On Fri, 06 May 2011 17:57:24 -0400 Matias Garcia <[email protected]> wrote:

CodeSourcery uses non-standard arguments to determine which sysroot to use and to set other optimizations (e.g. which floating point ABI to use). This patch allows one to pass an arbitrary argument to the sysroot discovery in ext-tool.mk and adds the same option to the argument list in ext-toolchain-wrapper.c. I have not tested it with an empty option. Use at your own risk as this is my first open-source patch ever... (Am I supposed to write 'signed-off by...'?)

While the goal is correct, I don't like this implementation. The toolchain wrapper should just make use of the flags in BR2_TARGET_OPTIMIZATION configuration option, and not only -march, -mtune, -mabi, etc. options which are currently being used.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#2 lore raw

PATCH 1/1 external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

Hi Thomas,

Quoted 13 lines · Thomas Petazzoni

Hello Mathias,

Quoted 7 lines · On Fri, 06 May 2011 17:57:24 -0400 Matias Garcia <[email protected]> wrote:

CodeSourcery uses non-standard arguments to determine which sysroot to use and to set other optimizations (e.g. which floating point ABI to use). This patch allows one to pass an arbitrary argument to the sysroot discovery in ext-tool.mk and adds the same option to the argument list in ext-toolchain-wrapper.c. I have not tested it with an empty option. Use at your own risk as this is my first open-source patch ever... (Am I supposed to write 'signed-off by...'?)

Quoted 4 lines

While the goal is correct, I don't like this implementation. The toolchain wrapper should just make use of the flags in BR2_TARGET_OPTIMIZATION configuration option, and not only -march, -mtune, -mabi, etc. options which are currently being used.

I thought of that first, but I figured BR2_TARGET_OPTIMIZATION may be used for flags you wouldn't want sent to the linker (for example) in EVERY circumstance. In other words, I thought the wrapper ought to be for sysroot selection primarily. If you disagree, I'd be glad to change it.

Any other comments?

What's the usual procedure for submitting patches? I didn't find one on the website. I also see most people have a file summary at the top.

Cheers,
Matias

Quoted 4 lines

Regards,

Thomas

A message that is not in the archive (sent off-list or not yet received): 1305733040.7239.20.camel@matias-lnx-host

#4 lore raw

PATCH 1/1 external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

Hello Matias,

Please keep the Buildroot list in the loop for Buildroot-related discussions.

Quoted 4 lines · On Wed, 18 May 2011 11:37:20 -0400 Matias Garcia <[email protected]> wrote:

I never received a reply to this e-mail. Do you think it's worth re-submitting my patch? If I did, would it make it into the 2011.05 build? All I'm doing is updating Peter's wrapper with custom optimizations.

I'm still not a big fan of adding a different config option than BR2_TARGET_OPTIMIZATION that would be specific to the external toolchain case. But I haven't dug into the issue enough to propose a solution.

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw

PATCH 1/1 external toolchain: add arbitrary arguments to sysroot discovery and toolchain wrapper

Quoted 4 lines · Thomas Petazzoni

Hello Matias,

Please keep the Buildroot list in the loop for Buildroot-related discussions.

Will do. I sent a reply to the list last time and no-one replied...

Quoted 8 lines
Quoted 4 lines · On Wed, 18 May 2011 11:37:20 -0400 Matias Garcia <[email protected]> wrote:

I never received a reply to this e-mail. Do you think it's worth re-submitting my patch? If I did, would it make it into the 2011.05 build? All I'm doing is updating Peter's wrapper with custom optimizations.

Quoted 4 lines

I'm still not a big fan of adding a different config option than BR2_TARGET_OPTIMIZATION that would be specific to the external toolchain case. But I haven't dug into the issue enough to propose a solution.

Here's the patch simplified to use only BR2_TARGET_OPTIMIZATION. Again, I don't know any fancy ways to post patches, so it's just the git diff. I moved the optimizations to the end of the wrapper so that you can supersede any of the build-in stuff if you want, at your peril.

Quoted 2 lines

Thomas

Matias
--
Patch to add BR2_TARGET_OPTIMIZATION to the external toolchain wrapper.

(quoted diff) +0 -0

b/toolchain/toolchain-external/ext-tool.mk
index 328f908..ad95d21 100644

toolchain/toolchain-external/ext-tool.mk +0 -0
@@ -132,6 +132,10 @@ CC_TARGET_ABI_:=$(call qstrip,

$(BR2_GCC_TARGET_ABI))

 # march/mtune/floating point mode needs to be passed to the external
toolchain
 # to select the right multilib variant
+ifneq ($(BR2_TARGET_OPTIMIZATION),)
+TOOLCHAIN_EXTERNAL_CFLAGS += $(BR2_TARGET_OPTIMIZATION)
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS +=
-DBR_OPT='$(BR2_TARGET_OPTIMIZATION)'
+endif
 ifneq ($(CC_TARGET_TUNE_),)
 TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
(quoted diff) +0 -0

b/toolchain/toolchain-external/ext-toolchain-wrapper.c index a485e74..dfa4fba 100644

toolchain/toolchain-external/ext-toolchain-wrapper.c +3 -0
@@ -37,6 +37,9 @@ static char *args[MAXARGS] = {
 #ifdef BR_VFPFLOAT
 	"-mfpu=vfp",
 #endif /* BR_VFPFLOAT */
+#ifdef BR_OPT
+	BR_OPT,
+#endif /* BR_OPT */
 };
 
 static const char *get_basename(const char *name)b

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20110518/4e177f44/attachment-0001.html>