Message ID | 6119D107D82B0940B389FAED3F2DDE66158823C4@Ansuz.hms.se |
---|---|
State | Superseded |
Headers | show |
Dear Lars Dunemark, On Tue, 16 Apr 2013 07:24:51 +0000, Lars Dunemark wrote: > Recently, we discovered that it has become something strange with our external toolchain builds. > > We discovered this when we wanted to start using Eclipse integration for buildroot and build applications outside buildroot. > > After some investigation we discovered that the ext-toolchain-wrapper had changed and received support for relative paths. > After adding some debug prints: > toolchain/toolchain-external/ext-toolchain-wrapper.c > 122 printf("path: %s, sysroot: %s\n", path, sysroot); > > I got the the following result: > > $ pwd > /media/build/source > $ arm-cortex_a8-linux-gnueabi-gcc > path: /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, sysroot: /media/usr/arm-buildroot-linux-gnueabi/sysroot > arm-cortex_a8-linux-gnueabi-gcc: no input files > > > $ ./buildroot/output/host/usr/bin/arm-cortex_a8-linux-gnueabi-gcc > path: /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, sysroot: /media/build/source/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot > arm-cortex_a8-linux-gnueabi-gcc: no input files What is /media/build/source/toolchain/ ? How did you install things in there ? The toolchain that you must use with Buildroot is the one in output/host/usr/bin/. Using something else will most likely not work properly. Can you give details about your /media/build/source/toolchain/ directory so that we can understand what is your configuration? It doesn't look a standard way of using Buildroot. Thanks, Thomas
Hi Thomas > Dear Lars Dunemark, > > On Tue, 16 Apr 2013 07:24:51 +0000, Lars Dunemark wrote: > > > Recently, we discovered that it has become something strange with our > external toolchain builds. > > > > We discovered this when we wanted to start using Eclipse integration for > buildroot and build applications outside buildroot. > > > > After some investigation we discovered that the ext-toolchain-wrapper had > changed and received support for relative paths. > > After adding some debug prints: > > toolchain/toolchain-external/ext-toolchain-wrapper.c > > 122 printf("path: %s, sysroot: %s\n", path, sysroot); > > > > I got the the following result: > > > > $ pwd > > /media/build/source > > $ arm-cortex_a8-linux-gnueabi-gcc > > path: > > /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, > > sysroot: /media/usr/arm-buildroot-linux-gnueabi/sysroot > > arm-cortex_a8-linux-gnueabi-gcc: no input files > > > > > > $ ./buildroot/output/host/usr/bin/arm-cortex_a8-linux-gnueabi-gcc > > path: > > /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, > > sysroot: > > /media/build/source/buildroot/output/host/usr/arm-buildroot-linux-gnue > > abi/sysroot > > arm-cortex_a8-linux-gnueabi-gcc: no input files > > What is /media/build/source/toolchain/ ? How did you install things in there ? The toolchain I'm using is created with crosstool-ng outside of buildroot. In buildroot menuconfig I have set # BR2_TOOLCHAIN_BUILDROOT is not set BR2_TOOLCHAIN_EXTERNAL=y # BR2_TOOLCHAIN_CTNG is not set BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y # BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD is not set BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y BR2_TOOLCHAIN_EXTERNAL_PATH="/media/build/source/toolchain/" BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="arm-cortex_a8-linux-gnueabi" BR2_TOOLCHAIN_EXTERNAL_PREFIX="arm-cortex_a8-linux-gnueabi" BR2_TOOLCHAIN_EXTERNAL_GLIBC=y # BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC is not set BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y BR2_TOOLCHAIN_EXTERNAL_CXX=y BR2_TOOLCHAIN_EXTRA_EXTERNAL_LIBS="" The intention with this is to have one toolchain build as base so we don't need to rebuild it every time. I attach our config file for ct-ng. > > The toolchain that you must use with Buildroot is the one in > output/host/usr/bin/. Using something else will most likely not work properly. > > Can you give details about your /media/build/source/toolchain/ directory so that > we can understand what is your configuration? It doesn't look a standard way of > using Buildroot. > > Thanks, > > Thomas > -- > Thomas Petazzoni, Free Electrons > Kernel, drivers, real-time and embedded Linux development, consulting, training > and support. > http://free-electrons.com Best regards Lars Dunemark
> > What is /media/build/source/toolchain/ ? How did you install things in there ? > > The toolchain I'm using is created with crosstool-ng outside of buildroot. I have tried this with BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM201203=y BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_PREFIX="arm-none-linux-gnueabi" And get same problem with paths. Eg absolute path works: $ ./output/host/usr/bin/arm-none-linux-gnueabi-gcc arm-none-linux-gnueabi-gcc: fatal error: no input files and using PATH failes: $ pwd /media/build/source/buildroot $ arm-none-linux-gnueabi-gcc /media/build/opt/ext-toolchain/bin/arm-none-linux-gnueabi-gcc: No such file or directory Best regards Lars Dunemark
Dear Lars Dunemark, On 16 April 2013 12:16, Lars Dunemark wrote: > Eg absolute path works: > $ ./output/host/usr/bin/arm-none-linux-gnueabi-gcc > arm-none-linux-gnueabi-gcc: fatal error: no input files > > and using PATH failes: > $ pwd > /media/build/source/buildroot > $ arm-none-linux-gnueabi-gcc > /media/build/opt/ext-toolchain/bin/arm-none-linux-gnueabi-gcc: No such > file or directory It looks like making the external toolchain wrapper relocatable has broken it for use outside of buildroot. If you add the wrapper directory to your path and invoke the wrapper as arm-linux-gcc (for example), execution will enter the 'else' on line 76 of ext-toolchain-wrapper.c. This sets basename to arm-linux-gcc, which is fine, but it also sets absbasedir to whatever $(pwd)/../.. resolves to which then gets used when calculating the sysroot directory, resulting in gcc not having the real sysroot in its search paths. The above all works fine if the wrapper is invoked with an absolute path. (I've not tried with a relative path with slashes in.) I've got a patch with a fix which calculates absbasedir from /proc/self/exe. (I don't know of any other way of reliably getting the path to the current executable.) My C is rusty though, so it might need to be fixed up before it's applied. Also, I don't know if there was there a reason for avoiding the basename and dirname functions from libgen.h. I've not sent a properly git formatted patch before, (and I can't send email from my development machine), so it'll be a day or so before I can put a properly formatted patch together, or you can just pull it from the badly formatted patch in this email: http://article.gmane.org/gmane.comp.lib.uclibc.buildroot/54942 Regards Greg Beresford Disclaimer: This email contains proprietary information some or all of which may be legally privileged and/or is confidential. It is for the intended recipient only. If an addressing or transmission error has misdirected this email, please notify the author by replying to this email. If you are not the intended recipient, you must not use, disclose, distribute, copy or print this email. Any views expressed in this message are those of the individual sender, except where the message states otherwise. ZBD Displays accepts no responsibility for any computer virus which might be transferred by way of this email. We may monitor all email communication through our networks. If you contact us by email, we may store your name and address to facilitate communication. ZBD Displays Ltd is registered in England and Wales, company registration number: 03929602. Registered Office: Malvern Hills Science Park, Geraldine Road, Malvern, Worcestershire, WR14 3SZ, UK
Hi Greg Beresford, Thanks for your replay, I have tested your patch and it solves my problem. Is there anything more that needs to be done with this patch before it can be integrated into master? > It looks like making the external toolchain wrapper relocatable has broken it for > use outside of buildroot. If you add the wrapper directory to your path and > invoke the wrapper as arm-linux-gcc (for example), execution will enter the > 'else' on line 76 of ext-toolchain-wrapper.c. This sets basename to arm-linux- > gcc, which is fine, but it also sets absbasedir to whatever $(pwd)/../.. resolves to > which then gets used when calculating the sysroot directory, resulting in gcc not > having the real sysroot in its search paths. > > The above all works fine if the wrapper is invoked with an absolute path. (I've > not tried with a relative path with slashes in.) > > I've got a patch with a fix which calculates absbasedir from /proc/self/exe. (I > don't know of any other way of reliably getting the path to the current > executable.) My C is rusty though, so it might need to be fixed up before it's > applied. Also, I don't know if there was there a reason for avoiding the > basename and dirname functions from libgen.h. I've not sent a properly git > formatted patch before, (and I can't send email from my development > machine), so it'll be a day or so before I can put a properly formatted patch > together, or you can just pull it from the badly formatted patch in this email: > http://article.gmane.org/gmane.comp.lib.uclibc.buildroot/54942 > Best regards Lars Dunemark
diff --git a/toolchain/toolchain-external/ext-tool.mk b/toolchain/toolchain-external/ext-tool.mk index b477bc0..ba9d933 100644 --- a/toolchain/toolchain-external/ext-tool.mk +++ b/toolchain/toolchain-external/ext-tool.mk @@ -126,7 +126,8 @@ TOOLCHAIN_EXTERNAL_WRAPPER_ARGS = -DBR_SYSROOT='"$(STAGING_SUBDIR)"' ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),) # TOOLCHAIN_EXTERNAL_BIN points outside HOST_DIR => absolute path TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \ - -DBR_CROSS_PATH_ABS='"$(TOOLCHAIN_EXTERNAL_BIN)"' + -DBR_CROSS_PATH_ABS='"$(TOOLCHAIN_EXTERNAL_BIN)"' \ + -DBR_CROSS_HOST_DIR='"$(HOST_DIR)"' else # TOOLCHAIN_EXTERNAL_BIN points inside HOST_DIR => relative path TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += \ diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c index a92bada..d97e3f1 100644 --- a/toolchain/toolchain-external/ext-toolchain-wrapper.c +++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c @@ -72,9 +72,14 @@ int main(int argc, char **argv) } sprintf(relbasedir, "%s/../..", argv[0]); absbasedir = realpath(relbasedir, NULL); + free(relbasedir); } else { basename = progpath; +#ifdef BR_CROSS_HOST_DIR + absbasedir = BR_CROSS_HOST_DIR; +#else absbasedir = realpath("../..", NULL); +#endif } if (absbasedir == NULL) { perror(__FILE__ ": realpath");
Hello Recently, we discovered that it has become something strange with our external toolchain builds. We discovered this when we wanted to start using Eclipse integration for buildroot and build applications outside buildroot. After some investigation we discovered that the ext-toolchain-wrapper had changed and received support for relative paths. After adding some debug prints: toolchain/toolchain-external/ext-toolchain-wrapper.c 122 printf("path: %s, sysroot: %s\n", path, sysroot); I got the the following result: $ pwd /media/build/source $ arm-cortex_a8-linux-gnueabi-gcc path: /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, sysroot: /media/usr/arm-buildroot-linux-gnueabi/sysroot arm-cortex_a8-linux-gnueabi-gcc: no input files $ ./buildroot/output/host/usr/bin/arm-cortex_a8-linux-gnueabi-gcc path: /media/build/source/toolchain/bin/arm-cortex_a8-linux-gnueabi-gcc, sysroot: /media/build/source/buildroot/output/host/usr/arm-buildroot-linux-gnueabi/sysroot arm-cortex_a8-linux-gnueabi-gcc: no input files As you can see we get wrong sysroot if we using gcc directly from out PATH. Our toolchain is located beside buildroot directory: /buildroot /toolchain The only workaround that I have found is to add following patch but I think this will break the purpose with the original patch: Commit: befb9a3ee0c5994162f527d8ef763d57d68ec48e Is there any other better solution to this problem? Best regards Lars Dunemark From 0d6e973ac7c7d84c27d6af0fa26479fd34f364e6 Mon Sep 17 00:00:00 2001 From: Lars Dunemark <ladu@hms.se> Date: Tue, 16 Apr 2013 07:22:19 +0200 Subject: [PATCH] Fix toolchain-wrapper when using toolchain in PATH When adding current toolchain to PATH = BR_ROOT/output/host/usr/bin there is a mismatch in sysroot path. This adds absolute path to sysroot. Change-Id: I2c29fbb6ec3b424447f91c5817dde543970d7a92 --- toolchain/toolchain-external/ext-tool.mk | 3 ++- .../toolchain-external/ext-toolchain-wrapper.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)