I'm trying to follow the LFS guide for compiling the GCC 5.1 with binutils 5.25 and glibc 2.21 and the process fails when reaching the "gcc pass 2" step giving me the error:
ld: /tools/lib/../lib64/libstdc++.a(new_opv.o): relocation R_X86_64_32 against `_ZTISt9bad_alloc' can not be used when making a shared object; recompile with -fPIC
/tools/lib/../lib64/libstdc++.a: error adding symbols: Bad value
I've tried giving the -fPIC
option but it doesn't help.
My configure options are the following:
CC=$LFS_TGT-gcc
CXX=$LFS_TGT-g++
AR=$LFS_TGT-ar
RANLIB=$LFS_TGT-ranlib
../gcc-5.1.0/configure \
--prefix=/tools \
--with-local-prefix=/tools \
--with-native-system-header-dir=/tools/include \
--enable-languages=c,c++ \
--disable-libstdcxx-pch \
--disable-multilib \
--disable-bootstrap \
--disable-libgomp
The whole error message is:
libtool: link: x86_64-peal-linux-gnu-g++ -fPIC -DPIC -shared -nostdlib /home/system/peal/system/system/toolchain/tools/lib/../lib64/crti.o /home/system/peal/system/system/toolchain/tools/bin/../lib/gcc/x86_64-peal-linux-gnu/5.1.0/crtbeginS.o .libs/findcomp.o .libs/libcc1.o .libs/names.o .libs/callbacks.o .libs/connection.o .libs/marshall.o -L/home/system/peal/system/system/toolchain/tools/bin/../lib/gcc/x86_64-peal-linux-gnu/5.1.0 -L/home/system/peal/system/system/toolchain/tools/bin/../lib/gcc -L/home/system/peal/system/system/toolchain/tools/lib/../lib64 -L/home/system/peal/system/system/toolchain/tools/bin/../lib/gcc/x86_64-peal-linux-gnu/5.1.0/../../../../x86_64-peal-linux-gnu/lib -L/home/system/peal/system/system/toolchain/tools/lib /tools/lib/../lib64/libstdc++.a -lm -lc -lgcc /home/system/peal/system/system/toolchain/tools/bin/../lib/gcc/x86_64-peal-linux-gnu/5.1.0/crtendS.o /home/system/peal/system/system/toolchain/tools/lib/../lib64/crtn.o -static-libstdc++ -static-libgcc ../libiberty/pic/libiberty.a -Wl,-soname -Wl,libcc1.so.0 -Wl,-retain-symbols-file -Wl,../../gcc-5.1.0/libcc1/libcc1.sym -o .libs/libcc1.so.0.0.0
/home/system/peal/system/system/toolchain/tools/bin/../lib/gcc/x86_64-peal-linux-gnu/5.1.0/../../../../x86_64-peal-linux-gnu/bin/ld: /tools/lib/../lib64/libstdc++.a(new_opv.o): relocation R_X86_64_32 against `_ZTISt9bad_alloc' can not be used when making a shared object; recompile with -fPIC
/tools/lib/../lib64/libstdc++.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:409: recipe for target 'libcc1.la' failed
make[3]: *** [libcc1.la] Error 1
make[3]: Leaving directory '/home/system/peal/system/system/toolchain/sources/gcc-build/libcc1'
Makefile:291: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/system/peal/system/system/toolchain/sources/gcc-build/libcc1'
Makefile:10639: recipe for target 'all-libcc1' failed
make[1]: *** [all-libcc1] Error 2
make[1]: Leaving directory '/home/system/peal/system/system/toolchain/sources/gcc-build'
Makefile:880: recipe for target 'all' failed
make: *** [all] Error 2
In case it helps, the LFS*
variables are these:
LFS=/home/system/peal/system/system/toolchain
LFS_TGT=x86_64-peal-linux-gnu
My build server is based on Ubuntu 16.04 (gcc 5.3) daily updated.
Here are some more details about the toolchain:
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ gcc --version
gcc (GCC) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ g++ --version
g++ (GCC) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ ld --version
GNU ld (GNU Binutils) 2.25.90.20151209
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ ldd --version
ldd (GNU libc) 2.21
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ which ld
/tools/bin/ld
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ which ldd
/tools/bin/ldd
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ which gcc
/tools/bin/gcc
me@buildserver:/home/system/peal/system/system/toolchain/sources/gcc-build$ which g++
/tools/bin/g++
Any ideas?
Thank you!
LDFLAGS
,CXXFLAGS
andCFLAGS
with the-fPIC
?CFLAGS="-g -O2 -fPIC"
but without successlibstdc++
built in section 5.8 of the book. You are still quite early on in your build, so I would suggest you restart from the beginning of chapter 5. Also, double confirm thatsh
is pointing tobash
.5.8.1.
of the LFS manual. I just verified what sh was pointing to and indeed it wasdash
, notbash
so now I'll start from scratch and see what happens. I'll come back later with a comment. Thak you Munir!