I was having problems finding info on how to install and switch between multiple installed GCC version.
Some old programs require GCC-3 to compile and as we all know at the moment we use GCC-4.4.4 so my compile failed.
Instead of recoding the qemu project which i needed to compile i installed GCC-3.4.6-r2 and then found a handy method of switching between compilers quickly.
I thought i would share it as a tip and trick.
Note here if you use CFLAGS="-O2 -march=native" in your /etc/make.conf you will need to change thhis. I made a second line temporarily commenting out the #CFLAGS="-O2 -march=native" with the sharp sign then i added CFLAGS="-O2 -march=pentium4" This is because GCC-3 does not have the feature to automatically detect your CPU features. This is one of the great benefits of GCC-4 but hey. After you are done and switch back to GCC-4 just edit your /etc/make.conf and swap the sharp sign# to comment in native and comment out the pentium4 and your all good.
First of lets unmask GCC versions this gives us access to install masked versions. Note you may not need do this step so i suggest first try it without unmasking with keywords and just jump to the next step. If its masked or not found then do the unmasking.
Quote: |
# echo "sys-devel/gcc ~x86" >> /etc/portage/package.keywords |
Next we need to verify its being installed in a new slot (NS)
Quote: |
# emerge -av =sys-devel/gcc-3.4.6-r2 |
It should say in [ NS ] if it does your good to go so say yes. Of course this is for version 3.4.6-r6 if you want a different version adjust accordingly. The = sign is crucial for those that dont know.
After this has completed the magic switching and listing commands are as follows:
To switch to the 3.4.6 do this
Quote: |
# gcc-config i686-pc-linux-gnu-3.4.6 |
To List the available versions you have installed and can switch to(its an lower cap L):
Quote: |
# gcc-config -l |
To switch back to version 4.4.4 or whichever higher version you have installed(use list command above to list which they are)
Quote: |
# gcc-config i686-pc-linux-gnu-4.4.4 |
Thats it, this is how you can have multiple versions of GCC installed and switch between them as and when needed. I understand it is very rare in many cases to do this probably 1 out of 2000 possible packages this maybe handy. Again due to the serious lack of information on this out there across the web i felt a need to make sure it was documented.
I am sure and hope it would help someone.
_________________
ليست هناك تعليقات:
إرسال تعليق