/[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.12 - (hide annotations) (download) (as text)
Wed Mar 1 20:17:49 2006 UTC (8 years, 4 months ago) by jkt
Branch: MAIN
Changes since 1.11: +3 -18 lines
File MIME type: application/xml
Removed redundant notes about the need to substitute GCC version and CHOST settings

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

  ViewVC Help
Powered by ViewVC 1.1.20