1 AUTHOR: Daniel Baumann <daniel.baumann@panthera-systems.net>
5 LICENSE: GNU General Public License
7 SYNOPSIS: How to build LFS using multiple compiler instances.
9 PRIMARY URI: http://archive.daniel-baumann.ch/linux-from-scratch/hints/parallelcompiling/
12 How to build a LFS-system in less time using multiple compiler instances in parallel.
15 * http://www.linuxfromscratch.org/hints/downloads/attachments/parallelcompiling/profile-LFS-5.1.1-4_parallelcompiling-1.patch
18 The command-replacements are applicable for LFS version 5.1.1. Similar changes
19 will probably work fine on other versions of the book, but your mileage may
23 --------------------------------------------------------------------------------
28 This hint replaces the smp-hint written by Adam Greenblatt <agreenbl@aol.com>.
29 Now updated and maintained by Daniel Baumann.
35 GNU Make can build multiple targets in parallel compiler (GCC) instances using
38 On single-processor computer, the compiler instances will be automatically
39 scheduled on the processor. This gains speed because a single instance rarely
40 use all ressources, the rest can be used by another one.
42 On multi-processor computer, the compiler instances will be automatically
43 scheduled between the processors. This gains speed because it makes use of the
44 additional application-processor(s) (CPU(s) number 1-?) instead of only using
45 the boot-processor (CPU number 0).
47 A few packages fail to build in parallel: Their makefiles contain implicit
48 depencies that force them to build serially (arguably, this is a bug in those
49 packages). A couple of other packages, notably the GNU C Library (Glibc) and
50 XFree86, use other makefile trickery in place of '-j'.
52 Here is a step by step description of the changes needed.
55 1.1 About $CC_PARALLEL
56 ======================
58 As with $LFS, we will use the variable $CC_PARALLEL to specify how many compiler
59 instances to build with. Replace $CC_PARALLEL with an integer. A good value
60 seems to be 2 instances per processor. In example for a dual-processor system,
61 I suggest to use CC_PARALLEL="4".
63 Machines with Jackson Technologie (also know as Intel Hyper-Threading) should
64 make use of it. A good value here is 2 instances per logical processor. In
65 example for a dual-processor system with enabled Jackson Technologie, I suggest
66 to use CC_PARALLEL="8".
68 Generally on faster systems (2GHz and more), it is also save to use more than 2
69 isntances per (logical) processor. I personally use 5, but I leave this up to
72 The rest of the hint assumes you have set $CC_PARALLEL as an environment
75 # export CC_PARALLEL="4"
77 Attention: If you use the '-j' switch without a following number, GNU Make
78 will start an infinit number of compiler instances. This often
79 crashs your system and should therefore not be used (especially
80 noticed on compiling Glibc which does hang nearly everytime the
88 2.1 Chapter 4. Final Preparations
89 =================================
92 Add: export CC_PARALLEL="<value>"
94 Note: Please replace <value> with a proper integer according to the
98 2.2 Chapter 5. Constructing a temporary system
99 ==============================================
101 Binutils-2.14 - Pass 1
102 Change: make LDFLAGS="-all-static"
103 To: make -j $CC_PARALLEL LDFLAGS="-all-static"
105 Change: make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib
106 To: make -j $CC_PARALLEL -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib
109 Change: make BOOT_LDFLAGS="-static" bootstrap
110 To: make -j $CC_PARALLEL BOOT_LDFLAGS="-static" bootstrap
113 No changes - we are just copying the header files here.
116 Change: make AUTOCONF=no
117 To: make PARALLELMFLAGS="-j $CC_PARALLEL"
119 Change: make localedata/install-locales
120 To: make PARALLELMLFAGS="-j $CC_PARALLEL" localedata/install-locales
122 Adjusting the toolchain
123 Change: make -C ld install
124 To: make -j $CC_PARALLEL -C ld install
128 To: make -j $CC_PARALLEL
132 To: make -j $CC_PARALLEL
136 To: make -j $CC_PARALLEL install
140 To: make -j $CC_PARALLEL
142 Binutils-2.14 - Pass 2
144 To: make -j $CC_PARALLEL
148 To: make -j $CC_PARALLEL
152 To: make -j $CC_PARALLEL
155 Change: make PREFIX=/tools install
156 To: make -j $CC_PARALLEL PREFIX=/tools install
160 To: make -j $CC_PARALLEL
164 To: make -j $CC_PARALLEL
168 To: make -j $CC_PARALLEL
172 To: make -j $CC_PARALLEL
176 To: make -j $CC_PARALLEL
180 To: make -j $CC_PARALLEL
184 To: make -j $CC_PARALLEL
194 To: make -j $CC_PARALLEL
198 To: make -j $CC_PARALLEL
202 To: make -j $CC_PARALLEL
205 No changes - Bash does not like to be made in parallel.
209 make -C mount mount umount
210 make -C text-utils more
212 To: make -j $CC_PARALLEL -C lib
213 make -j $CC_PARALLEL -C mount mount unmount
214 make -j $CC_PARALLEL -C text-utils more
217 Change: make perl utilities
218 To: make -j $CC_PARALLEL perl utilities
221 2.3 Chapter 6. Installing basic system software
222 ===============================================
224 Entering the chroot environment
225 Change: chroot "$LFS" /tools/bin/env -i \
226 HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
227 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
228 /tools/bin/bash --login +h
230 To: chroot $LFS /tools/bin/env -i CC_PARALLEL="<value>" \
231 HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
232 PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
233 /tools/bin/bash --login +h
235 Note: Please replace <value> with a proper integer according to the
238 Creating devices with Make_devices-1.2
239 No changes - we are just creating the devices files here.
242 No changes - we are just copying the header files here.
245 No changes - we are just copying the man-pages here.
249 To: make PARALLELMFLAGS="-j $CC_PARALLEL"
251 Change: make localedata/install-locales
252 To: make PARALLELMFLAGS="-j $CC_PARALLEL"
254 Re-adjusting the toolchain
255 Change: make -C ld INSTALL=/tools/bin/install install
256 To: make -j $CC_PARALLEL -C ld INSTALL=/tools/bin/install install
259 Change: make tooldir=/usr
260 To: make -j $CC_PARALLEL tooldir=/usr
264 To: make -j $CC_PARALLEL
268 To: make -j $CC_PARALLEL
272 To: make -j $CC_PARALLEL
275 To: make -j $CC_PARALLEL
278 No changes - mktemp does not worth the effort.
281 No changes - iana-etc does not worth the effort.
285 To: make -j $CC_PARALLEL
289 To: make -j $CC_PARALLEL
298 To: make -j $CC_PARALLEL
302 To: make -j $CC_PARALLEL
306 To: make -j $CC_PARALLEL
310 To: make -j $CC_PARALLEL
313 No changes - Groff does not like to be made in parallel.
317 To: make -j $CC_PARALLEL
321 To: make -j $CC_PARALLEL
325 To: make -j $CC_PARALLEL
328 No changes - Net-tools do not like to be made in parallel.
332 To: make -j $CC_PARALLEL
336 To: make -j $CC_PARALLEL
340 To: make -j $CC_PARALLEL
344 To: make -j $CC_PARALLEL
348 To: make -j $CC_PARALLEL
351 No changes - Bash does not like to be made in parallel.
355 To: make -j $CC_PARALLEL
359 To: make -j $CC_PARALLEL
363 To: make -j $CC_PARALLEL
367 To: make -j $CC_PARALLEL
371 To: make -j $CC_PARALLEL
375 To: make -j $CC_PARALLEL
379 To: make -j $CC_PARALLEL
383 To: make -j $CC_PARALLEL
387 To: make -j $CC_PARALLEL
391 To: make -j $CC_PARALLEL
394 No changes - Man does not like to be made in parallel.
398 To: make -j $CC_PARALLEL
402 To: make -j $CC_PARALLEL
406 To: make -j $CC_PARALLEL
409 Change: make LDLIBS=-lncurses
410 To: make -j $CC_PARALLEL LDLIBS=-lncurses
414 To: make -j $CC_PARALLEL
418 To: make -j $CC_PARALLEL
422 To: make -j $CC_PARALLEL
426 To: make -j $CC_PARALLEL
430 To: make -j $CC_PARALLEL -C src
434 To: make -j $CC_PARALLEL
437 Change: make HAVE_KILL=yes HAVE_SLN=yes
438 To: make -j $CC_PARALLEL HAVE_KILL=yes HAVE_SLN=yes
441 Change: make bootstrap
442 To: make -j $CC_PARALLEL bootstrap
445 2.4 Chapter 7. Setting up system boot scripts
446 =============================================
448 LFS-Bootscripts-2.0.5
449 No changes - we are just copying the scripts here.
452 2.5 Chapter 8. Making the LFS system bootable
453 =============================================
456 Change: make CC=/opt/gcc-2.95.3/bin/gcc bzImage
457 make CC=/opt/gcc-2.95.3/bin/gcc modules
459 To: make -j $CC_PARALLEL CC=/opt/gcc-2.95.3/bin/gcc bzImage
460 make -j $CC_PARALLEL CC=/opt/gcc-2.95.3/bin/gcc modules
467 3.1 Chapter 25. X Window Environment
468 ====================================
471 Change: ( make World 2>&1 | tee xorg-compile.log && exit $PIPESTATUS ) &&
473 To: ( make TOPPARALLELMLFAGS="-j $CC_PARALLEL" World 2>&1 \
474 | tee xorg-comile.log && exit $PIPESTATUS ) &&
477 Change: ( make WORLDOPTS="" World 2>&1 | tee xfree-compile.log && exit $PIPESTATUS ) &&
479 To: ( make WORLDOPTS="" TOPPARALLELMFLAGS="-j $CC_PARALLEL" \
480 World 2>&1 | tee xfree-compile.log && \
481 exit $PIPESTATUS ) &&
487 Download the patch from:
489 http://www.linuxfromscratch.org/hints/downloads/attachments/parallelcompiling/profile-LFS-5.1.1-4_parallelcompiling-1.patch
491 Apply the patch with:
494 # patch -Np1 -i ../profile-LFS-5.1.1-4_parallelcompiling-1.patch
496 Open config_seperate/general.ent, go to
498 <!ENTITY gcc_parallel "<value>">
500 and replace <value> according to your needs.
502 --------------------------------------------------------------------------------
505 * Adam Greenblatt <agreenbl@aol.com> for the smp-hint.
509 * Updated nALFS profile patch.
511 * Updated nALFS profile patch.
513 * Updated to LFS-5.1.1.
514 * X.org-command (BLFS) added.
515 * XFree86-command (BLFS) updated.
516 * nALFS profile patch added.
518 * Typographic mistakes corrected.
520 * Updated to LFS 5.1.
521 * Minor text changes.
523 * Minor text changes.
525 * Ncurses-command revised (Thanks to Greg Schaefer <gschafer@zip.com.au>).
526 * Typographic mistake corrected.
528 * Updated to LFS 5.0.
529 * Minor text changes.
530 * Typographic mistakes corrected.
534 * Glibc-command revised.
535 * XFree86-command (BLFS) added.
536 * Typographic mistakes corrected.