bootlin / toolchains-builder

http://toolchains.free-electrons.com
89 stars 27 forks source link

Support -no-canonical-prefixes argument to gcc #42

Closed jheaff1 closed 3 years ago

jheaff1 commented 3 years ago

Hi,

It appears that the gcc executables in the toolchains hosted at https://toolchains.bootlin.com/ do not support the -no-canonical-prefixes argument.

For example, if I run the following commands using the x86-64-core-i7 toolchain:

tar -xf x86-64-core-i7--glibc--stable-2020.08-1.tar.bz2
cd  x86-64-core-i7--glibc--stable-2020.08-1/bin
./x86_64-linux-gcc -E -xc++ - -v

I get the following output:

Using built-in specs.
COLLECT_GCC=/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/x86_64-linux-gcc.br_real
Target: x86_64-buildroot-linux-gnu
Configured with: ./configure --prefix=/opt/x86-64-core-i7--glibc--stable-2020.08-1 --sysconfdir=/opt/x86-64-core-i7--glibc--stable-2020.08-1/etc --enable-static --target=x86_64-buildroot-linux-gnu --with-sysroot=/opt/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/sysroot --enable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --disable-decimal-float --with-gmp=/opt/x86-64-core-i7--glibc--stable-2020.08-1 --with-mpc=/opt/x86-64-core-i7--glibc--stable-2020.08-1 --with-mpfr=/opt/x86-64-core-i7--glibc--stable-2020.08-1 --with-pkgversion='Buildroot 2020.08-14-ge5a2a90' --with-bugurl=http://bugs.buildroot.net/ --without-zstd --enable-libquadmath --enable-tls --enable-threads --without-isl --without-cloog --with-arch=corei7 --enable-languages=c,c++,fortran --with-build-time-tools=/opt/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/bin --enable-shared --disable-libgomp
Thread model: posix
gcc version 9.3.0 (Buildroot 2020.08-14-ge5a2a90) 
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=corei7'
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../libexec/gcc/x86_64-buildroot-linux-gnu/9.3.0/cc1plus -E -quiet -v -iprefix /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/ -isysroot /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/sysroot -D_GNU_SOURCE - -mtune=generic -march=corei7
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0"
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0/x86_64-buildroot-linux-gnu"
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0/backward"
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/include"
ignoring nonexistent directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/sysroot/usr/local/include"
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/include-fixed"
ignoring duplicate directory "/home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/../../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0/x86_64-buildroot-linux-gnu
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include/c++/9.3.0/backward
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/include
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/include-fixed
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/bin/../lib/gcc/x86_64-buildroot-linux-gnu/9.3.0/../../../../x86_64-buildroot-linux-gnu/include
 /home/jheaff1/Downloads/x86-64-core-i7--glibc--stable-2020.08-1/x86_64-buildroot-linux-gnu/sysroot/usr/include
End of search list.

Notice the paths at the bottom of the console output above has absolute paths. Now, if i run the same gcc command but add the -no-canonical-prefixes argument, I get the same output. I would expect that the paths at the bottom of the console output be relative paths. If I run the same commands but for the official arm gcc toolchain, I get the following output:

Using built-in specs.
COLLECT_GCC=./arm-none-eabi-gcc
Target: arm-none-eabi
Configured with: /mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/src/gcc/configure --target=arm-none-eabi --prefix=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native --libexecdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/lib --infodir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/install-native/arm-none-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-gmp=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpfr=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-mpc=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-isl=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-libelf=/mnt/workspace/workspace/GCC-10-pipeline/jenkins-GCC-10-pipeline-48_20201124_1606180641/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Arm Embedded Toolchain 10-2020-q4-major' --with-multilib-list=rmprofile,aprofile
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major) 
COLLECT_GCC_OPTIONS='-E' '-v' '-fno-canonical-system-headers' '-mcpu=arm7tdmi' '-mfloat-abi=soft' '-marm' '-march=armv4t'
 ./../lib/gcc/arm-none-eabi/10.2.1/cc1plus -E -quiet -v -iprefix ./../lib/gcc/arm-none-eabi/10.2.1/ -isysroot ./../arm-none-eabi -D__USES_INITFINI__ - -mcpu=arm7tdmi -mfloat-abi=soft -marm -march=armv4t -fno-canonical-system-headers
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1"
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi"
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward"
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/include"
ignoring nonexistent directory "./../arm-none-eabi/usr/local/include"
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/include-fixed"
ignoring duplicate directory "./../lib/gcc/../../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include"
ignoring nonexistent directory "./../arm-none-eabi/usr/include"
#include "..." search starts here:
#include <...> search starts here:
 ./../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1
 ./../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/arm-none-eabi
 ./../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include/c++/10.2.1/backward
 ./../lib/gcc/arm-none-eabi/10.2.1/include
 ./../lib/gcc/arm-none-eabi/10.2.1/include-fixed
 ./../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/include
End of search list.

Notice how the paths at the bottom of the console log are relative paths.

The motivation for resolving this issue is that I would like to use your x86-64-corei7 toolchain to provide a hermetic gcc toolchain within the Bazel build system. Sadly your toolchains would not play nicely with Bazel due to this issue

RomainNaour commented 3 years ago

Hello,

As a reminder, Toolchain-builder project use Buildroot internally to build all prebuilt toolchains.

I believe it's not a toolchain issue but an issue related to how gcc binary is used. If you import the same official arm gcc toolchain to Buildroot (as an external toolchain) you will get the same behavior. That's because in Buildroot, the toolchain infrastructure provide a toolchain wrapper that retrieve the full path to the gcc binary. This wrapper is present in all prebuilt toolchains so the gcc binary is called using an absolute path. (Add BR2_DEBUG_WRAPPER=1 in the environment to enable toolchain wrapper debug output)

Also try the official arm gcc toolchain with "$PWD/arm-none-eabi-gcc" instead of "./arm-none-eabi-gcc", you will get absolute path with or without "-no-canonical-prefixes".

About Bazel, there is curently no package using Bazel in Buildroot. Using Buildroot internal toolchain or Toolchain-builder toolchain with Bazel has not been tested. But I guess Bazel should be able to use existing toolchain as is.

Best regards, Romain

jheaff1 commented 3 years ago

Thanks for the reply @RomainNaour!

If I configure Bazel to use the gcc.br_real file, then it works perfectly. I’ll close this issue as it’s not really to do with bootlin

RomainNaour commented 3 years ago

You're welcome, I still think that Bazel should be able to use the toolchain wrapper (as for all other buildsystems). The wrapper provide all required flags (sysroot path) for your target, using gcc.br_real directly is not recommended. @tpetazzoni do you confirm?

Best regards, Romain