LFS-IV-构建LFS系统

IV 构建LFS系统

第8章 构建LFS系统

Man-page-5.13

1
2
3
4
5
6
7
8
tar -xvf man-pages-5.13.tar.xz
cd man-pages-5.13

make prefix=/usr install

cd ..
rm -rf man-pages-5.13

Iana-Etc-20210611

1
2
3
4
5
6
7
8
tar -xvf iana-etc-20210611.tar.gz
cd iana-etc-20210611

cp services protocols /etc

cd ..
rm -rf iana-etc-20210611

Glibc-2.34

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tar -xvf glibc-2.34.tar.xz
cd glibc-2.34

sed -e '/NOTIFY_REMOVED)/s/)/ \&\& data.attr != NULL)/' \
-i sysdeps/unix/sysv/linux/mq_notify.c

patch -Np1 -i ../glibc-2.34-fhs-1.patch

mkdir -v build
cd build

echo "rootsbindir=/usr/sbin" > configparms

time { ../configure --prefix=/usr \
--disable-werror \
--enable-kernel=3.2 \
--enable-stack-protector=strong \
--with-headers=/usr/include \
libc_cv_slibdir=/usr/lib && make && make check;}

UNSUPPORTED: elf/tst-audit10
UNSUPPORTED: elf/tst-avx512
FAIL: elf/tst-cpu-features-cpuinfo
FAIL: elf/tst-cpu-features-cpuinfo-static
UNSUPPORTED: elf/tst-dlopen-self-container
UNSUPPORTED: elf/tst-dlopen-tlsmodid-container
UNSUPPORTED: elf/tst-env-setuid
UNSUPPORTED: elf/tst-env-setuid-tunables
UNSUPPORTED: elf/tst-glibc-hwcaps-2-cache
UNSUPPORTED: elf/tst-glibc-hwcaps-cache
UNSUPPORTED: elf/tst-glibc-hwcaps-prepend-cache
UNSUPPORTED: elf/tst-ldconfig-bad-aux-cache
UNSUPPORTED: elf/tst-ldconfig-ld_so_conf-update
UNSUPPORTED: elf/tst-pldd
UNSUPPORTED: elf/tst-preload-pthread-libc
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: grp/tst-initgroups1
UNSUPPORTED: grp/tst-initgroups2
FAIL: io/tst-lchmod
UNSUPPORTED: locale/tst-localedef-path-norm
UNSUPPORTED: localedata/tst-localedef-hardlinks
UNSUPPORTED: math/test-double-libmvec-sincos-avx512
UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
UNSUPPORTED: misc/tst-adjtimex
UNSUPPORTED: misc/tst-clock_adjtime
UNSUPPORTED: misc/tst-close_range
UNSUPPORTED: misc/tst-ntp_adjtime
UNSUPPORTED: misc/tst-pkey
FAIL: misc/tst-ttyname
UNSUPPORTED: nptl/test-cond-printers
UNSUPPORTED: nptl/test-condattr-printers
UNSUPPORTED: nptl/test-mutex-printers
UNSUPPORTED: nptl/test-mutexattr-printers
UNSUPPORTED: nptl/test-rwlock-printers
UNSUPPORTED: nptl/test-rwlockattr-printers
FAIL: nptl/tst-mutex10
UNSUPPORTED: nptl/tst-pthread-gdb-attach
UNSUPPORTED: nptl/tst-pthread-gdb-attach-static
UNSUPPORTED: nptl/tst-pthread-getattr
UNSUPPORTED: nss/tst-nss-compat1
UNSUPPORTED: nss/tst-nss-db-endgrent
UNSUPPORTED: nss/tst-nss-db-endpwent
UNSUPPORTED: nss/tst-nss-files-hosts-long
UNSUPPORTED: nss/tst-nss-test3
UNSUPPORTED: nss/tst-reload1
UNSUPPORTED: nss/tst-reload2
UNSUPPORTED: posix/bug-ga2
UNSUPPORTED: posix/bug-ga2-mem
UNSUPPORTED: posix/tst-vfork3
UNSUPPORTED: posix/tst-vfork3-mem
UNSUPPORTED: resolv/mtrace-tst-leaks2
UNSUPPORTED: resolv/tst-leaks2
UNSUPPORTED: resolv/tst-resolv-ai_idn
UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
FAIL: stdlib/test-bz22786
UNSUPPORTED: stdlib/tst-secure-getenv
UNSUPPORTED: stdlib/tst-system
UNSUPPORTED: string/tst-memchr-rtm
UNSUPPORTED: string/tst-memcmp-rtm
UNSUPPORTED: string/tst-memmove-rtm
UNSUPPORTED: string/tst-memrchr-rtm
UNSUPPORTED: string/tst-memset-rtm
UNSUPPORTED: string/tst-strchr-rtm
UNSUPPORTED: string/tst-strcpy-rtm
UNSUPPORTED: string/tst-strerror
UNSUPPORTED: string/tst-strlen-rtm
UNSUPPORTED: string/tst-strncmp-rtm
UNSUPPORTED: string/tst-strrchr-rtm
UNSUPPORTED: string/tst-strsignal
UNSUPPORTED: time/tst-clock_settime
UNSUPPORTED: time/tst-settimeofday
Summary of test results:
6 FAIL
4400 PASS
64 UNSUPPORTED
16 XFAIL
2 XPASS

报错可以选择无视

备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
touch /etc/ld.so.conf

sed '/test-installation/s@$(PERL)@echo not running@' -i ../Makefile

make install

sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd

cp -v ../nscd/nscd.conf /etc/nscd.conf
mkdir -pv /var/cache/nscd

install -v -Dm644 ../nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
install -v -Dm644 ../nscd/nscd.service /usr/lib/systemd/system/nscd.service

