GCC 5.1.0 无法按照 LFS 指南进行编译 -- pass 2;链接错误?

GCC 5.1.0 无法按照 LFS 指南进行编译 -- pass 2;链接错误?

我尝试按照 LFS 指南使用 binutils 5.25 和 glibc 2.21 编译 GCC 5.1,但在到达“gcc pass 2”步骤时该过程失败,出现错误:

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

我尝试过提供该-fPIC选项,但没有帮助。

我的配置选项如下:

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

整个错误信息是:

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

如果有帮助,LFS*变量如下:

LFS=/home/system/peal/system/system/toolchain
LFS_TGT=x86_64-peal-linux-gnu

我的构建服务器基于每日更新的 Ubuntu 16.04 (gcc 5.3)。

以下是有关工具链的更多详细信息:

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++

有任何想法吗?

谢谢你!

答案1

我发现了问题:

  • 正如 Munir 所说,我sh指向dash而不是bash
  • 之后,gcc由于缺少rpc/xdr.h头文件而无法编译;这是通过glibc添加标志重建来修复的:--enable-obsolete-rpc;

现在一切都很好。

相关内容