Building Linux From Scratch on a Google Cloud Virtual Machine
Part 3: Building and Installing System Packages
This is a continuation of Part 2
References are made to LFS Version 9.1-systemd using the format LFS x.x.x… for specific sections. Command blocks are largely copied verbatim with minor customizations for this setup.
This part of the tutorial will comprise notes on system setup and annotations for each build step for the temporary system in LFS 6. The annotations will be more limited than in Part 2 only noting parts that did not work as expected when following the directions in LFS.
Brace yourselves. This part is grueling. Even with an 8 cpu machine, the sequence of builds still takes a while. But for me it was still a great learning experience. I took the time to understand the role of the tools I was installing and ended up learning about a dozen or so utilities I didn’t know about that will definitely be helpful in the future. I’m really excited for the next part when we get to build and install the Linux kernel.
I split the steps it over a few afternoons with plenty of tea and music. The playlist from ChilledCow below served as an excellent backdrop.
Here we go (deep breath).
Switch user to root.
All of the operations in LFS 6 must be done as root. This command is helpful.
sudo -i
Prepare the kernel file systems.
Operations in 6.2 worked OK out of the box.
Enter the chroot environment.
Operations in 6.4 worked OK out of the box. Don’t worry about the “I have no name!” message.
File system creation.
Operations in 6.5 and 6.6 worked OK out of the box.
Installing Packages
No annotations indicate that the build and installation worked without any trouble just by following LFS directions.
Remember to untar the source file and cd into the directory before issuing any commands.
Glibc
The patch must be applied from within the glibc source directory.
Here is my output from make check
:
UNSUPPORTED: elf/tst-audit10
UNSUPPORTED: elf/tst-avx512
UNSUPPORTED: elf/tst-dlopen-self-container
UNSUPPORTED: elf/tst-dlopen-tlsmodid-container
UNSUPPORTED: elf/tst-ldconfig-bad-aux-cache
UNSUPPORTED: elf/tst-ldconfig-ld_so_conf-update
UNSUPPORTED: elf/tst-pldd
XPASS: elf/tst-protected1a
XPASS: elf/tst-protected1b
UNSUPPORTED: math/test-double-libmvec-sincos-avx512
UNSUPPORTED: math/test-float-libmvec-sincosf-avx512
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
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: resolv/tst-resolv-ai_idn
UNSUPPORTED: resolv/tst-resolv-ai_idn-latin1
Summary of test results:
1 FAIL
5177 PASS
22 UNSUPPORTED
17 XFAIL
2 XPASS
make[1]: *** [Makefile:630: tests] Error 1
make[1]: Leaving directory '/sources/glibc-2.31'
make: *** [Makefile:9: check] Error 2
There is 1 fail, misc/tst-ttyname, which LFS notes will fail. Other than that, we look good!
LFS 6.10 contains directions to finalize setup of Glibc. There are many steps to ensure proper setup. My installation passed all of the sanity checks.
Binutils
All tests expected to pass passed.
GMP
I changed default optimizations in case I want to run on a less capable CPU.
All tests passed. Note that LFS specifies 190 tests. I encountered 197.
GCC
Here is the summary of my test results:
=== g++ Summary ===# of expected passes 134787
# of expected failures 527
# of unsupported tests 5921
/sources/gcc-9.2.0/build/gcc/xg++ version 9.2.0 (GCC)=== gcc tests ===
--
=== gcc Summary ===# of expected passes 139439
# of unexpected failures 2
# of expected failures 527
# of unsupported tests 2151
/sources/gcc-9.2.0/build/gcc/xgcc version 9.2.0 (GCC)--
=== libatomic Summary ===# of expected passes 54
=== libgomp tests ===Running target unix=== libgomp Summary ===# of expected passes 2316
# of expected failures 2
# of unsupported tests 210
=== libitm tests ===--
=== libitm Summary ===# of expected passes 42
# of expected failures 3
# of unsupported tests 1
=== libstdc++ tests ===--
=== libstdc++ Summary ===# of expected passes 12892
# of unexpected failures 8
# of expected failures 78
# of unsupported tests 380Compiler version: 9.2.0 (GCC)
Compared to the test logs provided by LFS, it is a perfect match.
Libtool
If you have multiple cores, use them during test. Otherwise it takes forever.
Libffi
Using generic platform spec for configuration:
./configure --prefix=/usr --disable-static --with-gcc-arch=x86_64
Coreutils
To check if the su PATH environment variable contains /tools/bin:
su nobody -s /bin/bash \
-c "echo $PATH"#should return
/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
My test results (appended -j8 flag to make check):
All of the unmentioned packages compiled and installed without protest.
This concludes Part 3