zoukankan      html  css  js  c++  java
  • lfs遇到的一些问题--准备阶段

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

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

    echo $LFS
    export LFS=/mnt/lfs

     

    2.这个命令:

    ln -sv $LFS/tools  /

    在宿主系统上创建一个 /tools 符号链接。它将指向 LFS 分区上的$LFS/tools 目录,此命令相当于:

    ln -sv $LFS/tool  /tools

    之后可用ls  -l 在根目录看到生成了一个链接

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

     

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

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

    ../../../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

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

    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/中,所以命令改为(注意,sed不可执行多次):

    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 

     下载这个文件可能需要fuck the gfw,在下面贴出此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...

  • 相关阅读:
    django 项目 crm 关于展示表的细节
    djagngo crm 项目 展示页面 和分页
    django项目 crm登录 注册
    django项目 crm表结构一些常用的字段
    django认证 auth
    django form组件
    json和ajax技术
    VS 2013编译64位版本QT 4.8.6及使用cmake为依赖QT生成VS项目时Could NOT find Qt4
    使用国内pypi源来安装python包
    [转]ubuntu 下无法启动chrome
  • 原文地址:https://www.cnblogs.com/sukai/p/3657215.html
Copyright © 2011-2022 走看看