Typo
[linux_from_scratch_hints.git] / OLD / parallelcompiling.txt
blob87457d4a591240ea5a5228b230c879f567813f2a
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>
5 SYNOPSIS:
6         How to build a LFS system in less time using multiple GCC instances in
7         parallel
9 HINT:
11 CHANGELOG
12 =========
14         * 2003-06-21    Typographic and other misstakes corrected, Glibc-command
15                         revised and XFree86-command (BLFS) added
17         * 2003-06-07    Initial revision
20 DISCLAIMER
21 ==========
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.
35 INTRODUCTION
36 ============
38 GNU Make can build multiple targets in parallel GCC instances using the '-j'
39 switch.
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.
59 FIXES FOR LFS-BOOK
60 ==================
62 Chapter 2. Important information
63 --------------------------------
65 Insert the following paragraph after the "About $LFS" paragraph:
67         About $CC_PARALLEL
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
73         CC_PARALLEL=4.
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
88         variable, in example
90                 export CC_PARALLEL=4
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
112         Change: make
113         To:     make -j $CC_PARALLEL
115 Installing Fileutils-4.1
116         Change: make
117         To:     make -j $CC_PARALLEL
119 Installing Findutils-4.1
120         Change: make
121         To:     make -j $CC_PARALLEL
123 Installing Gawk-3.1.1
124         Change: make
125         To:     make -j $CC_PARALLEL
127 Installing GCC-3.2.1
128         Change: make BOOT_LDFLAGS="-static" bootstrap
129         To:     make -j $CC_PARALLEL BOOT_LDFLAGS="-static" bootstrap
131 Installing Grep-2.5
132         Change: make
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"
139 Installing Make-3.80
140         Change: make
141         To:     make -j $CC_PARALLEL
143 Installing Patch-2.5.4
144         Change: make
145         To:     make -j $CC_PARALLEL
147 Installing Sed-4.0.3
148         Change: make
149         To:     make -j $CC_PARALLEL
151 Installing Sh-utils-2.0
152         Change: make
153         To:     make -j $CC_PARALLEL
155 Installing Tar-1.13
156         Change: make
157         To:     make -j $CC_PARALLEL
159 Installing Texinfo-4.3
160         Change: make
161         To:     make -j $CC_PARALLEL
163 Installing Textutils-2.1
164         Change: make
165         To:     make -j $CC_PARALLEL
167 Installing Util-linux-2.11y
168         Change: make -C lib
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
196         Change: make
197         To:     make PARALLELMFLAGS="-j $CC_PARALLEL"
199 Installing GCC-3.2.1
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
212         Change: make
213         To:     make -j $CC_PARALLEL
215 Installing Ncurses-5.3
216         Change: make
217         To:     make -j $CC_PARALLEL
219 Installing Vim-6.1
220         Change: make CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\"
221         To:     make -j $CC_PARALLEL \
222                         CPPFLAGS=-DSYS_VIMRC_FILE=\\\"/etc/vimrc\\\"
224 Installling M4-1.4
225         Change: make
226         To:     make -j $CC_PARALLEL
228 Installing Bison-1.875
229         Change: make
230         To:     make -j $CC_PARALLEL
232 Installing Less-378
233         Change: make
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
240         Change: make
241         To:     make -j $CC_PARALLEL
243 Installing Sed-4.0.3
244         Change: make
245         To:     make -j $CC_PARALLEL
247 Installing Flex-2.5.4a
248         Change: make
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
256         Change: make
257         To:     make -j $CC_PARALLEL
259 Installing Sh-utils-2.0
260         Change: make
261         To:     make -j $CC_PARALLEL
263 Installing Gettext-0.11.5
264         Change: make
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
271         Change: make
272         To:     make -j $CC_PARALLEL
274 Installing Texinfo-4.3
275         Change: make
276         To:     make -j $CC_PARALLEL
278 Installing Autoconf-2.57
279         Change: make
280         To:     make -j $CC_PARALLEL
282 Installing Automake-1.7.2
283         Change: make install
284         To:     make -j $CC_PARALLEL install
286 Installing Bash-2.05a
287         No changes - bash does not like to be made in parallel.
289 Installing File-3.39
290         Change: make
291         To:     make -j $CC_PARALLEL
293 Installing Libtool-1.4.3
294         Change: make
295         To:     make -j $CC_PARALLEL
297 Installing Bin86-0.16.3
298         Change: make
299         To:     make -j $CC_PARALLEL
301 Installing Bzip2-1.0.2
302         Change: make
303         To:     make -j $CC_PARALLEL
305 Installing Ed-0.2
306         Change: make
307         To:     make -j $CC_PARALLEL
309 Installing Kbd-1.08
310         Change: make
311         To:     make -j $CC_PARALLEL
313 Installing Diffutils-2.8.1
314         Change: make
315         To:     make -j $CC_PARALLEL
317 Installing E2fsprogs-1.32
318         Change: make
319         To:     make -j $CC_PARALLEL
321 Installing Grep-2.5
322         Change: make
323         To:     make -j $CC_PARALLEL
325 Installing Gzip-1.2.4a
326         Change: make
327         To:     make -j $CC_PARALLEL
329 Installing Man-1.5k
330         No changes - man does not like to be made in parallel.
332 Installing Lilo-22.2
333         No changes - lilo does not like to be made in parallel.
335 Installing Make-3.80
336         Change: make
337         To:     make -j $CC_PARALLEL
339 Installing Modutils-2.4.22
340         Change: make
341         To:     make -j $CC_PARALLEL
343 Installing Netkit-base-0.17
344         Change: make
345         To:     make -j $CC_PARALLEL
347 Installing Patch-2.5.4
348         Change: make
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
356         Change: make
357         To:     make -j $CC_PARALLEL
359 Installing Psmisc-21.2
360         Change: make
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
367         Change: make
368         To:     make -j $CC_PARALLEL
370 Installing Sysvinit-2.84
371         Change: make -C src
372         To:     make -j $CC_PARALLEL -C src
374 Installing Tar-1.13
375         Change: make
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
383         Change: make
384         To:     make PARALLELMFLAGS="-j $CC_PARALLEL"
386 Chapter 8. Making the LFS system bootable
387 -----------------------------------------
389 Installing Linux-2.4.20
390         Change: make bzImage
391                 make modules
393         To:     make -j $CC_PARALLEL bzImage
394                 make -j $CC_PARALLEL modules
397 FIXES FOR BLFS-BOOK
398 ===================
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