[01/28] gcc: toolchain stage 2: Set sysroot to /tools_${arch}

Message ID 20220204164748.315559-1-michael.tremer@ipfire.org
State Accepted
Commit 7c6bf38c05fb9ccf0d8d4e34f3448575f2b82899
Headers
Series [01/28] gcc: toolchain stage 2: Set sysroot to /tools_${arch} |

Commit Message

Michael Tremer Feb. 4, 2022, 4:47 p.m. UTC
  The stage 2 compiler was looking for libraries outside the bootstrapped
toolchain environment which causes that linked programs cannot be
executied because the runtime linker only looks for libraries inside the
toolchain environment.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/gcc | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Peter Müller Feb. 5, 2022, 6:13 p.m. UTC | #1
Hello Michael,

trying to compile the new toolchain on my workstation (running openSUSE Leap 15.3, kernel
5.3.18-150300.59.43-default, GCC 11 installed), gcc fails to build:

> Checking for necessary space on disk                                                                                                                                                                                                 [ DONE ]
> chroot: failed to run command 'env': No such file or directory
> Toolchain compilation (x86_64)                                                                                                                                                                                                        
> stage1                                                                                                                                                                                                                               [ DONE ]
> binutils (2.37)                                                                                                                                                                                                    PASS=1[       37 ][ DONE ]
> gcc (11.1.0)                                                                                                                                                                                                       PASS=1[     4:52 ][ FAIL ]
> 
>     checking for sys/auxv.h... no
>     checking for sys/mman.h... no
>     checking for grep that handles long lines and -e... /bin/grep
>     checking for egrep... /bin/grep -E
>     checking for ANSI C header files... no
>     checking whether decimal floating point is supported... no
>     checking whether fixed-point is supported... no
>     checking whether the compiler is configured for setjmp/longjmp exceptions... no
>     checking for CET support... yes
>     checking if the linker (/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/./gcc/collect-ld) is GNU ld... yes
>     checking for thread model used by GCC... single
>     checking whether assembler supports CFI directives... yes
>     checking for target glibc version... 2.11
>     2.11
>     checking for __attribute__((visibility("hidden")))... yes
>     checking for .cfi_sections .debug_frame... yes
>     checking whether the target assembler supports thread-local storage... yes
>     checking whether the thread-local storage support is from emutls... no
>     checking if the assembler supports AVX... yes
>     checking for init priority support... yes
>     configure: updating cache ./config.cache
>     configure: creating ./config.status
>     config.status: creating Makefile
>     config.status: creating auto-target.h
>     config.status: executing default commands
>     /home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libgcc/../config-ml.in: line 133: enable_libstdc++_v3=no: command not found
>     make[2]: Leaving directory '/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build'
>     make[1]: *** [Makefile:947: all] Error 2
>     make[1]: Leaving directory '/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build'
>     make: *** [gcc:251: /home/pmu/IPFire-development/ipfire-2.x/log/gcc-11.1.0-tools1] Error 2
> 
> ERROR: Building gcc PASS=1                                                                                                                                                                                                           [ FAIL ]
>     Check /home/pmu/IPFire-development/ipfire-2.x/log/_build.toolchain.log for errors if applicable                                                                                                                                  [ FAIL ]

In the logs, I also noticed this:

> make[4]: Entering directory '/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/libcc1'
> /bin/sh ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1  -I /home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/..
> /include -I /home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/../libgcc -I ../gcc -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/../gcc  -I/home/pmu/IPFire-developme
> nt/ipfire-2.x/build/usr/src/gcc-build/./gmp -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/gmp -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/./mpfr/src -I/home/pmu/IPFire-dev
> elopment/ipfire-2.x/build/usr/src/gcc-11.1.0/mpfr/src -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/mpc/src   -W -Wall  -fvisibility=hidden -fcf-protection  -O2 -pipe -Wall -fPIC -m64 -MT findcomp.lo -MD -MP -
> MF .deps/findcomp.Tpo -c -o findcomp.lo /home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/findcomp.cc
> libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1 -I /home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/../include -I /home/fluke/deve
> l/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/../libgcc -I ../gcc -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/../gcc -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/g
> cc-build/./gmp -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/gmp -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/./mpfr/src -I/home/pmu/IPFire-development/ipfire-2.x/build/usr
> /src/gcc-11.1.0/mpfr/src -I/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/mpc/src -W -Wall -fvisibility=hidden -fcf-protection -O2 -pipe -Wall -fPIC -m64 -MT findcomp.lo -MD -MP -MF .deps/findcomp.Tpo -c /home/fl
> uke/devel/IPFire-development/ipfire-2.x/build/usr/src/gcc-11.1.0/libcc1/findcomp.cc  -fPIC -DPIC -o .libs/findcomp.o
> g++: error: unrecognized command line option '-fcf-protection'; did you mean '-fstack-protector'?
> make[4]: *** [Makefile:604: findcomp.lo] Error 1
> make[4]: Leaving directory '/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/libcc1'
> make[3]: *** [Makefile:441: all] Error 2
> make[3]: Leaving directory '/home/pmu/IPFire-development/ipfire-2.x/build/usr/src/gcc-build/libcc1'
> make[2]: *** [Makefile:12396: all-libcc1] Error 2
> make[2]: *** Waiting for unfinished jobs....

This leaves me a bit puzzled, as I thought "-fcf-protection" used to work before.

What am I doing wrong? :-)

Thanks, and best regards,
Peter Müller
  
Peter Müller Feb. 6, 2022, 10:39 a.m. UTC | #2
Hello Michael,

oh well. :-(

openSuSE Leap 15.3 ships GCC 7 by default, and while I installed GCC 11, stupid me
forgot to change _another_ symlink which still pointed to the GCC 7 binary.

Please excuse the noise.

Thanks, and best regards,
Peter Müller
  
Michael Tremer Feb. 7, 2022, 10:15 a.m. UTC | #3
Hello,

This is exactly why we are pre-building the toolchain. Not only to save time, but because it is quite fragile.

I built this for all architectures on Debian 11 and this worked fine. I am very surprised to say this, but Debian seems to be really up to date :)

I would totally recommend changing your distribution.

-Michael

> On 6 Feb 2022, at 10:39, Peter Müller <peter.mueller@ipfire.org> wrote:
> 
> Hello Michael,
> 
> oh well. :-(
> 
> openSuSE Leap 15.3 ships GCC 7 by default, and while I installed GCC 11, stupid me
> forgot to change _another_ symlink which still pointed to the GCC 7 binary.
> 
> Please excuse the noise.
> 
> Thanks, and best regards,
> Peter Müller
  

Patch

diff --git a/lfs/gcc b/lfs/gcc
index ade02dcda..96e58ddae 100644
--- a/lfs/gcc
+++ b/lfs/gcc
@@ -116,6 +116,7 @@  ifeq "$(PASS)" "2"
   EXTRA_CONFIG = \
 	--build=$(BUILDTARGET) \
 	--prefix=$(TOOLS_DIR) \
+	--with-sysroot=$(ROOT) \
 	--with-local-prefix=$(TOOLS_DIR) \
 	--with-native-system-header-dir=$(TOOLS_DIR)/include \
 	--enable-languages=c,c++ \