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

相關文章
相關標籤/搜索