mkdir -pv /usr/lib/locale
localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
localedef -i de_DE -f ISO-8859-1 de_DE
localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
localedef -i de_DE -f UTF-8 de_DE.UTF-8
localedef -i el_GR -f ISO-8859-7 el_GR
localedef -i en_GB -f ISO-8859-1 en_GB
localedef -i en_GB -f UTF-8 en_GB.UTF-8
localedef -i en_HK -f ISO-8859-1 en_HK
localedef -i en_PH -f ISO-8859-1 en_PH
localedef -i en_US -f ISO-8859-1 en_US
localedef -i en_US -f UTF-8 en_US.UTF-8
localedef -i es_ES -f ISO-8859-15 es_ES@euro
localedef -i es_MX -f ISO-8859-1 es_MX
localedef -i fa_IR -f UTF-8 fa_IR
localedef -i fr_FR -f ISO-8859-1 fr_FR
localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
localedef -i is_IS -f ISO-8859-1 is_IS
localedef -i is_IS -f UTF-8 is_IS.UTF-8
localedef -i it_IT -f ISO-8859-1 it_IT
localedef -i it_IT -f ISO-8859-15 it_IT@euro
localedef -i it_IT -f UTF-8 it_IT.UTF-8
localedef -i ja_JP -f EUC-JP ja_JP
localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true
localedef -i ja_JP -f UTF-8 ja_JP.UTF-8
localedef -i nl_NL@euro -f ISO-8859-15 nl_NL@euro
localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
localedef -i se_NO -f UTF-8 se_NO.UTF-8
localedef -i ta_IN -f UTF-8 ta_IN.UTF-8
localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
localedef -i zh_CN -f GB18030 zh_CN.GB18030
localedef -i zh_HK -f BIG5-HKSCS zh_HK.BIG5-HKSCS
localedef -i zh_TW -f UTF-8 zh_TW.UTF-8

make localedata/install-locales

localedef -i POSIX -f UTF-8 C.UTF-8 2> /dev/null || true
localedef -i ja_JP -f SHIFT_JIS ja_JP.SIJS 2> /dev/null || true

cat > /etc/nsswitch.conf << "EOF"
# Begin /etc/nsswitch.conf
passwd: files
group: files
shadow: files

hosts: files dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

# End /etc/nsswitch.conf
EOF

tar -xf ../../tzdata2021a.tar.gz

ZONEINFO=/usr/share/zoneinfo
mkdir -pv $ZONEINFO/{posix,right}

for tz in etcetera southamerica northamerica europe africa antarctica \
asia australasia backward; do
zic -L /dev/null -d $ZONEINFO ${tz}
zic -L /dev/null -d $ZONEINFO/posix ${tz}
zic -L leapseconds -d $ZONEINFO/right ${tz}
done

cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
zic -d $ZONEINFO -p America/New_York
unset ZONEINFO

cat > /etc/ld.so.conf << "EOF"
# Begin /etc/ld.so.conf
/usr/local/lib
/opt/lib
EOF

