root/trunk/all_of_gcc_during_lfs.txt

Revision 1078, 14.5 kB (checked in by robert, 1 year ago)

Updated all_of_gcc_during_lfs hint

Line 
1 AUTHOR: Randy McMurchy <randy_at_linuxfromscratch_dot_org>
2
3 DATE: 2007-07-01
4
5 LICENSE: Creative Commons Attribution-NonCommercial-ShareAlike License
6          http://creativecommons.org/licenses/by-nc-sa/1.0/
7
8 SYNOPSIS: Installing all the GCC compilers while building LFS
9
10 DESCRIPTION: This hint will guide you through the installation of any or all
11 the GCC compilers while building an LFS system. These instructions target
12 the 4.x.x series of GCC as there have been significant changes since the
13 3.x.x series. Prior to the 4.x.x series, only the Ada compiler could not be
14 installed during Chapter 6 of an LFS build. See my
15 http://www.linuxfromscratch.org/hints/downloads/files/ada_install_during_lfs.txt
16 hint for instructions to install the Ada compiler during an LFS build if you
17 are using a version of GCC prior to 4.x.x.
18
19 ATTACHMENTS: None
20
21 REQUIRED DOWNLOADS:
22
23 1. The GCC tarball for whatever version of GCC called for in LFS. This will
24 be a file named something similar to gcc-4.1.2.tar.bz2
25
26 2. The 2005 version of the GNAT compiler found on the AdaCore site. The
27 download location (https://libre.adacore.com/dynamic/download_page) requires
28 that you create an account on the AdaCore site before you can download the
29 package. Nothing is required other than a valid email address. Ensure you
30 download the 2005 version of the GNAT compiler. The 2006 version will not work.
31 The file name you need is: gnat-gpl-2005-i686-gnu-linux-gnu-libc2.3-bin.tar.gz.
32 (not required if your host system has an existing Ada compiler, or you don't
33 plan on installing the GCC Ada compiler)
34
35 3. A GMP tarball if you plan on installing the Fortran compiler. See
36 http://www.linuxfromscratch.org/blfs/view/svn/general/gmp.html for download
37 locations.
38
39 4. An MPFR tarball if you plan on installing the Fortran compiler. See
40 http://www.mpfr.org/mpfr-current/ for download locations.
41
42 PREREQUISITES:
43
44 None
45
46 HINT:
47
48 =========
49 CONTENTS:
50 =========
51
52         1.  Introduction
53         2.  The Treelang compiler
54         3.  The Fortran compiler
55               GMP installation
56               MPFR installation
57               GCC installation
58         4.  The Ada compiler
59         5.  Package dependencies
60         6.  Installing the GNAT Ada compiler
61         7.  Configuring the PATH variable
62         8.  Chapter 5 GCC-Pass1 Modifications
63         9.  Reconfiguring the PATH variable
64         10. Chapter 5 GCC-Pass2 Modifications
65         11. Chapter 5 Ncurses modifications
66         12. Chapter 6 GCC Modifications
67         13. Chapter 6 Ncurses modifications
68         14. Closing
69
70 ================
71 1. INTRODUCTION:
72 ================
73
74 The default installation during LFS only installs a C and C++ compiler. If
75 you know that you'll need additional compilers after LFS is built, it is
76 easier to just build the additional compilers during LFS. So, you say to
77 yourself, when I get to the GCC installation in Chapter 6 of LFS, I'll just
78 add additional compilers to the configure script command and I'll build them
79 then. This won't work for the Ada, Fortran or Treelang compilers. For
80 these three compilers, you cannot wait until the GCC installation in Chapter
81 6 to decide you want/need to install them (Fortran is a slight exception
82 to this). At this point of Chapter 6, you are in a chroot environment
83 working with whatever is installed in the /tools directory you created in
84 Chapter 5 and there are not adequate tools, nor any real way to add them,
85 to compile Ada and Treelang.
86
87 In summary, if you need to install the Ada, Fortran or Treelang compilers
88 during Chapter 6 of an LFS build, you'll need to do some extra work. The
89 Java and Objective C compilers can be installed by simply adding them to the
90 list of compilers in the configure script parameter, --enable-languages=...
91
92 In order to install the GCC Ada compiler, you must have an existing Ada
93 compiler available so GCC can boostrap its version of Ada. If your host has
94 an existing Ada compiler, you can omit some of this hint and simply use the
95 updated Chapter 5 and Chapter 6 GCC installation instructions. More on this
96 in the appropriate sections later in the hint.
97
98 =========================
99 2. THE TREELANG COMPILER:
100 =========================
101
102 You probably don't need the Treelang compiler. It is only good for
103 developers who are developing a new compiler for GCC. However, if you wish
104 to build it during a build of LFS, you'll need to install the Bison and Flex
105 packages before starting the Chapter 6 build of GCC.
106
107 ========================
108 3. THE FORTRAN COMPILER:
109 ========================
110
111 Starting with version 4.x.x of GCC, there is no longer support for the
112 Fortran 77 series of compilers. Fortran 95 is now included with GCC. In
113 order to build the Fortran 95 compiler, the system must have the GMP and
114 MPFR packages installed. See the "REQUIRED DOWNLOADS" section above for
115 links to information about these packages.
116
117 Installing these packages in Chapter 5 may end up producing undesireable
118 results as GCC may look for bits of these packages later in a /tools
119 directory which won't exist any longer. So, it is safer to install these
120 packages in Chapter 6. Installation of packages is somewhat wierd before GCC
121 is installed in Chapter 6, but using the extra parameters shown below seemed
122 to get GMP, MPFR and Fortran 95 installed correctly.
123
124 Both of these packages should be built after Binutils and before GCC in
125 Chapter 6. GMP should be installed first.
126
127 ----------------
128 GMP Installation
129 ----------------
130
131 In order to build the GMP C++ extension library (by passing --enable-cxx
132 parameter to configure), you'll need to fake an installation of the libstdc++
133 library in /usr/lib of the new LFS partition. Issue the two commands below
134 before building the GMP package to provide temporary symlinks to the library
135 in the /tools/lib directory:
136
137 ln -v -s /tools/lib/libstdc++.so.6 /usr/lib
138 ln -v -s /tools/lib/libstdc++.so   /usr/lib
139
140 Additionally, you'll need to install the M4 package at the end of Chapter 5
141 or before the GMP installation in Chapter 6. You can use the existing LFS
142 Chapter 6 instructions for installing the M4 package.
143
144 -----------------
145 MPFR Installation
146 -----------------
147
148 The installation of MPFR must also be slightly modified at this point for
149 a good installation. I found that I had to add --with-gmp-include=/usr/include
150 to the configure script so MPFR could find GMP's library interface header.
151 Here are the commands I used to install MPFR:
152
153 ./configure --prefix=/usr \
154             --enable-thread-safe \
155             --enable-shared \
156             --with-gmp-include=/usr/include
157 make
158 make html
159 make check
160 make install
161
162 ----------------
163 GCC Installation
164 ----------------
165
166 At this point (GMP and MPFR installations complete), you can add the fortran
167 language to the --enable-languages switch on GCC's configure and expect it
168 to successfully build Fortran 95. However, you also need to add a couple
169 more parameters to the configure script so that configure can find the two
170 packages you just installed. I'm not certain, but apparently it must look
171 in /tools for these packages, so parameters are added to configure to tell
172 it to look in /usr. Add these two parameters to GCC's configure script:
173
174         --with-mpfr=/usr
175         --with-gmp=/usr
176
177 The complete command I used to install all the compilers was:
178
179 ../gcc-4.0.3/configure \
180         --prefix=/usr \
181         --libexecdir=/usr/lib \
182         --enable-shared \
183         --enable-threads=posix \
184         --enable-__cxa_atexit \
185         --enable-clocale=gnu \
186         --with-mpfr=/usr \
187         --with-gmp=/usr \
188         --enable-languages=c,c++,objc,fortran,ada,java,treelang
189
190 ====================
191 4. THE ADA COMPILER:
192 ====================
193
194 Starting with version 4.x.x of GCC, the Ada installation is simpler, but it
195 still requires an initial boostrap using an existing Ada compiler. If you
196 have an Ada compiler on the host system you're building LFS on, there
197 isn't much required before you can just build GCC.
198
199 ========================
200 5. PACKAGE DEPENDENCIES:
201 ========================
202
203 As previously mentioned, if you already have an existing Ada compiler on the
204 host system, you won't need to install the GNAT binary Ada compiler. You can
205 skip to step 7 and configure your path.
206
207 If you don't have an existing Ada compiler, you'll need to install the GNAT
208 binary version available from the URL shown in the "REQUIRED DOWNLOADS"
209 section at the beginning of the hint.
210
211 ====================================
212 6. INSTALLING THE GNAT ADA COMPILER:
213 ====================================
214
215 You'll need to install the GNAT Ada compiler before starting the Chapter 5
216 GCC-Pass1 instructions in the LFS book. This is right after the Binutils-Pass1
217 installation.
218
219 Here's the simple installation procedure for the GNAT Ada compiler:
220
221 1. Download the tarball from the Adacore site.
222
223 2. Unpack the tarball and change directories into the root of the source tree.
224
225 3. Issue the following command to install the GNAT compiler:
226
227 make ins-all prefix=/tools/gnat
228
229 You should check and ensure that the /tools/gnat directory was created and
230 populated with files. The GNAT source tree can then be removed.
231
232 =================================
233 7. CONFIGURING THE PATH VARIABLE:
234 =================================
235
236 You'll need to modify the PATH variable so that the newly installed GNAT
237 compiler is used to bootstrap GCC. Issue the following commands:
238
239 PATH_HOLD=$PATH
240 export PATH=/tools/gnat/bin:$PATH_HOLD
241
242 Ensure your PATH variable was changed properly:
243
244 echo $PATH
245
246 And if you have the 'which' command installed on your host:
247
248 which gcc
249
250 NOTE: if you're using an existing Ada compiler from your host, make the
251 appropriate substitutions above so this compiler is invoked by the 'gcc'
252 command.
253
254 =====================================
255 8. CHAPTER 5 GCC-PASS1 MODIFICATIONS:
256 =====================================
257
258 There's some changes required to the Chapter 5 installation of GCC-Pass1.
259
260 1. You'll need to unpack the gcc-ada tarball along with the gcc-core tarball
261 so the GCC Ada sources are available. Alternatively, just unpack the combined
262 GCC tarball which contains all the compilers.
263
264 2. Modify the ./configure command to pass --enable-languages=c,ada
265 (Note the addition of ",ada")
266
267 Except for the changes shown above, follow the commands as outlined in the
268 Chapter 5 GCC-Pass1 instructions in LFS.
269
270 If desired, remove the /tools/gnat directory at the conclusion of the
271 Chapter 5 GCC-Pass1 instructions, as the GNAT compiler won't be required any
272 longer. All remaining GCC installations are done using the now existing GCC
273 version of Ada.
274
275 ===================================
276 9. RECONFIGURING THE PATH VARIABLE:
277 ===================================
278
279 Now that you are done with the GNAT compiler, put your PATH variable back
280 like it was using the following commands:
281
282 export PATH=$PATH_HOLD
283 unset PATH_HOLD
284
285 Ensure your PATH variable was changed properly:
286
287 echo $PATH
288
289 And if you have the 'which' command installed on your host:
290
291 which gcc
292 which gnat
293
294 =====================================
295 10. CHAPTER 5 GCC-PASS2 MODIFICATIONS:
296 =====================================
297
298 There's some changes required to the Chapter 5 installation of GCC-Pass2.
299
300 1. You'll need to unpack the gcc-ada tarball along with the gcc-core and
301 gcc-g++ tarballs so the GCC Ada sources are available. Alternatively, just
302 unpack the combined GCC tarball which contains all the compilers.
303
304 2. Modify the ./configure command to pass --enable-languages=c,c++,ada
305 (Note the addition of ",ada")
306
307 Except for the changes shown above, follow the commands as outlined in
308 the Chapter 5 GCC-Pass2 instructions in LFS.
309
310 ===================================
311 11. CHAPTER 5 NCURSES MODIFICATIONS:
312 ===================================
313
314 Remove the --without-ada switch in the Chapter 5 installation of the Ncurses
315 package if you desire for Ncurses to be Ada-aware and build the Ada hooks.
316 I'm not real sure this is required in Chapter 5, but I've never bothered to
317 test and see. I just remove the switch and let it build the Ada components.
318
319 ===============================
320 12. CHAPTER 6 GCC MODIFICATIONS:
321 ===============================
322
323 There's some changes required to the Chapter 6 installation of GCC.
324
325 1. You'll need to unpack the gcc-ada tarball along with the gcc-core and
326 gcc-g++ tarballs so the GCC Ada sources are available. Alternatively, just
327 unpack the combined GCC tarball which contains all the compilers. At this
328 point also decide if you'd like to install additional (or all) compilers.
329 There's nothing keeping you from installing all of the compilers included
330 in the GCC source tarball (providing you followed the other instructions in
331 this hint for Fortran 95 and Treelang). Do remember to also unpack the
332 testsuite tarball if you used the individual compiler tarballs.
333
334 2. Modify the ./configure command to pass --enable-languages=c,c++,ada
335 (Note the addition of ",ada")
336
337 ***** Alternatively, use --enable-languages=all, or add any other additional
338 ***** compilers on the --enable-languages= parameter.
339
340 3. After the "make install" step, issue the following command:
341
342 chown -v -R root:root /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/adainclude
343 (modify the GCC version number in the path shown above)
344
345 Except for the changes shown above, follow the commands as outlined in the
346 Chapter 6 GCC instructions in LFS.
347
348 ===================================
349 13. CHAPTER 6 NCURSES MODIFICATIONS:
350 ===================================
351
352 If you installed an Ada compiler and you didn't use a parameter to the
353 Ncurses configure script to prevent it from building the Ncurses Ada
354 components, issue the following command to change the ownership of some
355 installed files to the root user.
356
357 chown -v -R root:root /usr/lib/ada/adainclude
358
359 ===========
360 14. CLOSING:
361 ===========
362
363 Following these easy instructions allows you to install the full suite of
364 GCC compilers during your LFS build, eliminating the time-consuming and
365 perhaps risky process of reinstalling C and C++ later on during your BLFS
366 adventure.
367
368
369 ACKNOWLEDGEMENTS:
370
371 * Jim Gifford for the tip about using the existing Makefile to install GNAT.
372 * The LFS community for creating and maintaining such a cool project.
373
374
375 CHANGELOG:
376
377 [2007-07-01]
378     * Updated the Gnat download instructions
379     * Updated the requirements to install the 'treelang' language
380     * Updated the GMP installation instructions
381
382 [2006-05-18]
383     * Changed the GNAT installation to use the existing Makefile, which
384       eliminates the need to install Tcsh.
385
386 [2006-05-03]
387     * Updated for the LFS-6.2 version, including installing the 4.0.3
388       compiler. Added instructions to install all the compilers, not just
389       the Ada compiler.
390
391 [2005-03-14]
392     * Fixed typo
393     * Modified the Chapter 5 instructions to not use forced static build
394
395 [2005-03-13]
396     * Added instructions to change the ownership of the Ada interface header
397       include files to root
398
399 [2005-03-12]
400     * Original draft
401
Note: See TracBrowser for help on using the browser.