/[gentoo]/xml/htdocs/doc/en/gcc-upgrading.xml
Gentoo

Contents of /xml/htdocs/doc/en/gcc-upgrading.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (hide annotations) (download) (as text)
Thu Sep 7 11:06:40 2006 UTC (7 years, 7 months ago) by rane
Branch: MAIN
Changes since 1.19: +3 -3 lines
File MIME type: application/xml
fixing a typo in the halcy0n's mail address

1 jkt 1.1 <?xml version='1.0' encoding="UTF-8"?>
2 rane 1.20 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/gcc-upgrading.xml,v 1.19 2006/09/06 02:14:24 vapier Exp $ -->
3 jkt 1.1
4     <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
5    
6     <guide link="/doc/en/gcc-upgrading.xml">
7 vapier 1.19 <title>Gentoo GCC Upgrade Guide</title>
8 jkt 1.1
9     <author title="Author">
10     <mail link="amne@gentoo.org">Wernfried Haas</mail>
11     </author>
12     <author title="Author">
13     <mail link="jkt@gentoo.org">Jan Kundr├ít</mail>
14     </author>
15     <author title="Editor">
16 rane 1.20 <mail link="mark@halcy0n.com">Mark Loeser</mail>
17 jkt 1.1 </author>
18    
19     <abstract>
20     This document will guide the user through the process of upgrading GCC on their
21 vapier 1.19 Gentoo machines.
22 jkt 1.1 </abstract>
23    
24     <!-- The content of this document is licensed under the CC-BY-SA license -->
25     <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
26     <license/>
27    
28 rane 1.20 <version>18</version>
29 jkt 1.18 <date>2006-09-06</date>
30 jkt 1.1
31     <chapter id="intro">
32     <title>Introduction</title>
33     <section>
34     <title>GCC Upgrading</title>
35     <body>
36    
37     <p>
38     Why should you upgrade? Well, GCC is quite similar to any other package on your
39     system, just a bit more critical. You should upgrade GCC whenever a new version
40     fixes some bug that annoys you, new functionality you need is introduced, or if
41     you want to keep your system up-to-date. If none of the previous cases apply to
42     you, you can safely postpone upgrade as long as your GCC version is supported by
43     Gentoo developers.
44     </p>
45    
46     <p>
47 vapier 1.15 If you install a new major version of GCC (such as 3.3.6 to 3.4.5), the system
48     will not switch over to use it automatically. You'll have to explicitly request
49     the change because the migration process might require some additional steps.
50     If you decide not to switch, Portage will continue to use older version of your
51     compiler until you change your mind, or remove the old compiler from the system.
52     Non-major gcc upgrades are switched automatically for you (such as 3.4.5 to
53     3.4.6).
54 jkt 1.1 </p>
55    
56     <p>
57     This guide will document the necessary steps required to perform a seamless
58 neysx 1.6 upgrade of the compiler used by your Gentoo box. A specific section is
59     dedicated to the <uri link="#upgrade-3.3-to-3.4">upgrade from GCC 3.3 to 3.4 or
60     greater versions</uri> and issues with <c>libstdc++</c>. A second specific
61     section is for users <uri link="#first-install">first installing</uri> Gentoo
62     using a stage3 tarball, after a new GCC major/minor version has been released.
63 jkt 1.1 </p>
64    
65 nightmorph 1.13 <warn>
66     It should be noted that upgrading from GCC-3.4 to GCC-4.1 or greater still
67 jkt 1.18 requires you to follow the <uri link="#upgrade-general">general upgrading
68     instructions</uri>, as GCC-3.4 and GCC-4.1 use slightly different ABIs.
69 nightmorph 1.13 </warn>
70 neysx 1.6
71 jkt 1.1 </body>
72     </section>
73     </chapter>
74    
75     <chapter id="upgrade-general">
76     <title>General Upgrade Instructions</title>
77     <section>
78     <title>Introduction</title>
79     <body>
80    
81     <impo>
82 neysx 1.6 If you're looking for instructions specific to upgrades from GCC-3.3 to GCC-3.4
83     or greater, please consult the <uri link="#upgrade-3.3-to-3.4">dedicated
84     section</uri>.
85     </impo>
86    
87     <impo>
88     If you're looking for instructions specific to upgrades in GCC for new
89     installs, please consult the <uri link="#first-install">dedicated
90 jkt 1.1 section</uri>.
91     </impo>
92    
93     <p>
94     Generally speaking, upgrades to <e>bug fix releases</e>, like from 3.3.5 to
95     3.3.6, should be quite safe -- just emerge new version, switch your system to
96     use it and rebuild the only affected package, <c>libtool</c>. However, some GCC
97     upgrades break binary compatibility; in such cases a rebuild of the affected
98     packages (or even whole toolchain and system) might be required.
99     </p>
100    
101     <p>
102     When we spoke about the need to switch your compiler to the newer version by
103     hand, we said it won't happen automatically. However, there is one exception --
104     upgrades to bug fix releases, like from 3.3.5 to 3.3.6 in case you don't use the
105     "multislot" feature allowing them to coexist on one system. Multislot is
106     disabled by default as the majority of users won't benefit from it.
107     </p>
108    
109     <pre caption="Upgrading GCC">
110     # <i>emerge -uav gcc</i>
111    
112 nightmorph 1.14 <comment>(Please substitute "i686-pc-linux-gnu-4.1.1" with the GCC
113 jkt 1.1 version and CHOST settings you've upgraded to:)</comment>
114 nightmorph 1.14 # <i>gcc-config i686-pc-linux-gnu-4.1.1</i>
115 jkt 1.1 # <i>source /etc/profile</i>
116    
117 nightmorph 1.14 <comment>If you upgraded from gcc 3 to 4 (e.g. from 3.4.6 to 4.1.1 in this
118     example) you will have to run fix_libtool_files.sh manually</comment>
119     # <i>fix_libtool_files.sh 3.4.6</i>
120    
121 jkt 1.1 <comment>(Rebuilding libtool)</comment>
122     # <i>emerge --oneshot -av libtool</i>
123     </pre>
124    
125     <p>
126 nightmorph 1.14 To be completely safe that your system is in a sane state, you <e>must</e>
127     rebuild the toolchain and then world to make use of the new compiler.
128 jkt 1.1 </p>
129    
130     <pre caption="Rebuilding system">
131     # <i>emerge -eav system</i>
132     # <i>emerge -eav world</i>
133     </pre>
134    
135     <p>
136 neysx 1.6 It is safe to remove the older GCC version at this time. If you feel the need,
137     please issue the following command (as usual, substitute
138 nightmorph 1.14 <c>=sys-devel/gcc-3.4*</c> with the version you want to uninstall):
139 jkt 1.1 </p>
140    
141     <pre caption="Removing older GCC version">
142 nightmorph 1.14 # <i>emerge -aC =sys-devel/gcc-3.4*</i>
143 jkt 1.1 </pre>
144    
145 jkt 1.18 <impo>
146     Please note that the GCC 4.1 and newer can't compile a 2.4 kernel. Don't remove
147     your old GCC version if you want to use an older kernel.
148     </impo>
149    
150 jkt 1.1 </body>
151     </section>
152     </chapter>
153    
154     <chapter id="upgrade-3.3-to-3.4">
155 neysx 1.6 <title>Upgrading from GCC-3.3 to 3.4 or greater</title>
156 jkt 1.1 <section>
157     <title>Introduction</title>
158     <body>
159    
160     <p>
161 neysx 1.6 The upgrade from GCC-3.3 to 3.4 or greater is not seamless as the C++ ABI
162     changed between these two versions. There is an issue with the <c>libstdc++</c>
163     library which must be taken care of, as well.
164 jkt 1.1 </p>
165    
166     </body>
167     </section>
168     <section id="upgrade-3.3-to-3.4-choices">
169     <title>The Choices</title>
170     <body>
171    
172 jkt 1.5 <impo>
173 jkt 1.18 If you upgrade from gcc 3.4 to 4.1, please consult the <uri
174     link="#upgrade-general">General Update instructions</uri>.
175 nightmorph 1.14 </impo>
176    
177     <impo>
178 jkt 1.5 If you're upgrading on a SPARC machine, you will have to take the way of
179     <uri link="#upgrade-3.3-to-3.4-emerge-e">complete system rebuild</uri> due to
180     some internal <uri link="http://gcc.gnu.org/gcc-3.4/sparc-abi.html">ABI
181     changes</uri> in GCC's parameter passing.
182     </impo>
183    
184 jkt 1.1 <p>
185 nightmorph 1.14 If you upgrade from gcc 3.3 to 3.4, you have two possibilities on how to
186     upgrade your system. The <uri link="#upgrade-3.3-to-3.4-revdep-rebuild">first
187     method</uri> is faster and requires use of the <c>revdep-rebuild</c> tool from
188     package <c>gentoolkit</c> while the <uri
189     link="#upgrade-3.3-to-3.4-emerge-e">second one</uri> rebuilds the entire
190     system from scratch so it will make use of new GCC features. It's up to you to decide which of these two ways you will choose. In most cases, the first
191     method is sufficient.</p>
192     <p>If you upgrade from gcc 3.3 to 4.1, do not use the method based on
193     revdep-rebuild, but do a <uri link="#upgrade-3.3-to-3.4-emerge-e">complete
194     system rebuild</uri>.
195 jkt 1.1 </p>
196    
197     </body>
198     </section>
199     <section id="upgrade-3.3-to-3.4-revdep-rebuild">
200     <title>Using revdep-rebuild</title>
201     <body>
202    
203     <p>
204     This method requires that you first install <c>gentoolkit</c> if you have not
205     already done so. Then we will upgrade GCC and switch to the new compiler. We
206 jkt 1.3 will also rebuild the <c>libtool</c> package to ensure that toolchain is in
207 jkt 1.1 healthy state.
208     </p>
209    
210     <pre caption="Installing gentoolkit and upgrading GCC">
211     # <i>emerge -an gentoolkit</i>
212     # <i>emerge -uav gcc</i>
213 vanquirius 1.11 <comment>(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC
214     version and CHOST settings you've upgraded to:)</comment>
215     # <i>gcc-config i686-pc-linux-gnu-3.4.5</i>
216 jkt 1.1 # <i>source /etc/profile</i>
217    
218     <comment>(Rebuilding libtool)</comment>
219     # <i>emerge --oneshot -av libtool</i>
220     </pre>
221    
222     <p>
223     Now, we want to see which packages that revdep-rebuild will want to rebuild.
224     Then we will tell revdep-rebuild to actually rebuild the packages. This may take
225     some time, so have some patience.
226     </p>
227    
228     <pre caption="Using revdep-rebuild">
229     # <i>revdep-rebuild --library libstdc++.so.5 -- -p -v</i>
230     # <i>revdep-rebuild --library libstdc++.so.5</i>
231     </pre>
232    
233     <note>
234     It is possible that you might have problems with non-existing package versions
235     due to them being outdated or masked. If this is the case, you will want to use
236     the <c>--package-names</c> option to <c>revdep-rebuild</c>. This causes packages
237     to be recompiled based on the package name, rather than the exact name and
238     version.
239     </note>
240    
241     <p>
242     To provide compatibility with older binary C++ applications and any packages
243     that revdep-rebuild might have missed, <c>sys-libs/libstdc++-v3</c> needs to be
244     merged before you unmerge GCC 3.3 from your system.
245     </p>
246    
247     <pre caption="Installing libstdc++-v3 and cleaning up">
248     # <i>emerge --oneshot sys-libs/libstdc++-v3</i>
249     # <i>emerge -aC =sys-devel/gcc-3.3*</i>
250     </pre>
251    
252     </body>
253     </section>
254     <section id="upgrade-3.3-to-3.4-emerge-e">
255     <title>Using emerge -e</title>
256     <body>
257    
258     <p>
259     This method, while much slower, will rebuild your whole system to ensure that
260     everything has been rebuilt with your new compiler, and therefore safer. At
261     first, you will upgrade GCC and libtool and switch to your new compiler.
262     </p>
263    
264     <pre caption="Upgrading GCC">
265     # <i>emerge -uav gcc</i>
266 vanquirius 1.11 <comment>(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC
267     version and CHOST settings you've upgraded to:)</comment>
268     # <i>gcc-config i686-pc-linux-gnu-3.4.5</i>
269 jkt 1.1 # <i>source /etc/profile</i>
270    
271 nightmorph 1.14 <comment>If you upgraded from gcc 3 to 4 (e.g. from 3.3.6 to 4.1.1 in this
272     example) you will have to run fix_libtool_files.sh manually</comment>
273     # <i>fix_libtool_files.sh 3.3.6</i>
274    
275 jkt 1.1 <comment>(Rebuilding libtool)</comment>
276     # <i>emerge --oneshot -av libtool</i>
277     </pre>
278    
279     <p>
280     To provide compatibility with older binary C++ applications,
281     <c>sys-libs/libstdc++-v3</c> needs to be merged onto your system.
282     </p>
283    
284     <pre caption="Installing libstdc++-v3">
285     # <i>emerge --oneshot sys-libs/libstdc++-v3</i>
286     </pre>
287    
288     <p>
289     Now we will go about first rebuilding the system target, then the world target.
290     This will take a very long time, depending on the number of packages that you
291     have installed, as it will rebuild your entire toolchain and supporting system
292     files, followed by every package on your system, including the toolchain. This
293     is necessary to ensure that all packages have been compiled with the new
294     toolchain, including the toolchain itself.
295     </p>
296    
297     <pre caption="Rebuilding system and world">
298     # <i>emerge -e system</i>
299     # <i>emerge -e world</i>
300     </pre>
301    
302     <p>
303     It is also safe to remove older GCC versions at this time:
304     </p>
305    
306     <pre caption="Cleaning up">
307     # <i>emerge -aC =sys-devel/gcc-3.3*</i>
308     </pre>
309    
310     </body>
311     </section>
312     </chapter>
313    
314 neysx 1.6 <chapter id="first-install">
315     <title>Upgrading to GCC on a First Install</title>
316     <section>
317     <title>Introduction</title>
318     <body>
319    
320     <p>
321     A GCC upgrade on a system after installation from a stage3 tarball is a simple
322     affair. One advantage users of new installations have is they do not have a
323     plethora of software installed that links against the older version of GCC.
324     The following example is for a GCC-3.3 to 3.4 or greater upgrade. Certain parts
325     will be different if upgrading from other versions of GCC. For example, the
326     library names used for <c>revdep-rebuild</c> below are GCC 3.3 specific, as
327     well as the need to install <c>libstdc++-v3</c>.
328     </p>
329    
330     <p>
331     If a user has not made any customizations to their system yet, then there are
332     very few steps to get their system upgraded to a new GCC version. As with the
333     GCC-3.3 to 3.4 upgrade, the user has a couple options. However, unlike the
334     GCC-3.3 to 3.4 upgrade, this one is less complicated as there are fewer
335     differences between the methods. The <uri
336     link="#first-install-revdep-rebuild">first method</uri> is faster and makes use
337     of the <c>revdep-rebuild</c> tool from <c>gentoolkit</c>, similar to the above
338     procedure. Using revdep-rebuild causes only packages which actually link
339     against GCC libraries to be rebuilt, while the <uri
340     link="#first-install-emerge-e">second method</uri> causes your entire new
341     install to be recompiled with the new GCC version and takes much longer. This
342     second method is never required and only documented for completeness.
343     </p>
344    
345     <p>
346     These first steps are common between both methods, and should be completed by
347     everyone.
348     </p>
349    
350     <pre caption="Upgrading GCC">
351     # <i>emerge -uav gcc</i>
352 vanquirius 1.11 <comment>(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC
353     version and CHOST settings you've upgraded to:)</comment>
354     # <i>gcc-config i686-pc-linux-gnu-3.4.5</i>
355 neysx 1.6 # <i>source /etc/profile</i>
356    
357     <comment>(Rebuilding libtool)</comment>
358     # <i>emerge --oneshot -av libtool</i>
359     </pre>
360    
361     <p>
362     To provide compatibility with older binary C++ applications,
363     <c>sys-libs/libstdc++-v3</c> needs to be merged onto your system.
364     </p>
365    
366     <pre caption="Installing libstdc++-v3">
367     # <i>emerge --oneshot sys-libs/libstdc++-v3</i>
368     </pre>
369    
370     </body>
371     </section>
372    
373     <section id="first-install-revdep-rebuild">
374     <title>Using revdep-rebuild</title>
375     <body>
376    
377     <p>
378     This method requires that you first install <c>gentoolkit</c> if you have not
379     already done so. We will then run <c>revdep-rebuild</c> to actually scan the
380     installed packages for ones we need to rebuild, then rebuild them.
381     </p>
382    
383     <pre caption="Installing gentoolkit and running revdep-rebuild">
384     # <i>emerge -an gentoolkit</i>
385     # <i>revdep-rebuild --library libstdc++.so.5 -- -p -v</i>
386     # <i>revdep-rebuild --library libstdc++.so.5</i>
387     </pre>
388    
389     <note>
390     It is possible that you might have problems with non-existing package versions
391     due to them being outdated or masked. If this is the case, you will want to use
392     the <c>--package-names</c> option to <c>revdep-rebuild</c>. This causes packages
393     to be recompiled based on the package name, rather than the exact name and
394     version.
395     </note>
396    
397     </body>
398     </section>
399     <section id="first-install-emerge-e">
400     <title>Using emerge -e</title>
401     <body>
402    
403     <p>
404     This method, while much slower, will rebuild the system target to ensure that
405     everything has been rebuilt with your new compiler. This is not necessary, but
406     is valid if you are also making changes to CFLAGS or other make.conf variables
407     that will affect the system compile.
408     </p>
409    
410     <p>
411     Since we are performing these actions after an initial installation, we do not
412 jkt 1.10 need to recompile the <c>world</c> target as we would when doing an upgrade on
413     an already installed system. However, you may choose to perform a world update
414     in place of the system update, to ensure that all packages are updated.
415 neysx 1.6 </p>
416    
417     <pre caption="Rebuilding system">
418     # <i>emerge -e system</i>
419     </pre>
420    
421 jkt 1.10 </body>
422     </section>
423     <section id="first-install-cleaning-up">
424     <title>Cleaning up</title>
425     <body>
426    
427 neysx 1.6 <p>
428 jkt 1.7 It is also safe to remove older GCC versions at this time. Please substitute
429     <c>YOUR-NEW-GCC-VERSION</c> with the actual version you've upgraded to:
430 neysx 1.6 </p>
431    
432     <pre caption="Cleaning up">
433 jkt 1.7 # <i>emerge -aC "&lt;sys-devel/gcc-YOUR-NEW-GCC-VERSION"</i>
434 neysx 1.6 </pre>
435    
436     </body>
437     </section>
438 jkt 1.1 </chapter>
439 jkt 1.8
440     <chapter id="common-pitfalls">
441     <title>Common Pitfalls</title>
442     <section>
443     <body>
444    
445     <p>
446     It's important to disable <c>distcc</c> during upgrade. Mixing compiler versions
447     on your nodes <e>will</e> cause build issues. This is not required for ccache,
448     as the cache objects will be invalidated anyway.
449     </p>
450    
451     <p>
452     Always use same GCC version for your kernel and additional kernel modules. Once
453     you rebuild your world with new GCC, external modules (like
454 nightmorph 1.14 <c>app-emulation/qemu-softmmu</c>) will fail to load. Please rebuild your
455     kernel with the new GCC to fix that.
456 jkt 1.8 </p>
457    
458 jkt 1.9 <p>
459     If you're upgrading on a SPARC machine, make sure to rerun <c>silo -f</c> after
460     re-emerging world to avoid possible issues.
461     </p>
462    
463 jkt 1.8 </body>
464     </section>
465     <section>
466     <title>Frequent Error Messages</title>
467     <body>
468    
469     <p>
470     If your system complains about something like <e>libtool: link:
471     `/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.la' is not a valid libtool
472     archive</e>, please run <c>/sbin/fix_libtool_files.sh 3.3.6</c> (substitute
473     "3.3.6" with the version numbers from the error message).
474     </p>
475    
476     <p>
477 nightmorph 1.14 If you see <e>error: /usr/bin/gcc-config: line 632:
478 jkt 1.8 /etc/env.d/gcc/i686-pc-linux-gnu-3.3.5: No such file or directory</e>, then try
479     deleting <path>/etc/env.d/gcc/config-i686-pc-linux-gnu</path> and running
480 nightmorph 1.14 <c>gcc-config</c> again, followed by <c>source /etc/profile</c>. Only do this
481     if you do not have any cross-compilers set up, though.
482 jkt 1.8 </p>
483    
484     <p>
485     If a package fails during <c>emerge -e system</c> or <c>emerge -e world</c>,
486     you can resume operation with <c>emerge --resume</c>. If a package fails
487     repeatedly, skip it with <c>emerge --resume --skipfirst</c>. Don't run any
488     other instances of emerge in between or you will lose the resume information.
489     </p>
490    
491     <p>
492     If you get an error message <e>spec failure: unrecognized spec option</e> while
493     upgrading your compiler, try to switch back to your default compiler, unset the
494     <c>GCC_SPECS</c> variable and upgrade GCC again:
495     </p>
496    
497     <pre caption="Restoring primary specs">
498     # <i>gcc-config 1</i>
499     # <i>source /etc/profile</i>
500     # <i>unset GCC_SPECS</i>
501     # <i>emerge -uav gcc</i>
502     </pre>
503    
504     </body>
505     </section>
506     </chapter>
507 jkt 1.1 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20