lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / parallelcompiling.txt
blob279c590f402016e5a8f1d05e07298fa24681a7a0
1 AUTHOR: Daniel Baumann <daniel.baumann@panthera-systems.net>
3 DATE: 2004-07-10
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/
11 DESCRIPTION:
12 How to build a LFS-system in less time using multiple compiler instances in parallel.
14 ATTACHMENTS:
15 * http://www.linuxfromscratch.org/hints/downloads/attachments/parallelcompiling/profile-LFS-5.1.1-4_parallelcompiling-1.patch
17 PREREQUISITES:
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
20 vary.
22 HINT:
23 --------------------------------------------------------------------------------
25 PARALLELCOMPILING
26 =================
28 This hint replaces the smp-hint written by Adam Greenblatt <agreenbl@aol.com>.
29 Now updated and maintained by Daniel Baumann.
32 1. Introduction
33 ===============
35 GNU Make can build multiple targets in parallel compiler (GCC) instances using
36 the '-j' switch.
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
70 you to choose.
72 The rest of the hint assumes you have set $CC_PARALLEL as an environment
73 variable, in example
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
81                 computer).
84 2. LFS-Book
85 ===========
88 2.1 Chapter 4. Final Preparations
89 =================================
91 About $LFS
92         Add:    export CC_PARALLEL="<value>"
94         Note:   Please replace <value> with a proper integer according to the
95                 introduction.
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
108 GCC-3.3.3 - Pass 1
109         Change: make BOOT_LDFLAGS="-static" bootstrap
110         To:     make -j $CC_PARALLEL BOOT_LDFLAGS="-static" bootstrap
112 Linux-2.4.26 headers
113         No changes - we are just copying the header files here.
115 Glibc-2.3.3-lfs-5.1
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
126 Tcl-8.4.6
127         Change: make
128         To:     make -j $CC_PARALLEL
130 Expect-5.41.0
131         Change: make
132         To:     make -j $CC_PARALLEL
134 DejaGnu-1.4.4
135         Change: make install
136         To:     make -j $CC_PARALLEL install
138 GCC-3.3.3 - Pass 2
139         Change: make
140         To:     make -j $CC_PARALLEL
142 Binutils-2.14 - Pass 2
143         Change: make
144         To:     make -j $CC_PARALLEL
146 Gawk-3.1.3
147         Change: make
148         To:     make -j $CC_PARALLEL
150 Coreutils-5.2.1
151         Change: make
152         To:     make -j $CC_PARALLEL
154 Bzip2-1.0.2
155         Change: make PREFIX=/tools install
156         To:     make -j $CC_PARALLEL PREFIX=/tools install
158 Gzip-1.3.5
159         Change: make
160         To:     make -j $CC_PARALLEL
162 Diffutils-2.8.1
163         Change: make
164         To:     make -j $CC_PARALLEL
166 Findutils-4.1.20
167         Change: make
168         To:     make -j $CC_PARALLEL
170 Make-3.80
171         Change: make
172         To:     make -j $CC_PARALLEL
174 Grep-2.5.1
175         Change: make
176         To:     make -j $CC_PARALLEL
178 Sed-4.0.9
179         Change: make
180         To:     make -j $CC_PARALLEL
182 Gettext-0.14.1
183         Change: make
184         To:     make -j $CC_PARALLEL
186 Ncurses-5.4
187         Change: make
189         To:     make sources
190                 make -j $CC_PARALLEL
192 Patch-2.5.4
193         Change: make
194         To:     make -j $CC_PARALLEL
196 Tar-1.13.94
197         Change: make
198         To:     make -j $CC_PARALLEL
200 Texinfo-4.7
201         Change: make
202         To:     make -j $CC_PARALLEL
204 Bash-2.05b
205         No changes - Bash does not like to be made in parallel.
207 Util-linux-2.12a
208         Change: make -C lib
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
216 Perl-5.8.4
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
229         
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
236                 introduction.
238 Creating devices with Make_devices-1.2
239         No changes - we are just creating the devices files here.
241 Linux-2.4.26 headers
242         No changes - we are just copying the header files here.
244 Man-pages-1.66
245         No changes - we are just copying the man-pages here.
247 Glibc-2.3.3-lfs-5.1
248         Change: make
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
258 Binutils-2.14
259         Change: make tooldir=/usr
260         To:     make -j $CC_PARALLEL tooldir=/usr
262 GCC-3.3.3
263         Change: make
264         To:     make -j $CC_PARALLEL
266 Coreutils-5.2.1
267         Change: make
268         To:     make -j $CC_PARALLEL
270 Zlib-1.2.1
271         Change: make
272         To:     make -j $CC_PARALLEL
274         Change: make
275         To:     make -j $CC_PARALLEL
277 Mktemp-1.5
278         No changes - mktemp does not worth the effort.
280 Iana-Etc-1.00
281         No changes - iana-etc does not worth the effort.
283 Findutils-4.1.20
284         Change: make
285         To:     make -j $CC_PARALLEL
287 Gawk-3.1.3
288         Change: make
289         To:     make -j $CC_PARALLEL
291 Ncurses-5.4
292         Change: make
293         To:     make sources
294                 make -j $CC_PARALLEL
296 Vim-6.2
297         Change: make
298         To:     make -j $CC_PARALLEL
300 M4-1.4
301         Change: make
302         To:     make -j $CC_PARALLEL
304 Bison-1.875
305         Change: make
306         To:     make -j $CC_PARALLEL
308 Less-382
309         Change: make
310         To:     make -j $CC_PARALLEL
312 Groff-1.19
313         No changes - Groff does not like to be made in parallel.
315 Sed-4.0.9
316         Change: make
317         To:     make -j $CC_PARALLEL
319 Flex-2.5.4a
320         Change: make
321         To:     make -j $CC_PARALLEL
323 Gettext-0.14.1
324         Change: make
325         To:     make -j $CC_PARALLEL
327 Net-tools-1.60
328         No changes - Net-tools do not like to be made in parallel.
330 Inetutils-1.4.2
331         Change: make
332         To:     make -j $CC_PARALLEL
334 Perl-5.8.4
335         Change: make
336         To:     make -j $CC_PARALLEL
338 Texinfo-4.7
339         Change: make
340         To:     make -j $CC_PARALLEL
342 Autoconf-2.59
343         Change: make
344         To:     make -j $CC_PARALLEL
346 Automake-1.8.4
347         Change: make
348         To:     make -j $CC_PARALLEL
350 Bash-2.05b
351         No changes - Bash does not like to be made in parallel.
353 File-4.09
354         Change: make
355         To:     make -j $CC_PARALLEL
357 Libtool-1.5.6
358         Change: make
359         To:     make -j $CC_PARALLEL
361 Bzip2-1.0.2
362         Change: make
363         To:     make -j $CC_PARALLEL
365 Diffutils-2.8.1
366         Change: make
367         To:     make -j $CC_PARALLEL
369 Ed-0.2
370         Change: make
371         To:     make -j $CC_PARALLEL
373 Kbd-1.12
374         Change: make
375         To:     make -j $CC_PARALLEL
377 E2fsprogs-1.35
378         Change: make
379         To:     make -j $CC_PARALLEL
381 Grep-2.5.1
382         Change: make
383         To:     make -j $CC_PARALLEL
385 Grub-0.94
386         Change: make
387         To:     make -j $CC_PARALLEL
389 Gzip-1.3.5
390         Change: make
391         To:     make -j $CC_PARALLEL
393 Man-1.5m2
394         No changes - Man does not like to be made in parallel.
396 Make-3.80
397         Change: make
398         To:     make -j $CC_PARALLEL
400 Modutils-2.4.27
401         Change: make
402         To:     make -j $CC_PARALLEL
404 Patch-2.5.4
405         Change: make
406         To:     make -j $CC_PARALLEL
408 Procinfo-18
409         Change: make LDLIBS=-lncurses
410         To:     make -j $CC_PARALLEL LDLIBS=-lncurses
412 Procps-3.2.1
413         Change: make
414         To:     make -j $CC_PARALLEL
416 Psmisc-21.4
417         Change: make
418         To:     make -j $CC_PARALLEL
420 Shadow-4.0.4.1
421         Change: make
422         To:     make -j $CC_PARALLEL
424 Sysklogd-1.4.1
425         Change: make
426         To:     make -j $CC_PARALLEL
428 Sysvinit-2.85
429         Change: make -C src
430         To:     make -j $CC_PARALLEL -C src
432 Tar-1.13.94
433         Change: make
434         To:     make -j $CC_PARALLEL
436 Util-linux-2.12a
437         Change: make HAVE_KILL=yes HAVE_SLN=yes
438         To:     make -j $CC_PARALLEL HAVE_KILL=yes HAVE_SLN=yes
440 GCC-2.95.3
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 =============================================
455 Linux-2.4.26
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
463 3. BLFS-Book
464 ============
467 3.1 Chapter 25. X Window Environment
468 ====================================
470 Xorg-6.7.0
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 ) &&
476 XFree86-4.4.0
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 ) &&
484 4. nALFS
485 ========
487 Download the patch from:
488         
489         http://www.linuxfromscratch.org/hints/downloads/attachments/parallelcompiling/profile-LFS-5.1.1-4_parallelcompiling-1.patch
491 Apply the patch with:
493         # cd LFS-5.1.1
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 --------------------------------------------------------------------------------
504 ACKNOWLEDGEMENTS:
505   * Adam Greenblatt <agreenbl@aol.com> for the smp-hint.
507 CHANGELOG:
508   [2004-07-10]
509     * Updated nALFS profile patch.
510   [2004-06-12]
511     * Updated nALFS profile patch.
512   [2004-06-06]
513     * Updated to LFS-5.1.1.
514     * X.org-command (BLFS) added.
515     * XFree86-command (BLFS) updated.
516     * nALFS profile patch added.
517   [2004-05-29]
518     * Typographic mistakes corrected.
519   [2004-05-22]
520     * Updated to LFS 5.1.
521     * Minor text changes.
522   [2004-01-26]
523     * Minor text changes.
524   [2004-01-25]
525     * Ncurses-command revised (Thanks to Greg Schaefer <gschafer@zip.com.au>).
526     * Typographic mistake corrected.
527   [2004-01-16]
528     * Updated to LFS 5.0.
529     * Minor text changes.
530     * Typographic mistakes corrected.
531   [2003-09-09]
532     * New hint format.
533   [2003-06-21]
534     * Glibc-command revised.
535     * XFree86-command (BLFS) added.
536     * Typographic mistakes corrected.
537   [2003-06-07]
538     * Initial revision.