Networking and Internet #c#linux 1 min

gcc-config: choosing which installed GCC version to use

Translation of the original in Catalan. Read it in: CatalàCastellano

I'm a bit out of it; some time ago, with the gentoo updates, I had noticed that the sys-devel/gcc-config package got installed. Although I knew it was used to decide which version of GCC things will be compiled with, I had never tried to configure it. So a while ago, for no particular reason, I thought of it.

A short summary of how to use the command:

Which version of GCC we are using:

root@mini2 ~ # gcc-config -c
i686-pc-linux-gnu-3.3.6

List of versions ready to use:

root@mini2 ~ # gcc-config -l
 [1] i686-pc-linux-gnu-3.3.6 *
 [2] i686-pc-linux-gnu-3.3.6-hardened
 [3] i686-pc-linux-gnu-3.3.6-hardenednopie
 [4] i686-pc-linux-gnu-3.3.6-hardenednopiessp
 [5] i686-pc-linux-gnu-3.3.6-hardenednossp
 [6] i686-pc-linux-gnu-3.4.5
 [7] i686-pc-linux-gnu-3.4.5-hardened
 [8] i686-pc-linux-gnu-3.4.5-hardenednopie
 [9] i686-pc-linux-gnu-3.4.5-hardenednopiessp
 [10] i686-pc-linux-gnu-3.4.5-hardenednossp

We switch to version 3.4.5 of GCC:

root@mini2 ~ # gcc-config i686-pc-linux-gnu-3.4.5
 * Switching native-compiler to i686-pc-linux-gnu-3.4.5 ...
>>> Regenerating /etc/ld.so.cache...                                                                     [ ok ]
 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:
 *   # source /etc/profile

We can see that it has already changed the version for me:

root@mini2 ~ # gcc-config -l
 [1] i686-pc-linux-gnu-3.3.6
 [2] i686-pc-linux-gnu-3.3.6-hardened
 [3] i686-pc-linux-gnu-3.3.6-hardenednopie
 [4] i686-pc-linux-gnu-3.3.6-hardenednopiessp
 [5] i686-pc-linux-gnu-3.3.6-hardenednossp
 [6] i686-pc-linux-gnu-3.4.5 *
 [7] i686-pc-linux-gnu-3.4.5-hardened
 [8] i686-pc-linux-gnu-3.4.5-hardenednopie
 [9] i686-pc-linux-gnu-3.4.5-hardenednopiessp
 [10] i686-pc-linux-gnu-3.4.5-hardenednossp