cat >> /etc/ld.so.conf << "EOF"
# Add an include directory
include /etc/ld.so.conf.d/*.conf

EOF
mkdir -pv /etc/ld.so.conf.d

cd ../..
rm -rf glibc-2.34

报错:bison too old

解决:重新编译了一遍bison

Zlib-1.2.11

1
2
3
4
5
6
7
8
9
10
tar -xvf zlib-1.2.11.tar.xz
cd zlib-1.2.11

time { ./configure --prefix=/usr && make && make check && make install;}

rm -fv /usr/lib/libz.a

cd ..
rm -rf zlib-1.2.11

Bzip2-1.0.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
tar -xvf bzip2-1.0.8.tar.gz
cd bzip2-1.0.8

patch -Np1 -i ../bzip2-1.0.8-install_docs-1.patch

sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile
sed -i "s@(PREFIX)/man@(PREFIX)/share/man@g" Makefile

make -f Makefile-libbz2_so
make clean

make

make PREFIX=/usr install

cp -av libbz2.so.* /usr/lib
ln -sv libbz2.so.1.0.8 /usr/lib/libbz2.so

cp -v bzip2-shared /usr/bin/bzip2
for i in /usr/bin/{bzcat,bunzip2}; do
ln -sfv bzip2 $i
done

rm -fv /usr/lib/libbz2.a

cd ..
rm -rf bzip2-1.0.8

Xz-5.2.5

1
2
3
4
5
6
7
8
9
10
tar -xvf xz-5.2.5.tar.xz
cd xz-5.2.5

time { ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/xz-5.2.5 && make && make check && make install;}

cd ..
rm -rf xz-5.2.5

Zstd-1.5.0

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf zstd-1.5.0.tar.gz
cd zstd-1.5.0

make
make check
make prefix=/usr install

rm -v /usr/lib/libzstd.a

cd ..
rm -rf zstd-1.5.0

File-5.40

1
2
3
4
5
6
7
8
tar -xvf file-5.40.tar.gz
cd file-5.40

time { ./configure --prefix=/usr && make && make check && make install;}

cd ..
rm -rf file-5.40

Readline-8.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tar -xvf readline-8.1.tar.gz
cd readline-8.1

sed -i '/MV.*old/d' Makefile.in
sed -i '/{OLDSUFF}/c:' support/shlib-install

./configure --prefix=/usr \
--disable-static \
--with-curses \
--docdir=/usr/share/doc/readline-8.1

make SHLIB_LIBS="-lncursesw"

make SHLIB_LIBS="-lncursesw" install

install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-8.1

cd ..
rm -rf readline-8.1

M4-1.4.19

1
2
3
4
5
6
7
8
tar -xvf m4-1.4.19.tar.xz
cd m4-1.4.19

time { ./configure --prefix=/usr && make && make check && make install;}

cd ..
rm -rf m4-1.4.19

Bc-5.0.0

1
2
3
4
5
6
7
8
tar -xvf bc-5.0.0.tar.xz
cd bc-5.0.0

time { CC=gcc ./configure --prefix=/usr -G -O3 && make && make test && make install;}

cd ..
rm -rf bc-5.0.0

Flex-2.6.4

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf flex-2.6.4.tar.gz
cd flex-2.6.4

time { ./configure --prefix=/usr \
--docdir=/usr/share/doc/flex-2.6.4 \
--disable-static && make && make check && make install;}

ln -sv flex /usr/bin/lex

cd ..
rm -rf flex-2.6.4

Tcl-8.6.11

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
tar -xvf tcl8.6.11-src.tar.gz
cd tcl8.6.11

tar -xf ../tcl8.6.11-html.tar.gz --strip-components=1

SRCDIR=$(pwd)
cd unix
./configure --prefix=/usr \
--mandir=/usr/share/man \
$([ "$(uname -m)" = x86_64 ] && echo --enable-64bit)

make

sed -e "s|$SRCDIR/unix|/usr/lib|" \
-e "s|$SRCDIR|/usr/include|" \
-i tclConfig.sh
sed -e "s|$SRCDIR/unix/pkgs/tdbc1.1.2|/usr/lib/tdbc1.1.2|" \
-e "s|$SRCDIR/pkgs/tdbc1.1.2/generic|/usr/include|" \
-e "s|$SRCDIR/pkgs/tdbc1.1.2/library|/usr/lib/tcl8.6|" \
-e "s|$SRCDIR/pkgs/tdbc1.1.2|/usr/include|" \
-i pkgs/tdbc1.1.2/tdbcConfig.sh
sed -e "s|$SRCDIR/unix/pkgs/itcl4.2.1|/usr/lib/itcl4.2.1|" \
-e "s|$SRCDIR/pkgs/itcl4.2.1/generic|/usr/include|" \
-e "s|$SRCDIR/pkgs/itcl4.2.1|/usr/include|" \
-i pkgs/itcl4.2.1/itclConfig.sh

unset SRCDIR

make test

make install

chmod -v u+w /usr/lib/libtcl8.6.so

make install-private-headers

ln -sfv tclsh8.6 /usr/bin/tclsh

mv /usr/share/man/man3/{Thread,Tcl_Thread}.3

cd ../..
rm -rf tcl8.6.11

Expect-5.45.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tar -xvf expect5.45.4.tar.gz
cd expect5.45.4

time { ./configure --prefix=/usr \
--with-tcl=/usr/lib \
--enable-shared \
--mandir=/usr/share/man \
--with-tclinclude=/usr/include && make && make test && make install;}

ln -svf expect5.45.4/libexpect5.45.4.so /usr/lib

cd ..
rm -rf expect5.45.4

DejaGNU-1.6.3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
tar -xvf dejagnu-1.6.3.tar.gz
cd dejagnu-1.6.3

mkdir -v build
cd build

../configure --prefix=/usr
makeinfo --html --no-split -o doc/dejagnu.html ../doc/dejagnu.texi
makeinfo --plaintext -o doc/dejagnu.txt ../doc/dejagnu.texi

make install
install -v -dm755 /usr/share/doc/dejagnu-1.6.3
install -v -m644 doc/dejagnu.{html,txt} /usr/share/doc/dejagnu-1.6.3

make check

cd ../..
rm -rf dejagnu-1.6.3

Binutils-2.37

1
2
3
4
5
tar -xvf ./binutils-2.37.tar.xz 
cd binutils-2.37

expect -c "spawn ls"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
patch -Np1 -i ../binutils-2.37-upstream_fix-1.patch

sed -i '63d' etc/texi2pod.pl
find -name \*.1 -delete

mkdir -v build
cd build

../configure --prefix=/usr \
--enable-gold \
--enable-ld=default \
--enable-plugins \
--enable-shared \
--disable-werror \
--enable-64-bit-bfd \
--with-system-zlib

make tooldir=/usr

make -k check

FAIL: Link with zlib compressed debug output 1
FAIL: Link with zlib compressed debug output 2
FAIL: Link with zlib-gnu compressed debug output 1
FAIL: Link with zlib-gabi compressed debug output 1

make[1]: Target ‘check-host’ not remade because of errors.
make[1]: Nothing to be done for ‘check-target’.
make[1]: Leaving directory ‘/sources/binutils-2.37/build’
make: *** [Makefile:2288: do-check] Error 2
make: Target ‘check’ not remade because of errors.

已知四项和 zlib 相关的测试可能失败。

1
2
3
4
5
6
7
make tooldir=/usr install -j1

rm -fv /usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes}.a

cd ../..
rm -rf binutils-2.37

GMP-6.2.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tar xf gmp-6.2.1.tar.xz
cd gmp-6.2.1

./configure --prefix=/usr \
--enable-cxx \
--disable-static \
--docdir=/usr/share/doc/gmp-6.2.1

make
make html
make check 2>&1 | tee gmp-check-log
awk '/# PASS:/{total+=$3} ; END{print total}' gmp-check-log
make install
make install-html

cd ..
rm -rf gmp-6.2.1

MPFR-4.1.0

1
2
3
4
5
6
7
8
9
10
11
tar -xvf mpfr-4.1.0.tar.xz
cd mpfr-4.1.0

time { ./configure --prefix=/usr \
--disable-static \
--enable-thread-safe \
--docdir=/usr/share/doc/mpfr-4.1.0 && make && make html && make check && make install && make install-html;}

cd ..
rm -rf mpfr-4.1.0

MPC-1.2.1

1
2
3
4
5
6
7
8
9
10
tar -xvf mpc-1.2.1.tar.gz
cd mpc-1.2.1

time { ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/mpc-1.2.1 && make && make html && make check && make install && make install-html;}

cd ..
rm -rf mpc-1.2.1

Attr-2.5.1

1
2
3
4
5
6
7
8
9
10
11
12
13
tar -xvf attr-2.5.1.tar.gz
cd attr-2.5.1

time { ./configure --prefix=/usr \
--disable-static \
--sysconfdir=/etc \
--docdir=/usr/share/doc/attr-2.5.1 && make && make check;}

make install

cd ..
rm -rf attr-2.5.1

Acl-2.3.1

1
2
3
4
5
6
7
8
9
10
tar -xvf acl-2.3.1.tar.xz
cd acl-2.3.1

time { ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/acl-2.3.1 && make && make install;}

cd ..
rm -rf acl-2.3.1

Libcap-2.53

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tar -xvf libcap-2.53.tar.xz
cd libcap-2.53

sed -i '/install -m.*STA/d' libcap/Makefile

make prefix=/usr lib=lib
make test
make prefix=/usr lib=lib install

chmod -v 755 /usr/lib/lib{cap,psx}.so.2.53

cd ..
rm -rf libcap-2.53

Shadow-4.9

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
tar -xvf shadow-4.9.tar.xz
cd shadow-4.9

sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \;

sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD SHA512:' \
-e 's:/var/spool/mail:/var/mail:' \
-e '/PATH=/{s@/sbin:@@;s@/bin:@@}' \
-i etc/login.defs

sed -e "224s/rounds/min_rounds/" -i libmisc/salt.c

touch /usr/bin/passwd
./configure --sysconfdir=/etc \
--with-group-name-max-length=32

make

make exec_prefix=/usr install
make -C man install-man
mkdir -p /etc/default
useradd -D --gid 999

cd ..
rm -rf shadow-4.9

GCC-11.2.0

编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
tar -xvf gcc-11.2.0.tar.xz
cd gcc-11.2.0

sed -e '/static.*SIGSTKSZ/d' \
-e 's/return kAltStackSize/return SIGSTKSZ * 4/' \
-i libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp

case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac

mkdir -v build
cd build

../configure --prefix=/usr \
LD=ld \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
--with-system-zlib

make

以非特权用户身份测试

1
2
3
4
5
6
7
ulimit -s 32768

chown -Rv tester .
su tester -c "PATH=$PATH make -k check"

../contrib/test_summary

cat <<‘EOF’ |
LAST_UPDATED: Obtained from git: releases/gcc-11.2.0 revision 7ca388565af176bd4efd4f8db1e5e9e11e98ef45

Native configuration is x86_64-pc-linux-gnu

  === g++ tests ===

Running target unix
FAIL: g++.dg/asan/asan_test.C -O2 (test for excess errors)
UNRESOLVED: g++.dg/asan/asan_test.C -O2 compilation failed to produce executable
WARNING: program timed out
FAIL: g++.dg/gcov/pr16855.C -std=gnu2a (test for excess errors)
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a execution test
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 15: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 22: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 24: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 38: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 44: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu2a line 49: is #####:should be 1
FAIL: g
.dg/gcov/pr16855.C -std=gnu++2a gcov: 6 failures in line counts, 0 in branch percentages, 0 in return percentages, 0 in intermediate format

  === g++ Summary ===

of expected passes 207320

of unexpected failures 10

of expected failures 1073

of unresolved testcases 1

of unsupported tests 9048

/sources/gcc-11.2.0/build/gcc/xg++ version 11.2.0 (GCC)

  === gcc tests ===

Running target unix
FAIL: gcc.dg/analyzer/analyzer-verbosity-2a.c (test for excess errors)
FAIL: gcc.dg/analyzer/analyzer-verbosity-3a.c (test for excess errors)
FAIL: gcc.dg/analyzer/edges-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-2.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-paths-1.c (test for excess errors)
FAIL: gcc.dg/analyzer/file-pr58237.c (test for excess errors)
FAIL: gcc.dg/analyzer/pr99716-1.c (test for excess errors)

  === gcc Summary ===

of expected passes 160265

of unexpected failures 8

of expected failures 854

of unsupported tests 2393

/sources/gcc-11.2.0/build/gcc/xgcc version 11.2.0 (GCC)

  === libatomic tests ===

Running target unix

  === libatomic Summary ===

of expected passes 54

  === libgomp tests ===

Running target unix

  === libgomp Summary ===

of expected passes 2889

of expected failures 4

of unsupported tests 308

  === libitm tests ===

Running target unix

  === libitm Summary ===

of expected passes 44

of expected failures 3

of unsupported tests 1

  === libstdc++ tests ===

Running target unix
FAIL: 17_intro/headers/c++1998/49745.cc (test for excess errors)
FAIL: 22_locale/numpunct/members/char/3.cc execution test
FAIL: 22_locale/time_get/get_time/char/2.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/char/wrapped_locale.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/2.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_env.cc execution test
FAIL: 22_locale/time_get/get_time/wchar_t/wrapped_locale.cc execution test

  === libstdc++ Summary ===

of expected passes 14823

of unexpected failures 8

of expected failures 104

of unsupported tests 352

Compiler version: 11.2.0 (GCC)
Platform: x86_64-pc-linux-gnu
configure flags: --prefix=/usr LD=ld --enable-languages=c,c++ --disable-multilib --disable-bootstrap --with-system-zlib
EOF
Mail -s “Results for 11.2.0 (GCC) testsuite on x86_64-pc-linux-gnu” gcc-testresults@gcc.gnu.org &&
mv /sources/gcc-11.2.0/build/./gcc/testsuite/g++/g++.sum /sources/gcc-11.2.0/build/./gcc/testsuite/g++/g++.sum.sent &&
mv /sources/gcc-11.2.0/build/./gcc/testsuite/gcc/gcc.sum /sources/gcc-11.2.0/build/./gcc/testsuite/gcc/gcc.sum.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.sum.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.sum.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.sum.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libstdc+±v3/testsuite/libstdc++.sum /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libstdc+±v3/testsuite/libstdc++.sum.sent &&
mv /sources/gcc-11.2.0/build/./gcc/testsuite/g++/g++.log /sources/gcc-11.2.0/build/./gcc/testsuite/g++/g++.log.sent &&
mv /sources/gcc-11.2.0/build/./gcc/testsuite/gcc/gcc.log /sources/gcc-11.2.0/build/./gcc/testsuite/gcc/gcc.log.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.log /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libatomic/testsuite/libatomic.log.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.log /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libgomp/testsuite/libgomp.log.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.log /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libitm/testsuite/libitm.log.sent &&
mv /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libstdc+±v3/testsuite/libstdc++.log /sources/gcc-11.2.0/build/./x86_64-pc-linux-gnu/libstdc+±v3/testsuite/libstdc++.log.sent &&
true

install

1
2
3
4
5
6
7
8
9
10
11
make install
rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/11.2.0/include-fixed/bits/

chown -v -R root:root \
/usr/lib/gcc/*linux-gnu/11.2.0/include{,-fixed}

ln -svr /usr/bin/cpp /usr/lib

ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/11.2.0/liblto_plugin.so \
/usr/lib/bfd-plugins/

检查工具链

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
readelf -l a.out | grep ': /lib'

grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log

grep -B4 '^ /usr/include' dummy.log

grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'

grep "/lib.*/libc.so.6 " dummy.log

