2

For running testcases etc. I would like to compile parts of our buildroot environment for the Host system (/usr/bin/gcc etc.).

I tried specifying an external_toolchain in /usr but this fails. Has anyone managed to do something like this?

The buildroot manual says this is unsupported because they can not import it into a rootfs. But for testcases a rootfs is not necessary.

Cœur
  • 37,241
  • 25
  • 195
  • 267
arved
  • 4,401
  • 4
  • 30
  • 53

2 Answers2

2

Yeah, unfortunately, it is not possible to do this. To be useful for Buildroot, a toolchain has to be a "pure" toolchain, i.e containing only the C library binaries and headers. You /usr is cluttered with gazillions of libraries from your host machine, and since Buildroot makes a full copy of the toolchain sysroot (which in your case, would be /usr), it would copy many, many things.

So definitely, it is not something that we support, and we don't intend to support this. You can also decide to build your programs with a x86 or x86_64 cross-compiler, have Buildroot generate a minimal Linux system, and chroot into it directly on your development PC.

Thomas Petazzoni
  • 5,636
  • 17
  • 25
1

The current documentation also seems to explain that this is not possible https://github.com/buildroot/buildroot/blob/2018.08/docs/manual/configure.txt#L198

We also do not support using the distribution toolchain (i.e. the gcc/binutils/C library installed by your distribution) as the toolchain to build software for the target. This is because your distribution toolchain is not a "pure" toolchain (i.e. only with the C/C++ library), so we cannot import it properly into the Buildroot build environment. So even if you are building a system for a x86 or x86_64 target, you have to generate a cross-compilation toolchain with Buildroot or crosstool-NG.

Furthermore, current Buildroot seems to check if your toolchain path seems to be a global toolchain, and bails out automatically if it is https://github.com/buildroot/buildroot/blob/2018.08/toolchain/helpers.mk#L395

with_sysroot=`$${__CROSS_CC} -v 2>&1 |sed -r -e '/.* --with-sysroot=([^[:space:]]+)[[:space:]].*/!d; s//\1/'`; \
if test "$${with_sysroot}"  = "/" ; then \
    echo "Distribution toolchains are unsuitable for use by Buildroot," ; \
    echo "as they were configured in a way that makes them non-relocatable,"; \
    echo "and contain a lot of pre-built libraries that would conflict with"; \
    echo "the ones Buildroot wants to build."; \
    exit 1; \
fi; \
Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985