1 TITLE: How to build LFS using multiple GCC instances in parallel
2 LFS VERSION: All (fixes for 4.1)
3 AUTHOR: Daniel Baumann <danielbaumann@linuxmail.org>
6 How to build a LFS system in less time using multiple GCC instances in
14 * 2003-06-21 Typographic and other misstakes corrected, Glibc-command
15 revised and XFree86-command (BLFS) added
17 * 2003-06-07 Initial revision
23 You use this LFS-Hint at your own risk.
25 Neither the author, nor the Linux From Scratch project accepts any reponsibility
26 for anything that happens when using this document or associated files.
28 This hint is based on the smp-hint written by Adam Greenblatt
29 <agreenbl@aol.com>, now updated and maintained by Daniel Baumann
30 <danielbaumann@linuxmail.org>.
32 I would like to thank Adam for allowing to continue his good work.
38 GNU Make can build multiple targets in parallel GCC instances using the '-j'
41 On single-processor machines, the GCC instances will be automatically scheduled
42 on the processor. This gains speed because a single GCC instance rarely use all
43 ressources, the rest can be used by another instance.
45 On multi-processor machines, the GCC instances will be automatically scheduled
46 between the processors. This gains speed because it makes use of the additional
47 application-processor(s) (CPU(s) number 1-?) instead of only using the
48 boot-processor (CPU number 0).
50 A few packages fail to build in parallel: their makefiles contain implicit
51 dependencies that force them to build serially (arguably, this is a bug in those
52 packages). A couple other packages, notably Glibc and XFree86, use other
53 makefile trickery in place of '-j'.
55 Here is a step by step description of the changes needed. Similar changes will
56 probably work fine on other versions of the book, but your mileage may vary.
62 Chapter 2. Important information
63 --------------------------------
65 Insert the following paragraph after the "About $LFS" paragraph:
69 As with $LFS above, we will use the variable $CC_PARALLEL below to
70 specify how many instances of GCC to build with. Replace $CC_PARALLEL
71 with a numeric value. A good value seems to be 2 instances per
72 processor. In example for a dual-processor system, I suggest to use
75 Machines with Jackson Technologie (also known as Intel Hyper-Threading)
76 should enable it. In fact, every logical processor has its own floating-
77 point-unit (FPU), only the caches are shared. Therefore, you get the
78 nearly doubled performance on FPU-calculations with only a little loss
79 on overhead for managing the shared cache. A good value here is 2
80 instances per logical processor. In example for a dual-processor system
81 with enabled Jackson Technologie, I suggest to use CC_PARALLEL=8.
83 Generally on very fast systems (2GHz and more), it is also save to use
84 more than 2 instances per (logical) processor. I personally use 5 per
85 processor, but I will leave this up to you to choose.
87 The rest of the book assumes you have set $CC_PARALLEL as an environment
92 If you use the '-j'-flag without a number followed, GNU Make will start
93 an infinit number of GCC instances. This often crashs your system and
94 should therefore not be used (especially noticed on compiling Glibc
95 which does hang nearly everytime the machine).
97 Chapter 5. Preparing the LFS system
98 -----------------------------------
100 Installing Bash-2.05a
101 No changes - bash does not like to be made in parallel.
103 Installing Binutils-2.13.2
104 Change: make LDFLAGS="-all-static"
105 To: make -j $CC_PARALLEL LDFLAGS="-all-static"
107 Installing Bzip2-1.0.2
108 Change: make CC="gcc -static -s"
109 To: make -j $CC_PARALLEL CC="gcc -static -s"
111 Installing Diffutils-2.8.1
113 To: make -j $CC_PARALLEL
115 Installing Fileutils-4.1
117 To: make -j $CC_PARALLEL
119 Installing Findutils-4.1
121 To: make -j $CC_PARALLEL
123 Installing Gawk-3.1.1
125 To: make -j $CC_PARALLEL
128 Change: make BOOT_LDFLAGS="-static" bootstrap
129 To: make -j $CC_PARALLEL BOOT_LDFLAGS="-static" bootstrap
133 To: make -j $CC_PARALLEL
135 Installing Gzip-1.2.4a
136 Change: make LDFLAGS="-static"
137 To: make -j $CC_PARALLEL LDFLAGS="-static"
141 To: make -j $CC_PARALLEL
143 Installing Patch-2.5.4
145 To: make -j $CC_PARALLEL
149 To: make -j $CC_PARALLEL
151 Installing Sh-utils-2.0
153 To: make -j $CC_PARALLEL
157 To: make -j $CC_PARALLEL
159 Installing Texinfo-4.3
161 To: make -j $CC_PARALLEL
163 Installing Textutils-2.1
165 To: make -j $CC_PARALLEL
167 Installing Util-linux-2.11y
169 make -C mount mount umount
171 To: make -j $CC_PARALLEL -C lib
172 make -j $CC_PARALLEL -C mount mount umount
174 Chapter 6. Installing basic system software
175 -------------------------------------------
177 Entering the chroot environment
178 Change: chroot $LFS /static/bin/env -i \
179 HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
180 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/static/bin \
181 /static/bin/bash --login
183 To: chroot $LFS /static/bin/env -i \
184 HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
185 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/static/bin \
186 CC_PARALLEL=$CC_PARALLEL \
187 /static/bin/bash --login
189 Installing Linux Kernel-2.4.20
190 No changes - we are just installing the header files here.
192 Installing Man-pages-1.54
193 No changes - we are just installing the man-pages here.
195 Installing Glibc-2.3.1
197 To: make PARALLELMFLAGS="-j $CC_PARALLEL"
200 Change: make bootstrap
201 To: make -j $CC_PARALLEL bootstrap
203 Installing Zlib-1.1.4
204 Change: make LIBS="libz.so.1.1.4 libz.a"
205 To: make -j $CC_PARALLEL LIBS="libz.so.1.1.4 libz.a"
207 Installing Findutils-4.1
208 Change: make libexecdir=/usr/bin
209 To: make -j $CC_PARALLEL libexecdir=/usr/bin
211 Installing Gawk-3.1.1
213 To: make -j $CC_PARALLEL
215 Installing Ncurses-5.3
217 To: make -j $CC_PARALLEL
220 Change: make CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\"
221 To: make -j $CC_PARALLEL \
222 CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\"
226 To: make -j $CC_PARALLEL
228 Installing Bison-1.875
230 To: make -j $CC_PARALLEL
234 To: make -j $CC_PARALLEL
236 Installing Groff-1.18.1
237 No changes - groff does not like to be made in parallel.
239 Installing Textutils-2.1
241 To: make -j $CC_PARALLEL
245 To: make -j $CC_PARALLEL
247 Installing Flex-2.5.4a
249 To: make -j $CC_PARALLEL
251 Installing Binutils-2.13.2
252 Change: make tooldir=/usr
253 To: make -j $CC_PARALLEL tooldir=/usr
255 Installing Fileutils-4.1
257 To: make -j $CC_PARALLEL
259 Installing Sh-utils-2.0
261 To: make -j $CC_PARALLEL
263 Installing Gettext-0.11.5
265 To: make -j $CC_PARALLEL
267 Installing Net-tools-1.60
268 No changes - net-tools do not like to be made in parallel.
270 Installing Perl-5.8.0
272 To: make -j $CC_PARALLEL
274 Installing Texinfo-4.3
276 To: make -j $CC_PARALLEL
278 Installing Autoconf-2.57
280 To: make -j $CC_PARALLEL
282 Installing Automake-1.7.2
284 To: make -j $CC_PARALLEL install
286 Installing Bash-2.05a
287 No changes - bash does not like to be made in parallel.
291 To: make -j $CC_PARALLEL
293 Installing Libtool-1.4.3
295 To: make -j $CC_PARALLEL
297 Installing Bin86-0.16.3
299 To: make -j $CC_PARALLEL
301 Installing Bzip2-1.0.2
303 To: make -j $CC_PARALLEL
307 To: make -j $CC_PARALLEL
311 To: make -j $CC_PARALLEL
313 Installing Diffutils-2.8.1
315 To: make -j $CC_PARALLEL
317 Installing E2fsprogs-1.32
319 To: make -j $CC_PARALLEL
323 To: make -j $CC_PARALLEL
325 Installing Gzip-1.2.4a
327 To: make -j $CC_PARALLEL
330 No changes - man does not like to be made in parallel.
333 No changes - lilo does not like to be made in parallel.
337 To: make -j $CC_PARALLEL
339 Installing Modutils-2.4.22
341 To: make -j $CC_PARALLEL
343 Installing Netkit-base-0.17
345 To: make -j $CC_PARALLEL
347 Installing Patch-2.5.4
349 To: make -j $CC_PARALLEL
351 Installing Procinfo-18
352 Change: make LDLIBS=-lncurses
353 To: make -j $CC_PARALLEL LDLIBS=-lncurses
355 Installing Procps-3.1.5
357 To: make -j $CC_PARALLEL
359 Installing Psmisc-21.2
361 To: make -j $CC_PARALLEL
363 Installing Shadow-4.0.3
364 No changes - shadow does not like to be made in parallel.
366 Installing Sysklogd-1.4.1
368 To: make -j $CC_PARALLEL
370 Installing Sysvinit-2.84
372 To: make -j $CC_PARALLEL -C src
376 To: make -j $CC_PARALLEL
378 Installing Util-linux-2.11y
379 Change: make HAVE_SLN=yes
380 To: make -j $CC_PARALLEL HAVE_SLN=yes
382 Installing Glibc-2.3.1
384 To: make PARALLELMFLAGS="-j $CC_PARALLEL"
386 Chapter 8. Making the LFS system bootable
387 -----------------------------------------
389 Installing Linux-2.4.20
393 To: make -j $CC_PARALLEL bzImage
394 make -j $CC_PARALLEL modules
400 Chapter 26. Installing X
401 ------------------------
403 Installing XFree86-4.3.0
404 Change: WORLDOPTS="" make World 2>&1 | tee xfree-compile.log &&
405 To: WORLDOPTS="" make TOPPARALLELMFLAGS="-j $CC_PARALLEL" \
406 World 2>&1 | tee xfree-compile.log &&
409 END OF PARALLELCOMPILING-HINT