目录
build:指构建程序时使用的机器。注意在某些其他章节,这台机器被称为“host”(宿主)。
host:指将来会运行被构建的程序的机器。注意这里说的“host”与其他章节使用的“宿主”(host) 一词不同。比如:$LFS
target:只有编译器使用这个术语。编译器为这台机器产生代码。它可能和 build 与 host 都不同。比如:configure --host=$LFS_TGT参数。
第 5 章 编译交叉工具链
5.2. Binutils-2.40 - 第一遍
进入$LFS/sources文件夹,解压,创建build文件夹
tar -xf binutils-2.40.tar.xz
cd binutils-2.40
mkdir -v build
cd build
执行构建,并记录SBU标准时间 ,4核cpu
time {
../configure --prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--enable-gprofng=no \
--disable-werror && make -j4 && make install; }
内存16G,cpu配置如下:
lfs:/mnt/lfs/tools$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 39 bits physical, 48 bits virtual
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 141
Model name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
基准运行时间 ,半分钟左右,由于并行,用户态的总时间多于real。
real 0m33.358s
user 1m17.278s
sys 0m21.260s
5.3. GCC-12.2.0 - 第一遍
进入$LFS/sources文件夹,解压gcc包,引入GMP、MPFR 和 MPC 这三个包,创建build文件夹
tar -xf gcc-12.2.0.tar.xz
cd gcc-12.2.0
# 解压GMP、MPFR 和 MPC 三个包
tar -xf ../mpfr-4.2.0.tar.xz
mv -v mpfr-4.2.0 mpfr
tar -xf ../gmp-6.2.1.tar.xz
mv -v gmp-6.2.1 gmp
tar -xf ../mpc-1.3.1.tar.gz
mv -v mpc-1.3.1 mpc
# 创建build文件夹
mkdir -v build
cd build
# 构建
time {
../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.37 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--enable-default-pie \
--enable-default-ssp \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++ && make -j4 && make install; }
运行时间:5分半
real 5m29.864s
user 17m47.384s
sys 2m13.571s
5.4. Linux-6.1.11 API 头文件
替换为Linux-6.1.29
lfs:/mnt/lfs/sources$ tar -xf linux-6.1.29.tar.xz
lfs:/mnt/lfs/sources$ cd linux-6.1.29
lfs:/mnt/lfs/sources/linux-6.1.29$ make mrproper
5.5. Glibc-2.37
lfs:/mnt/lfs/sources$ tar -xf glibc-2.37.tar.xz
lfs:/mnt/lfs/sources$ cd glibc-2.37
5.6. GCC-12.2.0 中的 Libstdc++
lfs:/mnt/lfs/sources$ tar -xf gcc-12.2.0.tar.xz
lfs:/mnt/lfs/sources$ cd gcc-12.2.0
lfs:/mnt/lfs/sources/gcc-12.2.0$ mkdir -v build
lfs:/mnt/lfs/sources/gcc-12.2.0$ cd build/
# 按lfs文档执行
第 6 章 交叉编译临时工具
无
第 7 章 进入 Chroot 并构建其他临时工具
7.7. Gettext-0.21.1
此处发现前面gawk工具没有安装,在宿主系统下用root重新安装部署6.9. Gawk-5.2.1。注意检查:echo $LFS环境变量. /mnt/lfs,