LFS遇到的一些问题之准备阶段

本机宿主系统archlinux,lfs SVN-20130711,参考文档 html

 

1.在离开或从新进入当前工做环境 (好比 su 成为root或者其余用户) 时不要忘记检查$LFS是否设置好。 linux

echo $LFS export LFS=/mnt/lfs

 

2.这个命令: shell

ln -sv $LFS/tools  /

在宿主系统上建立一个/tools符号连接。它将指向 LFS 分区上的$LFS/tools 目录,此命令至关于: 安全

ln -sv $LFS/tool  /tools

以后可用ls  -l 在根目录看到生成了一个连接 app

lrwxrwxrwx 1 root root    15 Apr 10 19:03 tools -> /mnt/lfs//tools

 

3.第一遍编译Binutils,出师不利,开始就出错了,卡在开头,耗费一个下午的时间,方才解决(中间在1024放纵了很久……阿弥陀佛) ide

configure时没错,make时出错,错误信息相似下面: ui

../../../binutils-2.23.2/bfd/doc/bfd.texinfo:325: unknown command `colophon'
../../../binutils-2.23.2/bfd/doc/bfd.texinfo:336: unknown command `cygnus'
make[3]: *** [bfd.info] Error 1
make[3]: Leaving directory `/mnt/lfs/sources/binutils-build/bfd/doc'
Making info in po
make[3]: Entering directory `/mnt/lfs/sources/binutils-build/bfd/po'
make[3]: Nothing to be done for `info'.
make[3]: Leaving directory `/mnt/lfs/sources/binutils-build/bfd/po'
make[3]: Entering directory `/mnt/lfs/sources/binutils-build/bfd'
make[3]: Nothing to be done for `info-am'.
make[3]: Leaving directory `/mnt/lfs/sources/binutils-build/bfd'
make[2]: *** [info-recursive] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/binutils-build/bfd'
make[1]: *** [all-bfd] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/binutils-build'
make: *** [all] Error 2 this

搜便世界,在这里找到个解决办法: atom

sed -i -e 's/@colophon/@@colophon/'   -e 's/doc@cygnus.com/doc@@cygnus.com/' bfd/doc/bfd.texinfo

当时正在新建的 binutils-build 下,此目录中的bfd/doc/ 中没有bfd.texinfo 文件,而在 binutils-2.23.2/bfd/doc/中,因此命令改成: spa

sed -i -e 's/@colophon/@@colophon/'  -e 's/doc@cygnus.com/doc@@cygnus.com/' ../binutils-2.23.2/bfd/doc/bfd.texinfo

成功编译! 此前还稀里糊涂的运行过make clean,  make distclean等命令,删除过目录,从新下载binutils包,但都没奏效,若是上面的方法不行,能够试试这些。此外,若是怀疑是gcc版本的问题,在宿主系统要求中gcc的部分,有这个note

On some distributions, there have been reports that some libraries used by gcc can be in an inconsistent state and that this interferes with building some LFS packages. To check this, look in /usr/lib and possibly /usr/lib64 for libgmp.la, libmpfr.la, and libmpc.la. Either all three should be present or absent, but not only one or two. If the problem exists on your system, either rename or delete the .la files or install the appropriate missing package.

我运行version-check.sh后发现没有libgmp.la, libmpfr.la,  libmpc.la这三个货,能够从这下手解决。

 

4.第一遍编译gcc,这条命令没有解释清楚

sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure

  -i 选项表示将改变直接写入文件

  /k prot/ 会搜索到这行

# Test for stack protector support in target C library

将/k prot/写成/stack protector/或许更容易理解。

接下来不是将"k prot" 替换成后边那句,而是在这行后边插入agcc_cv_libc_provides_ssp=yes

就成了

# Test for stack protector support in target C library
agcc_cv_libc_provides_ssp=yes

 

5.第一遍gcc,出错:

复制代码
configure: error: in `/mnt/lfs/sources/gcc-build/i686-lfs-linux-gnu/libatomic':
configure: error: C compiler cannot create executables
See `config.log' for more details.
Makefile:11514: recipe for target 'configure-target-libatomic' failed
make[1]: *** [configure-target-libatomic] Error 1
make[1]: Leaving directory '/mnt/lfs/sources/gcc-build'
Makefile:837: recipe for target 'all' failed
make: *** [all] Error 2
复制代码

 缘由:libatomic未禁用。

 解决:在前一步的configure选项中,加入 --disable-libatomic 选项 (另外一个方案,本身没试,供参考)

 

6.安装 Linux API 头文件, 解压内核。以前在程序包说明的部分提到内核要用最新的

Linux 内核相对常常更新,常常是由于发现了新的安全弱点。只要勘误表没有声明,总应该使用最新的 3.10.x 内核版本。 对于速度受限或者带宽昂贵的用户,想要升级 Linux 内核,能够分别下载程序包的基线版本和补丁。这可能会节省一些时间或开销。 

 

 在下载patch文件,解压到内核目录,用这个命令将补丁打上

patch -p1 < patch-3.10.36

 

 其中,patch-3.10.36 为解压后的补丁文件

 

7.编译glibc, configure错误:

checking for autoconf... autoconf checking whether autoconf works... no configure: error: *** These critical programs are missing or too old: make
*** Check the INSTALL file for required versions.

 fuck,这个问题如此困难,是make版本的问题。而我用的lfs由于要看中文的,因此不是最新的,也就会有版本相关的bug。踏破铁鞋,搜到一个解决办法,给glibc-2.17里的configure打个补丁,点击此处下载该补丁,即configure-make4.patch ,放到glibc-2.17的目录,而后在该目录执行:

patch <configure-make4.patch

 patch文件的内容以下:

--- configure    2012-12-19 18:06:09.792647617 +0200
+++ configure.fix    2013-10-31 01:14:26.479246078 +0200
@@ -4936,7 +4936,7 @@
   ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0
-9.]*\).*$/\1/p'`
   case $ac_prog_version in
     '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
