Results 1 to 5 of 5

Thread: GCC Compiler Versions

Hybrid View

  1. #1

    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)?

    Thanks,
    DigbyT

  2. Re: GCC Compiler Versions

    Hi
    To see the gcc version used to compile the kernel is..
    Code:
    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...
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Re: GCC Compiler Versions

    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:


    #!/bin/sh
    # Switch default compiler between 4.8 and 6
    #

    if [ "$#" != "1" ] ;then
    arg=help
    else
    arg=$1
    fi

    case "$arg" in
    orig) VER=4.8 ;;
    new) VER=6 ;;
    *)

    echo "Usage: $0 {orig|new}"
    exit 1 ;;
    esac

    echo "Switching to compiler version $VER"
    cd /usr/bin
    for LINK in gcov g++ gcc gcc-ar gcc-nm gcc-ranlib cpp c++ cc
    do
    TGT=$LINK
    [ "$TGT" = "c++" ] && TGT=g++
    [ "$TGT" = "cc" ] && TGT=gcc
    echo SETTING UP $LINK to $TGT-$VER
    rm -f $LINK
    ln -s $TGT-$VER $LINK
    done

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

  4. Re: GCC Compiler Versions

    On Thu 20 Jul 2017 01:14:02 AM CDT, digbyt wrote:

    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:



    #!/bin/sh
    # Switch default compiler between 4.8 and 6
    #

    if [ "$#" != "1" ] ;then

    arg=help
    else

    arg=$1
    fi

    case "$arg" in

    orig) VER=4.8 ;;
    new) VER=6 ;;
    *)

    echo "Usage: $0 {orig|new}"
    exit 1 ;;
    esac

    echo "Switching to compiler version $VER"
    cd /usr/bin
    for LINK in gcov g++ gcc gcc-ar gcc-nm gcc-ranlib cpp c++ cc
    do

    TGT=$LINK
    [ "$TGT" = "c++" ] && TGT=g++
    [ "$TGT" = "cc" ] && TGT=gcc
    echo SETTING UP $LINK to $TGT-$VER
    rm -f $LINK
    ln -s $TGT-$VER $LINK
    done

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


    Hi
    Look at using update-alternatives, have a look at this howto;
    https://en.opensuse.org/User:Tsu2/gc...e-alternatives

    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!


  5. #5

    Re: GCC Compiler Versions

    Hi,

    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.

    Regards,
    DigbyT

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •