dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
167 stars 21 forks source link

GCC 10.2.0 Fails to Compile under chroot #27

Closed dslm4515 closed 4 years ago

dslm4515 commented 4 years ago

Current host: Raspberry Pi 4 (4GB RAM) Distro: MLFS-6.00 (GCC 9.2.0) Truple: aarch64-linux-musleabihf

Compilation errors out with libgomp of GCC failing:

checking whether the C compiler works... no                                                                                                                              
configure: error: in `/sources/gcc-10.2.0/build/aarch64-linux-musleabihf/libgomp':                                                                                       
configure: error: C compiler cannot create executables                                                                                                                   
See `config.log' for more details                                                                                                                                        
make[1]: *** [Makefile:14436: configure-target-libgomp] Error 1                                                                                                          
make[1]: Leaving directory '/sources/gcc-10.2.0/build'                                                                                                                   
make: *** [Makefile:962: all] Error 2

Checking config.log for libgomp shows:

configure:3907: checking whether the C compiler works                                                                                                                    
configure:3929: /sources/gcc-10.2.0/build/./gcc/xgcc -B/sources/gcc-10.2.0/build/./gcc/ -B/usr/aarch64-linux-musleabihf/bin/ -B/usr/aarch64-linux-musleabihf/lib/ -isyst>
/tools/lib/gcc/aarch64-mlfs-linux-musleabihf/10.2.0/../../../../aarch64-mlfs-linux-musleabihf/bin/ld: cannot find -lssp_nonshared                                        
collect2: error: ld returned 1 exit status                                                                                                                               
configure:3933: $? = 1                                                                                                                                                   
configure:3971: result: no

My original configure command fo GCC:

SED=sed  libat_cv_have_ifunc=no       \                                                                                                                                  
../configure --prefix=/usr            \                                                                                                                                  
             --build="${TRUPLE}"\                                                                                                                                        
             --with-system-zlib       \                                                                                                                                  
             --with-isl \                                                                                                                                                
             --with-linker-hash-style=gnu \                                                                                                                              
             --enable-languages=c,c++ \                                                                                                                                  
             --enable-threads=posix \                                                                                                                                    
             --enable-clocale=generic \                                                                                                                                  
             --enable-languages=c,c++ \                                                                                                                                  
             --enable-tls \                                                                                                                                              
             --enable-libstdcxx-time \                                                                                                                                   
             --enable-fully-dynamic-string \                                                                                                                             
             --enable-default-pie \                                                                                                                                      
             --enable-default-ssp \                                                                                                                                      
             --enable-vtable-verify \                                                                                                                                    
             --enable-linker-build-id \                                                                                                                                  
             --enable-fast-character \                                                                                                                                   
             --disable-libstdcxx-pch \                                                                                                                                   
             --disable-nls \                                                                                                                                             
             --disable-multilib       \                                                                                                                                  
             --disable-bootstrap      \                                                                                                                                  
             --disable-symvers \                                                                                                                                         
             --disable-libsanitizer \                                                                                                                                    
             --disable-target-libiberty \                                                                                                                                
             --disable-libunwind-exceptions \
             --with-arch=armv8-a --with-abi=lp64 \
             --disable-libssp --disable-libmpx --disable-libmudflap

Initially, the last 3 flags in my configure command also yielded a failed build with a different error. I forgot to document the error when I used the same configure flags from previous branch (6.00, GCC 9.2.0). I am currently upgrading branch 7.00 with package versions used in LFS-10RC1

dslm4515 commented 4 years ago

Looking at Alpine Linux's build of GCC 10.2.0, I'm missing an extra library during musl libc build:

# provide minimal libssp_nonshared.a so we don't need libssp from gcc
/tools/bin/aarch64-mlfs-linux-musleabihf-gcc -fpie -c ../files/__stack_chk_fail_local.c -o __stack_chk_fail_local.o
/tools/bin/aarch64-mlfs-linux-musleabihf-gcc-ar r libssp_nonshared.a __stack_chk_fail_local.o
cp -v libssp_noshared.a /usr/lib/

__stack_chk_fail_local.c:

extern void __stack_chk_fail(void);
void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { __stack_chk_fail(); }

Looks like build progresses further, but stops again:

vtv_start.c:56:1: warning: constructor priorities from 0 to 100 are reserved for the implementation [-Wprio-ctor-dtor]                                                                           
   56 | {                                                                                                                                                                                        
      | ^                                                                                                                                                                                        
../../../libvtv/vtv_rts.cc:128:10: fatal error: execinfo.h: No such file or directory                                                                                                            
  128 | #include <execinfo.h>                                                                                                                                                                    
      |          ^~~~~~~~~~~~                                                                                                                                                                    
compilation terminated.                                                                                                                                                                          
make[4]: *** [Makefile:604: vtv_rts.lo] Error 1
4y8 commented 4 years ago

The "execinfo" error went out for me when applying the "execinfo" patch from Void Linux, with it, I managed to compile GCC 10.2.0 even though the patch is made for an older version of GCC.

dslm4515 commented 4 years ago

@Yul3n, I'll try that! Thanks!

firasuke commented 4 years ago

Use mussel, which is a script that I wrote to create cross compilation toolchains targetting musl libc with a single GCC build.

It produces working ABIs, supports many architectures, uses the latest upstream packages, supports LTO via zstd and is fully documented.

dslm4515 commented 4 years ago

@Yul3n, Awesome! I forgot to check void linux. That patched fixed it.

dslm4515 commented 4 years ago

@firasuke, WOW. That would come in very handy!

I got the Raspberry Pi 4 (4GB RAM) that I can test your project on. :P

dslm4515 commented 4 years ago

@firasuke, I just quickly looked over mussel ... you got lastest version of ISL working with GCC! My builds are still stuck on isl-0.19. Definitely, will check that out further!

firasuke commented 4 years ago

Thanks!

Please do, and let me know if it works for you.

4y8 commented 4 years ago

Shouldn't the issue be closed now?

dslm4515 commented 4 years ago

Running the GCC testsuite. at the moment... But yes, should be closed.