[Buildroot] Problem with external toolchain sysroot and eclipse

Lars Dunemark ladu at hms.se
Tue Apr 16 07:24:51 UTC 2013


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:
122         printf("path: %s, sysroot: %s\n", path, sysroot);

I got the the following result:

$ pwd
$ 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:

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 at 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(-)

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
 ifeq ($(filter $(HOST_DIR)/%,$(TOOLCHAIN_EXTERNAL_BIN)),)
 # TOOLCHAIN_EXTERNAL_BIN points outside HOST_DIR => absolute path
 # TOOLCHAIN_EXTERNAL_BIN points inside HOST_DIR => relative path
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;
+		absbasedir = BR_CROSS_HOST_DIR;
 		absbasedir = realpath("../..", NULL);
 	if (absbasedir == NULL) {
 		perror(__FILE__ ": realpath");

More information about the buildroot mailing list