TITLE: building on multiple cpus LFS VERSION: 3.1 AUTHOR: Adam Greenblatt SYNOPSIS: How to build an lfs system in less time on an SMP machine. HINT: GNU make can build multiple targets in parallel using the -j switch. If your machine has more than one cpu, you can cut your build time dramatically by changing some of the make commands shown in the book to use -j. On my dual CPU system, using this hint decreases the total build time from about 95 minutes to about 64 minutes. A few packages fail to build using multiple cpus: their makefiles contain implicit dependencies that force them to build serially. (Arguably, this is a bug in those packages.) A couple other packages, notably glibc and the X window system, use other makefile trickery in place of -j. [Note: Parallel builds of the X window system are currently broken. If anyone manages to fix them, please let me know and I'll include the information here.] Here is a step by step description of the changes needed from version 3.1 of the LFS book. Similar changes will probably work fine on other versions of the book, but your mileage may vary. Chapter 2. Important information _________________________________________________________________ Insert the following paragraph after the "About $LFS" paragraph: About $NCPUS As with $LFS above, we'll use the variable $NCPUS below to specify how many cpus to build with. If you have a multiple cpu machine, and your host system's kernel is configured to use more than one cpu, replace $NCPUS with the number of cpus you want to use. Otherwise, just replace $NCPUS with 1. The rest of the book assumes you've set $NCPUS as an enviroment variable; for example: export NCPUS=2 Chapter 5. Preparing the LFS system _________________________________________________________________ Installing Bash-2.05a No changes -- bash doesn't like to be made in parallel. Installing Binutils-2.11.2 Change: make LDFLAGS=-all-static tooldir=$LFS/usr && To: make -j $NCPUS LDFLAGS=-all-static tooldir=$LFS/usr && Installing Bzip2-1.0.1 Change: make CC="gcc -static" && To: make -j $NCPUS CC="gcc -static" && Installing Diffutils-2.7 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Fileutils-4.1 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing GCC-2.95.3 Change: make BOOT_LDFLAGS=-static bootstrap && To: make -j $NCPUS BOOT_LDFLAGS=-static bootstrap && Installing Grep-2.4.2 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Gzip-1.2.4a Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Linux Kernel-2.4.16 No changes -- we're just installing the header files here. Installing Make-3.79.1 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Mawk-1.3.3 No changes -- mawk doesn't like to be made in parallel. Installing Patch-2.5.4 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Sed-3.02 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Sh-utils-2.0 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Tar-1.13 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Texinfo-4.0 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Installing Textutils-2.0 Change: make LDFLAGS=-static && To: make -j $NCPUS LDFLAGS=-static && Chapter 6. Installing basic system software _________________________________________________________________ Installing Glibc-2.2.4 Change: mv tmp~ config.make && To: mv tmp~ config.make && echo "PARALLELMFLAGS = -j $NCPUS" >> Makefile && Installing Man-pages-1.43 Change: make install To: make -j $NCPUS install Installing Findutils-4.1 Change: make && To: make -j $NCPUS && Installing Mawk-1.3.3 No changes -- mawk doesn't like to be made in parallel. Installing Ncurses-5.2 Change: make && To: make -j $NCPUS && Installing Vim-6.0 No changes -- didn't seem worth the effort. Installing GCC-2.95.3 Change: make bootstrap && To: make -j $NCPUS bootstrap && Installing Bison-1.28 Change: make && To: make -j $NCPUS && Installing Less-358 Change: make && To: make -j $NCPUS && Installing Groff-1.17.2 No changes -- groff doesn't like to be made in parallel. Installing Man-1.5j No changes -- man doesn't like to be made in parallel. Installing Perl-5.6.1 Change: make && To: make -j $NCPUS && Installing M4-1.4 Change: make && To: make -j $NCPUS && Installing Texinfo-4.0 Change: make && To: make -j $NCPUS && Installing Autoconf-2.52 Change: make && To: make -j $NCPUS && Installing Automake-1.5 No changes -- didn't seem worth the effort Installing Bash-2.05a No changes -- bash doesn't like to be made in parallel. Installing Flex-2.5.4a Change: make && To: make -j $NCPUS && Installing File-3.36 Change: make && To: make -j $NCPUS && Installing Libtool-1.4.2 Change: make && To: make -j $NCPUS && Installing Bin86-0.16.0 Change: make && To: make -j $NCPUS && Installing Binutils-2.11.2 Change: make tooldir=/usr && To: make -j $NCPUS tooldir=/usr && Installing Bzip2-1.0.1 No changes -- didn't seem worth the effort Installing Ed-0.2 No changes -- didn't seem worth the effort Installing Gettext-0.10.40 Change: make && To: make -j $NCPUS && Installing Kbd-1.06 Change: make && To: make -j $NCPUS && Installing Diffutils-2.7 Change: make && To: make -j $NCPUS && Installing E2fsprogs-1.25 Change: make && To: make -j $NCPUS && Installing Fileutils-4.1 Change: make && To: make -j $NCPUS && Installing Grep-2.4.2 Change: make && To: make -j $NCPUS && Installing Gzip-1.2.4a Change: make && To: make -j $NCPUS && Installing Lilo-22.1 No changes -- lilo doesn't like to be made in parallel Installing Make-3.79.1 Change: make && To: make -j $NCPUS && Installing Modutils-2.4.12 Change: make && To: make -j $NCPUS && Installing Netkit-base-0.17 Change: make && To: make -j $NCPUS && Installing Patch-2.5.4 Change: make && To: make -j $NCPUS && Installing Procinfo-18 Change: make LDLIBS=-lncurses && To: make -j $NCPUS LDLIBS=-lncurses && Installing Procps-2.0.7 Change: make && To: make -j $NCPUS && Installing Psmisc-20.1 Change: make && To: make -j $NCPUS && Installing Reiserfsprogs-3.x.0j No changes -- didn't seem worth the effort Installing Sed-3.02 Change: make && To: make -j $NCPUS && Installing Sh-utils-2.0 Change: make && To: make -j $NCPUS && Installing Net-tools-1.60 No changes -- net-tools doesn't like to be made in parallel Installing Shadow-20001016 No changes -- shadow doesn't like to be made in parallel Installing Sysklogd-1.4.1 Change: make && To: make -j $NCPUS && Installing Sysvinit-2.83 No changes -- didn't seem worth the effort Installing Tar-1.13 Change: make && To: make -j $NCPUS && Installing Textutils-2.0 Change: make && To: make -j $NCPUS && Installing Util-linux-2.11m Change: make HAVE_SLN=yes ADD_RAW=yes && To: make -j $NCPUS HAVE_SLN=yes ADD_RAW=yes && Chapter 8. Making the LFS system bootable _________________________________________________________________ Installing a kernel Change: make bzImage && To: make -j $NCPUS bzImage && That's all there is to it.