grep found dummy.log

rm -v dummy.c a.out dummy.log

````

收尾工作

```shell
mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib

cd ../..
rm -rf gcc-11.2.0

Pkg-config-0.29.2

1
2
3
4
5
6
7
8
9
10
11
tar -xvf pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2

time { ./configure --prefix=/usr \
--with-internal-glib \
--disable-host-tool \
--docdir=/usr/share/doc/pkg-config-0.29.2 && make && make check && make install;}

cd ..
rm -rf pkg-config-0.29.2

Ncurses-6.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
tar -xvf ncurses-6.2.tar.gz
cd ncurses-6.2

time { ./configure --prefix=/usr \
--mandir=/usr/share/man \
--with-shared \
--without-debug \
--without-normal \
--enable-pc-files \
--enable-widec && make && make install;}

for lib in ncurses form panel menu ; do
rm -vf /usr/lib/lib${lib}.so
echo "INPUT(-l${lib}w)" > /usr/lib/lib${lib}.so
ln -sfv ${lib}w.pc /usr/lib/pkgconfig/${lib}.pc
done

rm -vf /usr/lib/libcursesw.so
echo "INPUT(-lncursesw)" > /usr/lib/libcursesw.so
ln -sfv libncurses.so /usr/lib/libcurses.so

rm -fv /usr/lib/libncurses++w.a

mkdir -v /usr/share/doc/ncurses-6.2
cp -v -R doc/* /usr/share/doc/ncurses-6.2

cd ..
rm -rf ncurses-6.2

Sed-4.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tar -xvf sed-4.8.tar.xz
cd sed-4.8

./configure --prefix=/usr

make
make html

chown -Rv tester .
su tester -c "PATH=$PATH make check"

make install
install -d -m755 /usr/share/doc/sed-4.8
install -m644 doc/sed.html /usr/share/doc/sed-4.8

cd ..
rm -rf sed-4.8

Psmisc-23.4

1
2
3
4
5
6
7
8
tar -xvf psmisc-23.4.tar.xz
cd psmisc-23.4

time { ./configure --prefix=/usr && make && make install;}

cd ..
rm -rf psmisc-23.4

Gettext-0.21

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf gettext-0.21.tar.xz
cd gettext-0.21

time { ./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/gettext-0.21 && make && make check && make install;}

chmod -v 0755 /usr/lib/preloadable_libintl.so

cd ..
rm -rf gettext-0.21

Bison-3.7.6

1
2
3
4
5
6
7
8
tar -xvf bison-3.7.6.tar.xz
cd bison-3.7.6

time { ./configure --prefix=/usr --docdir=/usr/share/doc/bison-3.7.6 && make && make check && make install;}

cd ..
rm -rf bison-3.7.6

Grep-3.7

1
2
3
4
5
6
7
8
tar -xvf grep-3.7.tar.xz
cd grep-3.7

time { ./configure --prefix=/usr && make && make check && make install;}

cd ..
rm -rf grep-3.7

Bash-5.1.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tar -xvf bash-5.1.8.tar.gz
cd bash-5.1.8

time { ./configure --prefix=/usr \
--docdir=/usr/share/doc/bash-5.1.8 \
--without-bash-malloc \
--with-installed-readline && make;}

chown -Rv tester .

su -s /usr/bin/expect tester << EOF
set timeout -1
spawn make tests
expect eof
lassign [wait] _ _ _ value
exit $value
EOF

make install

exec /bin/bash --login +h

切换shell后会丢失原来复制进去执行的命令队列

1
2
3
cd ..
rm -rf bash-5.1.8

Libtool-2.4.6

1
2
3
4
5
6
7
8
9
10
tar -xvf libtool-2.4.6.tar.xz
cd libtool-2.4.6

time { ./configure --prefix=/usr && make && make check && make install;}

rm -fv /usr/lib/libltdl.a

cd ..
rm -rf libtool-2.4.6

GDBM-1.20

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tar -xvf gdbm-1.20.tar.gz
cd gdbm-1.20

./configure --prefix=/usr \
--disable-static \
--enable-libgdbm-compat

make
make -k check
make install

cd ..
rm -rf gdbm-1.20

Gperf-3.1

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf gperf-3.1.tar.gz
cd gperf-3.1

./configure --prefix=/usr --docdir=/usr/share/doc/gperf-3.1

make
make -j1 check
make install

cd ..
rm -rf gperf-3.1

Expat-2.4.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
tar -xvf expat-2.4.1.tar.xz
cd expat-2.4.1

./configure --prefix=/usr \
--disable-static \
--docdir=/usr/share/doc/expat-2.4.1

make
make check
make install

install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.4.1

cd ..
rm -rf expat-2.4.1

Inetutils-2.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
tar -xvf inetutils-2.1.tar.xz
cd inetutils-2.1

./configure --prefix=/usr \
--bindir=/usr/bin \
--localstatedir=/var \
--disable-logger \
--disable-whois \
--disable-rcp \
--disable-rexec \
--disable-rlogin \
--disable-rsh \
--disable-servers

make
make check
make install

mv -v /usr/{,s}bin/ifconfig

cd ..
rm -rf inetutils-2.1

Less-590

1
2
3
4
5
6
7
8
9
10
11
tar -xvf less-590.tar.gz
cd less-590

./configure --prefix=/usr --sysconfdir=/etc

make
make install

cd ..
rm -rf less-590

Perl-5.34.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
tar -xvf perl-5.34.0.tar.xz
cd perl-5.34.0

patch -Np1 -i ../perl-5.34.0-upstream_fixes-1.patch

export BUILD_ZLIB=False
export BUILD_BZIP2=0

time { 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 \
-Dman1dir=/usr/share/man/man1 \
-Dman3dir=/usr/share/man/man3 \
-Dpager="/usr/bin/less -isR" \
-Duseshrplib \
-Dusethreads && make && make test && make install;}
unset BUILD_ZLIB BUILD_BZIP2

cd ..
rm -rf perl-5.34.0

XML::Parser-2.46

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf XML-Parser-2.46.tar.gz 
cd XML-Parser-2.46

perl Makefile.PL

make
make test
make install

cd ..
rm -rf XML-Parser-2.46

Intltool-0.51.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tar -xvf intltool-0.51.0.tar.gz 
cd intltool-0.51.0

sed -i 's:\\\${:\\\$\\{:' intltool-update.in

./configure --prefix=/usr
make
make check

make install
install -v -Dm644 doc/I18N-HOWTO /usr/share/doc/intltool-0.51.0/I18N-HOWTO

cd ..
rm -rf intltool-0.51.0

Autoconf-2.71

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf autoconf-2.71.tar.xz 
cd autoconf-2.71

./configure --prefix=/usr

make
make check
make install

cd ..
rm -rf autoconf-2.71

Automake-1.16.4

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf automake-1.16.4.tar.xz	
cd automake-1.16.4

./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.16.4

make
make -j4 check
make install

cd ..
rm -rf automake-1.16.4

Kmod-29

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tar -xvf kmod-29.tar.xz
cd kmod-29

./configure --prefix=/usr \
--sysconfdir=/etc \
--with-xz \
--with-zstd \
--with-zlib

make

make install
for target in depmod insmod modinfo modprobe rmmod; do
ln -sfv ../bin/kmod /usr/sbin/$target
done
ln -sfv kmod /usr/bin/lsmod

cd ..
rm -rf kmod-29

Libelf from Elfutils-0.185

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
tar -xvf elfutils-0.185.tar.bz2	
cd elfutils-0.185

./configure --prefix=/usr \
--disable-debuginfod \
--enable-libdebuginfod=dummy
make
make check
make -C libelf install

install -vm644 config/libelf.pc /usr/lib/pkgconfig
rm /usr/lib/libelf.a

cd ..
rm -rf elfutils-0.185

报错:

FAIL: run-backtrace-native.sh

configure:

    elfutils: 0.185 (eu_version: 185)

=====================================================================

Prefix                             : /usr
Program prefix ("eu-" recommended) : eu-
Source code location               : .
Maintainer mode                    : 
build arch                         : x86_64-pc-linux-gnu

RECOMMENDED FEATURES (should all be yes)
gzip support : yes
bzip2 support : yes
lzma/xz support : yes
zstd support : yes
libstdc++ demangle support : yes
File textrel check : yes
Symbol versioning : yes

NOT RECOMMENDED FEATURES (should all be no)
Experimental thread safety : no
install elf.h : no

OTHER FEATURES
Deterministic archives by default : false
Native language support : yes
Extra Valgrind annotations : no
libdebuginfod client support : dummy
Debuginfod server support : no
Default DEBUGINFOD_URLS :

EXTRA TEST FEATURES (used with make check)
have bunzip2 installed (required) : yes
have zstd installed : yes
debug branch prediction : no
gprof support : no
gcov support : no
run all tests under valgrind : no
gcc undefined behaviour sanitizer : no
use rpath in tests : no
test biarch : no

============================================================================
Testsuite summary for elfutils 0.185

TOTAL: 226

PASS: 220

SKIP: 5

XFAIL: 0

FAIL: 1

XPASS: 0

ERROR: 0

============================================================================
See tests/test-suite.log

Please report to https://sourceware.org/bugzilla

解决方法:忽视,直接跳过,已有人向官方提交该bug,该bug在0.186版本得到解决。

Libffi-3.4.2

1
2
3
4
5
6
7
8
9
10
11
tar -xvf libffi-3.4.2.tar.gz
cd libffi-3.4.2

time { ./configure --prefix=/usr \
--disable-static \
--with-gcc-arch=native \
--disable-exec-static-tramp && make && make check && make install;}

cd ..
rm -rf libffi-3.4.2

OpenSSL-1.1.1l

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tar -xvf openssl-1.1.1l.tar.gz
cd openssl-1.1.1l

time { ./config --prefix=/usr \
--openssldir=/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic && make && make test;}

sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile
make MANSUFFIX=ssl install

mv -v /usr/share/doc/openssl /usr/share/doc/openssl-1.1.1l
cp -vfr doc/* /usr/share/doc/openssl-1.1.1l

cd ..
rm -rf openssl-1.1.1l

Python-3.9.6

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tar -xvf Python-3.9.6.tar.xz
cd Python-3.9.6

time { ./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-ensurepip=yes \
--enable-optimizations && make && make install;}

install -v -dm755 /usr/share/doc/python-3.9.6/html
tar --strip-components=1 \
--no-same-owner \
--no-same-permissions \
-C /usr/share/doc/python-3.9.6/html \
-xvf ../python-3.9.6-docs-html.tar.bz2

cd ..
rm -rf Python-3.9.6

Ninja-1.10.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tar -xvf ninja-1.10.2.tar.gz
cd ninja-1.10.2

export NINJAJOBS=4

sed -i '/int Guess/a \
int j = 0;\
char* jobs = getenv( "NINJAJOBS" );\
if ( jobs != NULL ) j = atoi( jobs );\
if ( j > 0 ) return j;\
' src/ninja.cc

python3 configure.py --bootstrap

./ninja ninja_test
./ninja_test --gtest_filter=-SubprocessTest.SetWithLots

install -vm755 ninja /usr/bin/
install -vDm644 misc/bash-completion /usr/share/bash-completion/completions/ninja
install -vDm644 misc/zsh-completion /usr/share/zsh/site-functions/_ninja

cd ..
rm -rf ninja-1.10.2

Meson-0.59.1

1
2
3
4
5
6
7
8
9
10
11
12
13
tar -xvf meson-0.59.1.tar.gz
cd meson-0.59.1

python3 setup.py build

python3 setup.py install --root=dest
cp -rv dest/* /
install -vDm644 data/shell-completions/bash/meson /usr/share/bash-completion/completions/meson
install -vDm644 data/shell-completions/zsh/_meson /usr/share/zsh/site-functions/_meson

cd ..
rm -rf meson-0.59.1

Coreutils-8.32

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tar -xvf coreutils-8.32.tar.xz
cd coreutils-8.32

patch -Np1 -i ../coreutils-8.32-i18n-1.patch

autoreconf -fiv
FORCE_UNSAFE_CONFIGURE=1 ./configure \
--prefix=/usr \
--enable-no-install-program=kill,uptime

make
make NON_ROOT_USERNAME=tester check-root
echo "dummy:x:102:tester" >> /etc/group

1
2
3
chown -Rv tester .
su tester -c "PATH=$PATH make RUN_EXPENSIVE_TESTS=yes check"

1
2
3
4
5
6
7
8
9
sed -i '/dummy/d' /etc/group
make install
mv -v /usr/bin/chroot /usr/sbin
mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8
sed -i 's/"1"/"8"/' /usr/share/man/man8/chroot.8

cd ..
rm -rf coreutils-8.32

Check-0.15.2

1
2
3
4
5
6
7
8
tar -xvf check-0.15.2.tar.gz
cd check-0.15.2

time { ./configure --prefix=/usr --disable-static && make && make check && make docdir=/usr/share/doc/check-0.15.2 install;}

cd ..
rm -rf check-0.15.2

Diffutils-3.8

1
2
3
4
5
6
7
8
tar -xvf diffutils-3.8.tar.xz
cd diffutils-3.8

time { ./configure --prefix=/usr && make && make check && make install;}

cd ..
rm -rf diffutils-3.8

Gawk-5.1.0

1
2
3
4
5
6
7
8
9
10
11
12
13
tar -xvf gawk-5.1.0.tar.xz
cd gawk-5.1.0

sed -i 's/extras//' Makefile.in

time { ./configure --prefix=/usr && make && make check && make install;}

mkdir -v /usr/share/doc/gawk-5.1.0
cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-5.1.0

cd ..
rm -rf gawk-5.1.0

Findutils-4.8.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tar -xvf findutils-4.8.0.tar.xz
cd findutils-4.8.0

./configure --prefix=/usr --localstatedir=/var/lib/locate

make

chown -Rv tester .
su tester -c "PATH=$PATH make check"

make install

cd ..
rm -rf findutils-4.8.0

Groff-1.22.4

1
2
3
4
5
6
7
8
9
10
tar -xvf groff-1.22.4.tar.gz
cd groff-1.22.4

PAGE=A4 ./configure --prefix=/usr
make -j1
make install

cd ..
rm -rf groff-1.22.4

应将configure中环境变量PAGE的值<page_size>指定为A4

GRUB-2.06

1
2
3
4
5
6
7
8
9
10
11
12
13
tar -xvf grub-2.06.tar.xz
cd grub-2.06

time { ./configure --prefix=/usr \
--sysconfdir=/etc \
--disable-efiemu \
--disable-werror && make && make install;}

mv -v /etc/bash_completion.d/grub /usr/share/bash-completion/completions

cd ..
rm -rf grub-2.06

Gzip-1.10

1
2
3
4
5
6
7
8
9
10
11
tar -xvf gzip-1.10.tar.xz
cd gzip-1.10

./configure --prefix=/usr
make
make check
make install

cd ..
rm -rf gzip-1.10

IPRoute2-5.13.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tar -xvf iproute2-5.13.0.tar.xz
cd iproute2-5.13.0

sed -i /ARPD/d Makefile
rm -fv man/man8/arpd.8

sed -i 's/.m_ipt.o//' tc/Makefile

make

make SBINDIR=/usr/sbin install

mkdir -v /usr/share/doc/iproute2-5.13.0
cp -v COPYING README* /usr/share/doc/iproute2-5.13.0

cd ..
rm -rf iproute2-5.13.0

Kbd-2.4.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tar -xvf kbd-2.4.0.tar.xz
cd kbd-2.4.0

patch -Np1 -i ../kbd-2.4.0-backspace-1.patch

sed -i '/RESIZECONS_PROGS=/s/yes/no/' configure
sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in

./configure --prefix=/usr --disable-vlock

make
make check
make install

mkdir -v /usr/share/doc/kbd-2.4.0
cp -R -v docs/doc/* /usr/share/doc/kbd-2.4.0

cd ..
rm -rf kbd-2.4.0

Libpipeline-1.5.3

1
2
3
4
5
6
7
8
9
10
11
tar -xvf libpipeline-1.5.3.tar.gz
cd libpipeline-1.5.3

./configure --prefix=/usr
make
make check
make install

cd ..
rm -rf libpipeline-1.5.3

Make-4.3

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf make-4.3.tar.gz
cd make-4.3

./configure --prefix=/usr

make
make check
make install

cd ..
rm -rf make-4.3

Patch-2.7.6

1
2
3
4
5
6
7
8
9
10
11
12
tar -xvf patch-2.7.6.tar.xz
cd patch-2.7.6

./configure --prefix=/usr

make
make check
make install

cd ..
rm -rf patch-2.7.6

Tar-1.34

1
2
3
4
5
6
7
8
9
10
11
tar -xvf tar-1.34.tar.xz
cd tar-1.34

time { FORCE_UNSAFE_CONFIGURE=1 \
./configure --prefix=/usr && make && make check && make install;}

make -C doc install-html docdir=/usr/share/doc/tar-1.34

cd ..
rm -rf tar-1.34

Texinfo-6.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tar -xvf texinfo-6.8.tar.xz
cd texinfo-6.8

./configure --prefix=/usr

sed -e 's/__attribute_nonnull__/__nonnull/' \
-i gnulib/lib/malloc/dynarray-skeleton.c

make
make check
make install

make TEXMF=/usr/share/texmf install-tex

pushd /usr/share/info
rm -v dir
for f in *
do install-info $f dir 2>/dev/null
done
popd

cd ..
rm -rf texinfo-6.8

Vim-8.2.3337

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
tar -xvf vim-8.2.3337.tar.gz
cd vim-8.2.3337

echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >> src/feature.h

./configure --prefix=/usr

make

chown -Rv tester .
su tester -c "LANG=en_US.UTF-8 make -j1 test" &> vim-test.log

make install
ln -sv vim /usr/bin/vi
for L in /usr/share/man/{,*/}man1/vim.1; do
ln -sv vim.1 $(dirname $L)/vi.1
done

ln -sv ../vim/vim82/doc /usr/share/doc/vim-8.2.3337

cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
" Ensure defaults are set before customizing settings, not after
source $VIMRUNTIME/defaults.vim
let skip_defaults_vim=1
set nocompatible
set backspace=2
set mouse=
syntax on
if (&term == "xterm") || (&term == "putty")
set background=dark
endif
" End /etc/vimrc
EOF

vim -c ':options'

cd ..
rm -rf vim-8.2.3337

Eudev-3.2.10

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
tar -xvf eudev-3.2.10.tar.gz
cd eudev-3.2.10

./configure --prefix=/usr \
--bindir=/usr/sbin \
--sysconfdir=/etc \
--enable-manpages \
--disable-stati

make

mkdir -pv /usr/lib/udev/rules.d
mkdir -pv /etc/udev/rules.d

make check
make install

tar -xvf ../udev-lfs-20171102.tar.xz
make -f udev-lfs-20171102/Makefile.lfs install

udevadm hwdb --update

cd ..
rm -rf eudev-3.2.10

Man-DB-2.9.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tar -xvf man-db-2.9.4.tar.xz
cd man-db-2.9.4

./configure --prefix=/usr \
--docdir=/usr/share/doc/man-db-2.9.4 \
--sysconfdir=/etc \
--disable-setuid \
--enable-cache-owner=bin \
--with-browser=/usr/bin/lynx \
--with-vgrind=/usr/bin/vgrind \
--with-grap=/usr/bin/grap \
--with-systemdtmpfilesdir= \
--with-systemdsystemunitdir=

make
make check
make install

cd ..
rm -rf man-db-2.9.4

Procps-ng-3.3.17

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tar -xvf procps-ng-3.3.17.tar.xz
cd procps-3.3.17

./configure --prefix=/usr \
--docdir=/usr/share/doc/procps-ng-3.3.17 \
--disable-static \
--disable-kill

make
make check
make install

cd ..
rm -rf procps-3.3.17

Util-linux-2.37.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
tar -xvf util-linux-2.37.2.tar.xz
cd util-linux-2.37.2

./configure ADJTIME_PATH=/var/lib/hwclock/adjtime \
--libdir=/usr/lib \
--docdir=/usr/share/doc/util-linux-2.37.2 \
--disable-chfn-chsh \
--disable-login \
--disable-nologin \
--disable-su \
--disable-setpriv \
--disable-runuser \
--disable-pylibmount \
--disable-static \
--without-python \
--without-systemd \
--without-systemdsystemunitdir \
runstatedir=/run

make

rm tests/ts/lsns/ioctl_ns
chown -Rv tester .
su tester -c "make -k check"

make install

cd ..
rm -rf util-linux-2.37.2

E2fsprogs-1.46.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
tar -xvf e2fsprogs-1.46.4.tar.gz
cd e2fsprogs-1.46.4

mkdir -v build
cd build

time { ../configure --prefix=/usr \
--sysconfdir=/etc \
--enable-elf-shlibs \
--disable-libblkid \
--disable-libuuid \
--disable-uuidd \
--disable-fsck && make && make check && make install;}

rm -fv /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a

gunzip -v /usr/share/info/libext2fs.info.gz
install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info

makeinfo -o doc/com_err.info ../lib/et/com_err.texinfo
install -v -m644 doc/com_err.info /usr/share/info
install-info --dir-file=/usr/share/info/dir /usr/share/info/com_err.info

cd ../..
rm -rf e2fsprogs-1.46.4

Sysklogd-1.5.1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tar -xvf sysklogd-1.5.1.tar.gz
cd sysklogd-1.5.1

sed -i '/Error loading kernel symbols/{n;n;d}' ksym_mod.c
sed -i 's/union wait/int/' syslogd.c

make
make BINDIR=/sbin install

cat > /etc/syslog.conf << "EOF"
# Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
*.*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
*.emerg *
# End /etc/syslog.conf
EOF

cd ..
rm -rf sysklogd-1.5.1

Sysvinit-2.99

1
2
3
4
5
6
7
8
9
10
11
tar -xvf sysvinit-2.99.tar.xz
cd sysvinit-2.99

patch -Np1 -i ../sysvinit-2.99-consolidated-1.patch

make
make install

cd ..
rm -rf sysvinit-2.99

剥离/移除调试符号

本节可选。

默认情况下,大多数程序和库都包含调试符号(使用gcc的*-g*选项)进行编译。这意味着在调试使用调试信息编译的程序或库时,调试器不仅可以提供内存地址,还可以提供例程和变量的名称。

但是,包含这些调试符号会显着扩大程序或库。以下是这些符号占用空间量的示例:

  • 一个bash的二进制与调试符号:1200 KB
  • 一个bash的二进制不带调试符号:480 KB
  • 带有调试符号的 Glibc 和 GCC 文件(/lib/usr/lib):87 MB
  • 不带调试符号的 Glibc 和 GCC 文件:16 MB

大小可能因使用的编译器和 C 库而异,但在比较有和没有调试符号的程序时,差异通常是 2 到 5 之间的一个因素。

因为大多数用户永远不会在他们的系统软件上使用调试器,所以通过删除这些符号可以重新获得大量磁盘空间。下一节将展示如何从程序和库中去除所有调试符号。

大多数使用以下命令的用户不会遇到什么困难。但是,如果打错了命令,很容易导致新系统无法使用,因此在运行 strip 命令前,最好备份 LFS 系统的当前状态。

一些库的调试符号需要保存在单独的文件中。之后在 BLFS 中,如果使用 valgrind 或 gdb 运行退化测试,则需要这些调试信息的存在。

需要注意的是,strip 命令会覆盖它正在处理的二进制程序或库文件。这可能导致正在使用该文件中代码或数据的进程崩溃。如果运行 strip 本身的进程受到影响,则可能导致正在被处理的程序或库完全损坏。这可能导致系统完全不可用。为了避免这种情况,将一些库和程序复制到 /tmp 中,在那里移除调试符号,再使用 install 命令将它们安装回原位置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
save_usrlib="$(cd /usr/lib; ls ld-linux*)
libc.so.6
libthread_db.so.1
libquadmath.so.0.0.0
libstdc++.so.6.0.29
libitm.so.1.0.0
libatomic.so.1.2.0"

cd /usr/lib

for LIB in $save_usrlib; do
objcopy --only-keep-debug $LIB $LIB.dbg
cp $LIB /tmp/$LIB
strip --strip-unneeded /tmp/$LIB
objcopy --add-gnu-debuglink=$LIB.dbg /tmp/$LIB
install -vm755 /tmp/$LIB /usr/lib
rm /tmp/$LIB
done

online_usrbin="bash find strip"
online_usrlib="libbfd-2.37.so
libhistory.so.8.1
libncursesw.so.6.2
libm.so.6
libreadline.so.8.1
libz.so.1.2.11
$(cd /usr/lib; find libnss*.so* -type f)"

for BIN in $online_usrbin; do
cp /usr/bin/$BIN /tmp/$BIN
strip --strip-unneeded /tmp/$BIN
install -vm755 /tmp/$BIN /usr/bin
rm /tmp/$BIN
done

for LIB in $online_usrlib; do
cp /usr/lib/$LIB /tmp/$LIB
strip --strip-unneeded /tmp/$LIB
install -vm755 /tmp/$LIB /usr/lib
rm /tmp/$LIB
done

for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \
$(find /usr/lib -type f -name \*.a) \
$(find /usr/{bin,sbin,libexec} -type f); do
case "$online_usrbin $online_usrlib $save_usrlib" in
*$(basename $i)* )
;;
* ) strip --strip-unneeded $i
;;
esac
done

unset BIN LIB save_usrlib online_usrbin online_usrlib

清理系统

清理一些在执行过程中遗留的一些文件。

现在需要登出,并使用新的chroot命令重新进入chroot环境。

这里不再使用 +h 选项,因为所有之前安装的程序都已经替换成了最终版本,可以进行散列。

如果解除了虚拟内核文件系统的挂载,必须通过手动或重启系统的方式重新挂载它们,保证在进入 chroot 时它们已经挂载好。第 7.3.2 节 “挂载和填充 /dev”和第 7.3.3 节 “挂载虚拟内核文件系统”已经说明了这一过程。

在 /usr/lib 和 /usr/libexec 目录中还有一些扩展名为 .la 的文件。它们是 “libtool 档案” 文件。正如我们已经讨论过的,它们在链接到共享库,特别是使用 autotools 以外的构建系统时,是不必要,甚至有害的。执行以下命令删除它们:

上文中构建的编译器仍然有一部分安装在系统上,它现在已经没有存在的意义了。执行命令删除它:

最后,移除上文开始时创建的临时 ‘tester’ 用户账户。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
rm -rf /tmp/*

logout
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
/bin/bash --login

find /usr/lib /usr/libexec -name \*.la -delete

find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf

userdel -r tester

重启后恢复工作状态 #3

从现在开始,在退出并重新进入chroot环境时,要使用以下修改过的chroot命令.

如果解除了虚拟内核文件系统的挂载,必须通过手动或重启系统的方式重新挂载它们,保证在进入 chroot 时它们已经挂载好。第 7.3.2 节 “挂载和填充 /dev”和第 7.3.3 节 “挂载虚拟内核文件系统”已经说明了这一过程。

1
2
3
4
5
chroot "$LFS" /usr/bin/env -i          \
HOME=/root TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
/bin/bash --login