-    3.79* | 3.[89]*)
+    3.79* | 3.[89]* | 4.[01]*)
        ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
     *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;



 以后make出错:

复制代码
/mnt/lfs/sources/glibc-build/resolv/libresolv_pic.a(gethnamaddr.os):/mnt/lfs/sources/glibc-2.17/resolv/gethnamaddr.c:636: more undefined references to `__stack_chk_guard' follow
collect2: error: ld returned 1 exit status
../Makerules:446: recipe for target '/mnt/lfs/sources/glibc-build/resolv/libresolv.so' failed
make[2]: *** [/mnt/lfs/sources/glibc-build/resolv/libresolv.so] Error 1
make[2]: Leaving directory '/mnt/lfs/sources/glibc-2.17/resolv'
Makefile:233: recipe for target 'resolv/others' failed
make[1]: *** [resolv/others] Error 2
make[1]: Leaving directory '/mnt/lfs/sources/glibc-2.17'
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 2
复制代码

 问题竟然出在第一遍gcc时那句:

sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure

忘了执行……fuck!!  stupid!!,以前光查它什么意思了,忘了运行之,只好再搞一遍……

 

8.第二遍binutils, 由于是从新解压的,不要忘了到binutils-2.23.2目录里执行那条sed命令。

 

9.第二遍gcc,configure出错:

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations.

前面没理解对,这一步

tar -Jxf ../mpfr-3.1.2.tar.xz mv -v mpfr-3.1.2 mpfr tar -Jxf ../gmp-5.1.2.tar.xz mv -v gmp-5.1.2 gmp tar -zxf ../mpc-1.0.1.tar.gz mv -v mpc-1.0.1 mpc

mpfr,gmp,mpc三个文件夹的正确位置应为gcc-4.8.1目录,我误觉得直接在$LFS/source目录解压而后重命名了……

 

10.没有第10条。接下来的包顺利地一塌糊涂,直接闯到了第三部分,编制LFS!

 

to be continued...

相关文章
相关标签/搜索