tar -xvf ./binutils-2.37.tar.xz cd binutils-2.37 mkdir -v build cd build/ time { ../configure --prefix=$LFS/tools \ --with-sysroot=$LFS \ --target=$LFS_TGT \ --disable-nls \ --disable-werror && make && make install;} cd ../.. rm -rf binutils-2.37
警告:
checking for -plugin option… ar: no operation specified
configure: WARNING: Failed: ar --plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so rc
no
选择无视这个警告
cd .. cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h
cd .. rm -rf gcc-11.2.0
报错:
checking for suffix of object files… configure: error: in /mnt/lfs/sources/gcc-11.2.0/build/x86_64-lfs-linux-gnu/libgcc': configure: error: cannot compute suffix of object files: cannot compile See config.log’ for more details
Makefile:13649: recipe for target ‘configure-target-libgcc’ failed
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory ‘/mnt/lfs/sources/gcc-11.2.0/build’
Makefile:946: recipe for target ‘all’ failed
make: *** [all] Error 2
检查…/configure输出,发现报错
required isl version is 0.15 or later
*** This configuration is not supported in the following subdirectories:
target-libquadmath target-libstdc+±v3 gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-libgomp target-liboffloadmic target-libatomic target-libvtv target-libssp target-libitm target-libsanitizer
(Any other directories should still work fine.)
checking for default BUILD_CONFIG…
处理过程中发现虚拟机断网,故重启
获取isl
1 2 3 4 5 6 7 8 9
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2 tar jxvf isl-0.12.2.tar.bz2 cd isl-0.12.2 mkdir build cd build ../configure make sudo make install -j4
配置isl过程中发现报错
checking gmp.h usability… no
checking gmp.h presence… no
checking for gmp.h… no
configure: error: gmp.h header not found
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 tar -jxvf isl-0.18.tar.bz2 cd isl-0.18/ mkdir temp cd temp sudo ../configure --prefix=/usr/local/isl-0.18 sudo make sudo make install
tar -xvf linux-5.13.12.tar.xz cd linux-5.13.12 make mrproper make headers find usr/include -name '.*' -delete rm usr/include/Makefile cp -rv usr/include $LFS/usr cd .. rm -rf linux-5.13.12
time { ../libstdc++-v3/configure \ --host=$LFS_TGT \ --build=$(../config.guess) \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --disable-libstdcxx-pch \ --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/11.2.0 && make && make DESTDIR=$LFS install;}
cd ../.. rm -rf gcc-11.2.0
报错,无法安装 libtool: install: x86_64-lfs-linux-gnu-ranlib /mnt/lfs/usr/lib/../lib/libsupc++.a ../libtool: line 1132: x86_64-lfs-linux-gnu-ranlib: command not found Makefile:707: recipe for target 'install-toolexeclibLTLIBRARIES' failed make[2]: *** [install-toolexeclibLTLIBRARIES] Error 127 make[2]: Leaving directory '/mnt/lfs/sources/gcc-11.2.0/build/libsupc++' Makefile:841: recipe for target 'install-am' failed make[1]: *** [install-am] Error 2 make[1]: Leaving directory '/mnt/lfs/sources/gcc-11.2.0/build/libsupc++' Makefile:568: recipe for target 'install-recursive' failed make: *** [install-recursive] Error 1
检查配置../libstdc++-v3/configure,发现警告 configure: WARNING: === You have requested GNU symbol versioning, but configure: WARNING: === you are not building a shared libgcc_s. configure: WARNING: === Symbol versioning will be disabled. 报错 Makefile:1765: recipe for target 'x86_64-lfs-linux-gnu/bits/largefile-config.h' failed make: [x86_64-lfs-linux-gnu/bits/largefile-config.h] Error 1 (ignored) Makefile:1765: recipe for target 'x86_64-lfs-linux-gnu/bits/largefile-config.h' failed make: [x86_64-lfs-linux-gnu/bits/largefile-config.h] Error 1 (ignored)
stackvma.c: In function ‘rof_open’:
stackvma.c:122:30: error: ‘PATH_MAX’ undeclared (first use in this function)
122 | # define MIN_LEFTOVER (73 + PATH_MAX)
| ^~~~~~~~
stackvma.c:172:18: note: in expansion of macro ‘MIN_LEFTOVER’
172 | if (size > MIN_LEFTOVER)
| ^~~~~~~~~~~~
stackvma.c:122:30: note: each undeclared identifier is reported only once for each function it appears in
122 | # define MIN_LEFTOVER (73 + PATH_MAX)
| ^~~~~~~~
stackvma.c:172:18: note: in expansion of macro ‘MIN_LEFTOVER’
172 | if (size > MIN_LEFTOVER)
| ^~~~~~~~~~~~
Makefile:2319: recipe for target ‘stackvma.o’ failed
make[2]: *** [stackvma.o] Error 1
make[2]: Leaving directory ‘/mnt/lfs/sources/diffutils-3.8/lib’
Makefile:2019: recipe for target ‘all’ failed
make[1]: *** [all] Error 2
make[1]: Leaving directory ‘/mnt/lfs/sources/diffutils-3.8/lib’
Makefile:1650: recipe for target ‘all-recursive’ failed
make: *** [all-recursive] Error 1
解决:在出错的源文件中加入#include <linux/limits.h>
findutils:
buildcmd.c: In function ‘bc_init_controlinfo’:
buildcmd.c:491:29: error: ‘_POSIX_ARG_MAX’ undeclared (first use in this function); did you mean ‘_SC_ARG_MAX’?
491 | ctl->posix_arg_size_min = _POSIX_ARG_MAX;
| ^~~~~~~~~~~~~~
| _SC_ARG_MAX
buildcmd.c:491:29: note: each undeclared identifier is reported only once for each function it appears in
Makefile:2296: recipe for target ‘buildcmd.o’ failed
make[2]: *** [buildcmd.o] Error 1
make[2]: Leaving directory ‘/mnt/lfs/sources/findutils-4.8.0/lib’
Makefile:2357: recipe for target ‘all-recursive’ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/mnt/lfs/sources/findutils-4.8.0’
Makefile:2296: recipe for target ‘all’ failed
make: *** [all] Error 2
Command 'chroot' is available in '/usr/sbin/chroot' The command could not be located because '/usr/sbin' is not included in the PATH environment variable. This is most likely caused by the lack of administrative privileges associated with your user account. chroot: command not found
(lfs chroot) root:/sources/gcc-11.2.0/build# ../libstdc++-v3/configure \ CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --host=$(uname -m)-lfs-linux-gnu \ --disable-libstdcxx-pch checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-lfs-linux-gnu checking target system type... x86_64-lfs-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for x86_64-lfs-linux-gnu-strip... no checking for strip... strip checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for x86_64-lfs-linux-gnu-gcc... no checking for gcc... no checking for x86_64-lfs-linux-gnu-cc... no checking for cc... no checking for x86_64-lfs-linux-gnu-cl.exe... no checking for cl.exe... no configure: error: in `/sources/gcc-11.2.0/build': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
(lfs chroot) root:/sources/gcc-11.2.0/build# ../libstdc++-v3/configure \ CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --host=$(uname -m)-lfs-linux-gnu \ --disable-libstdcxx-pch checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-lfs-linux-gnu checking target system type... x86_64-lfs-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for x86_64-lfs-linux-gnu-strip... x86_64-lfs-linux-gnu-strip checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for x86_64-lfs-linux-gnu-gcc... x86_64-lfs-linux-gnu-gcc checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether x86_64-lfs-linux-gnu-gcc accepts -g... yes checking for x86_64-lfs-linux-gnu-gcc option to accept ISO C89... unsupported checking whether x86_64-lfs-linux-gnu-gcc understands -c and -o together... yes checking for x86_64-lfs-linux-gnu-g++... x86_64-lfs-linux-gnu-g++ checking whether we are using the GNU C++ compiler... yes checking whether x86_64-lfs-linux-gnu-g++ accepts -g... yes checking for special C compiler options needed for large files... no checking for _FILE_OFFSET_BITS value needed for large files... unknown checking for _LARGE_FILES value needed for large files... unknown checking how to run the C preprocessor... /lib/cpp configure: error: in `/sources/gcc-11.2.0/build': configure: error: C preprocessor "/lib/cpp" fails sanity check See `config.log' for more details
重启后恢复工作状态 #2
这个时候如果你关机或重新启动,那么重新开机后回到工作状态的步骤是:
1
su
1 2 3 4 5 6 7 8 9 10 11 12 13
mount -v --bind /dev $LFS/dev
mount -v --bind /dev/pts $LFS/dev/pts mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys mount -vt tmpfs tmpfs $LFS/run chroot "$LFS" /usr/bin/env -i \ HOME=/root \ TERM="$TERM" \ PS1='(lfs chroot) \u:\w\$ ' \ PATH=/usr/bin:/usr/sbin \ /bin/bash --login +h
Libstdc++ form GCC-11.2.0 pass 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
tar -xvf gcc-11.2.0.tar.xz cd gcc-11.2.0
ln -s gthr-posix.h libgcc/gthr-default.h
mkdir -v build cd build
time { ../libstdc++-v3/configure \ CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --host=$(uname -m)-lfs-linux-gnu \ --disable-libstdcxx-pch && make && make install;} cd ../.. rm -rf gcc-11.2.0
sh Configure -des \ -Dprefix=/usr \ -Dvendorprefix=/usr \ -Dprivlib=/usr/lib/perl5/5.34/core_perl \ -Darchlib=/usr/lib/perl5/5.34/core_perl \ -Dsitelib=/usr/lib/perl5/5.34/site_perl \ -Dsitearch=/usr/lib/perl5/5.34/site_perl \ -Dvendorlib=/usr/lib/perl5/5.34/vendor_perl \ -Dvendorarch=/usr/lib/perl5/5.34/vendor_perl make make install
Failed 6 tests out of 2437, 99.75% okay. ../cpan/Socket/t/getnameinfo.t ../dist/Net-Ping/t/110_icmp_inst.t ../dist/Net-Ping/t/500_ping_icmp.t ../dist/Net-Ping/t/501_ping_icmpv6.t ../dist/Net-Ping/t/520_icmp_ttl.t ../lib/Net/hostent.t
cpan/Socket/t/getnameinfo ........................................ # Failed test '$err == 0 for {family=AF_INET,port=80,sinaddr=127.0.0.1}/NI_NUMERICSERV' # at t/getnameinfo.t line 26. # got: -3 # expected: 0 # Failed test'$host is nonzero length for NS' # at t/getnameinfo.t line 30. # Looks like you failed 2 tests of 13. FAILED at test 9
dist/Net-Ping/t/520_icmp_ttl ..................................... Can't get icmp protocol by name at t/520_icmp_ttl.t line 23. # Looks like your test exited with 2 just after 1. FAILED--non-zero wait status: 512
dist/Net-Ping/t/501_ping_icmpv6 .................................. Can't get ipv6-icmp protocol by name at t/501_ping_icmpv6.t line 49. FAILED--no leader found
dist/Net-Ping/t/500_ping_icmp .................................... Can't get icmp protocol by name at t/500_ping_icmp.t line 58. FAILED--no leader found
dist/Net-Ping/t/110_icmp_inst .................................... Can't get icmp protocol by name at t/110_icmp_inst.t line 24. # Looks like your test exited with 2 just after 1. FAILED--expected 2 tests, saw 1
lib/Net/hostent .................................................. # Failed test 'gethostbyaddr('127.0.0.1')' # at ../lib/Net/hostent.t line 46. # Looks like your test exited with 1 just after 4. FAILED at test 4
以及一个ok的提示 t/op/magic ....................................................... Can't exec "ps": No such file or directory at op/magic.t line 830. ok ### Since not all tests were successful, you may want to run some of ### them individually and examine any diagnostic messages they produce. ### See the INSTALL document's section on "make test". ### You have a good chance to get more information by running ### ./perl harness ### in the 't' directory since most (>=80%) of the tests succeeded. ### You may have to set your dynamic library search path, ### LD_LIBRARY_PATH, to point to the build directory: ### setenv LD_LIBRARY_PATH `pwd`; cd t; ./perl harness ### LD_LIBRARY_PATH=`pwd`; export LD_LIBRARY_PATH; cd t; ./perl harness ### export LD_LIBRARY_PATH=`pwd`; cd t; ./perl harness ### for csh-style shells, like tcsh; or for traditional/modern ### Bourne-style shells, like bash, ksh, and zsh, respectively. Elapsed: 643 sec u=8.43 s=26.63 cu=281.27 cs=143.48 scripts=2437 tests=1120821
解决: 从root切换回lfs,再度编译
Python-3.9.6
1 2 3 4 5 6 7 8 9 10
tar -xvf Python-3.9.6.tar.xz cd Python-3.9.6
time { ./configure --prefix=/usr \ --enable-shared \ --without-ensurepip && make && make install;}
cd .. rm -rf Python-3.9.6
Texinfo-6.8
1 2 3 4 5 6 7 8 9 10 11
tar -xvf texinfo-6.8.tar.xz cd texinfo-6.8
sed -e 's/__attribute_nonnull__/__nonnull/' \ -i gnulib/lib/malloc/dynarray-skeleton.c
time { ./configure --prefix=/usr && make && make install;}