GCC Compiler Versions

Section 4.2 of the installation instructions (Introduction to SUSE Linux Enterprise Server for the Raspberry Pi) strongly recommends the use of ‘gcc-6’, which is GCC V6.2.1, rather than the default gcc/cc which is V4.8.5.

I assume that this cannot be done for everything - otherwise the old compiler would have just been replaced. Can anyone tell me what requires the older 4.8.5 compiler such that it has to be made the default?

Which compiler was used to build the kernel (assuming kernel modules need to be built with the same one)?


To see the gcc version used to compile the kernel is…

cat /proc/version
Linux version 4.4.74-92.29-default (geeko@buildhost) (gcc version 4.8.5 (SUSE Linux) ) #1 SMP Thu Jun 29 13:06:32 UTC 2017 (561ddb1)

As for the rest, I would assume it’s the default gcc (4.8.5) but would use gcc6 for my own code…

Ah yes, thanks. I forgot that the kernel version string includes the compiler used. I suppose the compiler used to build the kernel explains why the two compilers are supplied - although not why the old one is the default. It also makes me wonder what it is about the newer gcc which prevents it being used for kernel build…

It sounds easy to say ‘use gcc6 for my own code’, but in practice it is a bit tedious to have a special case on SUSE if you are trying to maintain a lot of software on a lot of different platforms. If I rsync my source tree to do a test build on SUSE, there would be a lot of makefiles to customize.

As a work around, I created the following script to switch the default between the two compilers:


Switch default compiler between 4.8 and 6

if [ “$#” != “1” ] ;then

case “$arg” in
[INDENT] orig) VER=4.8 ;;
new) VER=6 ;;

            echo "Usage: $0 {orig|new}"
            exit 1 ;;[/INDENT]


echo “Switching to compiler version $VER”
cd /usr/bin
for LINK in gcov g++ gcc gcc-ar gcc-nm gcc-ranlib cpp c++ cc
[ “$TGT” = “c++” ] && TGT=g++
[ “$TGT” = “cc” ] && TGT=gcc
rm -f $LINK

Now I just need to remember to switch defaults back to the old compiler when I do kernel builds…

Look at using update-alternatives, have a look at this howto;

Just export your CC or CXX to point at relevant versions…?

Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.2|GNOME 3.20.2|4.4.74-18.20-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!


Thanks - that does look like a better way of doing what I have done. Of course both solutions still seem a little clumsy because they have to be done on a system wide basis using administrator privilege.

Makes me wonder if it wouldn’t perhaps be better to implement such alternatives in a more flexible way, that is better suited to a multi-user system. for example, having /usr/bin/gccx.y directories, with compiler components having their standard names in each. The symlinks would then be, for example, gcc-ar → gcc4.8/gcc-ar etc.

The advantage would be that any user could locally force one or other option by putting /usr/bin/gccx.y in their path before /usr/bin.