[GUIDE][LINUX] Switching to a custom toolchain [ARM][AARCH64][SM/Linaro/UBER]

Search This thread

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
Introduction
Since the only guide I could find for switching toolchains in Android is one on linaro from a few years ago in the Galaxy nexus forum, I decided to make one and post it here. Custom toolchains can provide an overall better android experience to the end user by increasing speed, buttery smoothness, and even fixing bugs! Note: They can also produce bugs on some devices/ROMs.

Preface:
There are two mainstream custom toolchains, SaberMod and Linaro, which provide different improvements. In short, SaberMod is built for max speed, while Linaro is built for some subtle speed increases with much more smoothness.
Click for ARM info
For ARM devices, there are also 2 different toolchains used in Android; arm-linux-androideabi, which compiles the ROM, and arm-linux-eabi, which compiles the kernel. The recommended version for androideabi is 4.9, but higher should be used once the bugs are worked out/if it works for your device.
Click for AARCH64 (ARM64) info
For 64 bit ARM devices, there is one main toolchain,; aarch64-linux, which compiles both the ROM and the kernel. The recommended version is 4.9, because as of now 5.0 won't work with the kernel without heavy revision.

Switching ARM Toolchains

Step 1:
Run the following commands from your source directory to download the 4.9 toolchain for ROM and 4.9 toolchain for kernel

If using Linaro:
Code:
 git clone -b linaro-4.9-arm-linux-androideabi https://github.com/ArchiDroid/Toolchain prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-linaro-4.8
Code:
git clone -b linaro-4.9-arm-linux-eabi https://github.com/ArchiDroid/Toolchain prebuilts/gcc/linux-x86/arm/arm-linux-eabi-linaro-4.9

If using SaberMod: Download from http://sabermod.com

If Using UBER
Code:
git clone https://bitbucket.org/UBERTC/arm-linux-androideabi-4.9.git prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-UB-4.8
Code:
git clone https://bitbucket.org/UBERTC/arm-eabi-4.9.git prebuilts/gcc/linux-x86/arm/arm-linux-eabi-UB-4.9

Step 2 :
Here's where things get a little tricky. Step 2 is different for different android sources. If you use a rom that has GCC Freedom, use the first method. If not, open the file in your source directory in gedit /build/core/combo/TARGET_linux-arm.mk and ctrl+f to search for "TARGET_GCC_VERSION_AND" without the quotes. If it's found, use the first method. If not, use method 2.

Method 1: To actually use the toolchains, you'll need to change a few things in /build/core/combo/TARGET_linux-arm.mk. An example of what you need to change is shown below:

Code:
ifeq ($(strip $(TARGET_GCC_VERSION_AND)),)
     TARGET_GCC_VERSION_AND := SM-4.9
     else
     TARGET_GCC_VERSION_AND := $(TARGET_GCC_VERSION_AND)
     endif
     ifeq ($(strip $(TARGET_GCC_VERSION_ARM)),)
     TARGET_GCC_VERSION_ARM := SM-4.9
     else
     TARGET_GCC_VERSION_ARM := $(TARGET_GCC_VERSION_ARM)
     endif
     # Specify Target Custom GCC Chains to use:
     TARGET_GCC_VERSION_AND := SM-4.8
     TARGET_GCC_VERSION_ARM := SM-4.9

Notice how the target versions are each listed in two places?(AND is for androideabi and ARM is eabi) Just change the versions at the bottom where it says to specify the custom toolchain to the suffix of the toolchain you chose, for example linaro-4.8 and
SM-4.9 . Save and your done!

Method 2: Open /build/envsetup.sh in gedit or another text editor and look for the following section of code:

Code:
export ANDROID_EABI_TOOLCHAIN=
    local ARCH=$(get_build_var TARGET_ARCH)
    case $ARCH in
        x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
            ;;
        arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
            ;;
        mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
            ;;
        *)
            echo "Can't find toolchain for unknown architecture: $ARCH"
            toolchaindir=xxxxxxxxx
            ;;
    esac
    if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
        export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
    fi
 
    unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
    case $ARCH in
        arm)
            toolchaindir=arm/arm-eabi-$targetgccversion/bin
            if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
                 export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
                 ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
            fi
            ;;

Look at the line "arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin" and change $targetgccversion to the suffix of the androideabi toolchain you downloaded in step 1, such as linaro-4.8. Now look at the lines

Code:
unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
    case $ARCH in
        arm)
            toolchaindir=arm/arm-eabi-$targetgccversion/bin

and change $targetgccversion to the suffix of the eabi toolchain you downloaded in step 1, such as linaro-4.9. Save your file and you did it!


Switching AARCH64 Toolchains

Both ROM and Kernel use the same toolchain for AARCH64, so we need to clone it first.
Step 1:
Run the following commands from your source directory to download the 4.8 toolchain for ROM and 4.9 toolchain for kernel

If using Linaro:
Code:
 git clone https://android.git.linaro.org/git-ro/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9-linaro.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-linaro-4.9

If using SaberMod 4.9:
Code:
git clone https://github.com/SaberMod/aarch64-linux-android-4.9.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-SM-4.9

Step 2:
To actually use the toolchain, you'll need to change a few things in /build/core/combo/TARGET_linux-arm64.mk. An example of what you need to change is shown below:
Code:
ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
TARGET_GCC_VERSION := 4.9
else
TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
endif
See where TARGET_GCC_VERSION is defined as 4.9? change 4.9 to your toolchain version, SM-4.9 or linaro-4.9, to switch toolchains. Save the file and you're golden!

Congrats, you just upgraded to better toolchains! Make sure you run "make clobber && rm -rf ~/.ccache" before your next build.
 
Last edited:

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
More Links

I decided to add Links to all (known/published) custom toolchains available with a short description of each! Feel free to tell me if I miss any.

SaberMod Git
SaberMod aims to optimize Android as much as possible, using only the latest and fastest sources for toolchains. SaberMod also uses its own fixes and patches for graphite, ISL, and other optimizations.
UBERTC Git
UBER is focused on well rounded performace, starting with a GNU base, and building up smoothness, and battery by using Linaro and AOSP patches
Linaro (Switch to Linaro branch)
Linaro is the toolchain of Linaro Group, focussing on adding better support for ARM based targets
ArchiToolchain (Also under branches)
ArchiToolchain's goal is minimalism, by simply optimizing for a variety of targets.
Boosted TC
Little is known about boosted TC other than it was based on SM, and is likely incompatible with Lollipop (for ROMs)
Hyper Toolchains
Hyper Toolchains combines popular toolchains (Currently SM, Uber and Linaro) in various ways to create unique results, without a main goal.
 
Last edited:

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
ok what about linaro 4.10. And yes it does exist.
You can use 4.9 and 4.10 for kernel build only.
Never managed to build a ROM with a toolchain above 4.8 .
Yep, 4.10 doesnt work with ROM's, and for kernels it can cause (somtimes) stability problems. And doesn't "exist" per say. It's not an official version of GCC. From my understanding, it's a watered down version of GCC 5.0 mixed with 4.9 because 5.0 is currently in development and doesn't work. It also doesn't provide too much of a performance boost, so I chose not to include it in the guide.
 

REV3NT3CH

Inactive Recognized Contributor
Dec 30, 2012
3,774
10,849
Crescent City
Yep, 4.10 doesnt work with ROM's, and for kernels it can cause (somtimes) stability problems. And doesn't "exist" per say. It's not an official version of GCC. From my understanding, it's a watered down version of GCC 5.0 mixed with 4.9 because 5.0 is currently in development and doesn't work. It also doesn't provide too much of a performance boost, so I chose not to include it in the guide.
Well I know that lol...I was more so being sarcastic...I do Dev Roms and kernels but use GCC freedom as I know its creator personally....
 

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
Well I know that lol...I was more so being sarcastic...I do Dev Roms and kernels but use GCC freedom as I know its creator personally....
Could you post a link to GCC Freedom? I've seen it mentioned but i havent been able to find much about it.

You're only causing unnecessary confusion. Specifying custom prefix and proper manifest entry works far better than hardcoding ANY version right in the android_build.
Yeah, but this is a beginer guide. It's meant for people who have started compiling ROM's and want to give it a little extra boost, and to be able to be applied to any source code with ease (and so you can have multiple toolchains incase you want to switch). People who are knowledgeable enough about android to the point where they add things to their roomservice.xml and have custom repo's probably wont need a guide. But thanks for the tip, it'll help more advanced people who read these posts, and also thanks for uploading the prebuilt linaro toolchains, It really makes it easy for everyone.
 
Last edited:
  • Like
Reactions: raja_mastana

REV3NT3CH

Inactive Recognized Contributor
Dec 30, 2012
3,774
10,849
Crescent City
Could you post a link to GCC Freedom? I've seen it mentioned but i havent been able to find much about it.


Yeah, but this is a beginer guide. It's meant for people who have started compiling ROM's and want to give it a little extra boost, and to be able to be applied to any source code with ease (and so you can have multiple toolchains incase you want to switch). People who are knowledgeable enough about android to the point where they add things to their roomservice.xml and have custom repo's probably wont need a guide. But thanks for the tip, it'll help more advanced people who read these posts, and also thanks for uploading the prebuilt linaro toolchains, It really makes it easy for everyone.
Yea give me a bit..I'm at work and mobile but I'll shoot you a pm....it's more so a commit on github that's universal than a how-to guide on xda
 

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
@frap129 : Are you planning on adding/talking about flags ? And Archi's too ?

Archi's are the one's I use, so I don't plan on really talking about them. I may talk a little about Graphite flags, as those are highly optimal flags that are included in SaberMod, but that would be a separate guide because I'd have to talk about adding them to the ROM and the kernel,
 

katinatez

Senior Member
Mar 17, 2011
2,884
18,746
@frap129 love the guide, so happens I have been trying to change the kernel toolchain to SaberMod 4.9 and currently building the the ROM and Kernel with toolchain Sabermod 4.8. I am compiling temasek build for the Oneplus One, and using archidroid optimizations, take a look here https://github.com/temasek/android_build/blob/cm-11.0/core/combo/TARGET_linux-arm.mk
This file I did not edit.


This one i did edit line 172, to toolchaindir=arm/sm-arm-eabi-4.9/bin
https://github.com/temasek/android_build/blob/cm-11.0/envsetup.sh

And here is a link to the toolchain I want to use https://github.com/RobbieL811tc/sm-arm-eabi-4.9

and here is my Tool Chain manifest

Code:
<!-- TOOLCHAIN SaberMod 4.8-->
<project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" name="UBERUTILS/arm-linux-androideabi-4.8" remote="github" revision="master" />
<project path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" name="UBERUTILS/arm-eabi-4.8" remote="github" revision="master" />


<!-- TOOLCHAIN SaberMod 4.9-->
<project name="RobbieL811tc/sm-arm-eabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-eabi-4.9" remote="github" revision="master" />
<project name="RobbieL811tc/sm-arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-linux-androideabi-4.9" remote="github" revision="master" />

And last but not least is my terminal error

Code:
  HOSTLD  scripts/dtc/dtc
/home/katinatez/android/cm-11.0/kernel/oneplus/msm8974/Makefile:515: recipe for target 'scripts' failed
make[2]: *** [scripts] Error 2
Makefile:130: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory '/home/katinatez/android/cm-11.0/kernel/oneplus/msm8974'
build/core/tasks/kernel.mk:175: recipe for target 'TARGET_KERNEL_BINARIES' failed
make: *** [TARGET_KERNEL_BINARIES] Error 2
make: *** Waiting for unfinished jobs....
target StaticLib: libc_nomalloc (/home/katinatez/android/cm-11.0/out/target/product/bacon/obj/STATIC_LIBRARIES/libc_nomalloc_intermediates/libc_nomalloc.a)
external/sqlite/dist/sqlite3.c: In function 'pcache1Fetch':
external/sqlite/dist/sqlite3.c:39405:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
external/sqlite/dist/sqlite3.c:39407:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
external/sqlite/dist/sqlite3.c: At top level:
external/sqlite/dist/sqlite3.c:98075:1: warning: missing initializer [-Wmissing-field-initializers]
external/sqlite/dist/sqlite3.c:98075:1: warning: (near initialization for 'sqlite3Apis.aggregate_count') [-Wmissing-field-initializers]
[[email protected] cm-11.0]$

Hope I gave you plenty of info to help me figure out my error in compiling.
Any help would be appreciated.
Thank You
 

frap129

Inactive Recognized Developer
Jan 6, 2013
1,392
4,126
@frap129 love the guide, so happens I have been trying to change the kernel toolchain to SaberMod 4.9 and currently building the the ROM and Kernel with toolchain Sabermod 4.8. I am compiling temasek build for the Oneplus One, and using archidroid optimizations, take a look here https://github.com/temasek/android_build/blob/cm-11.0/core/combo/TARGET_linux-arm.mk
This file I did not edit.


This one i did edit line 172, to toolchaindir=arm/sm-arm-eabi-4.9/bin
https://github.com/temasek/android_build/blob/cm-11.0/envsetup.sh

And here is a link to the toolchain I want to use https://github.com/RobbieL811tc/sm-arm-eabi-4.9

and here is my Tool Chain manifest

Code:
<!-- TOOLCHAIN SaberMod 4.8-->
<project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8" name="UBERUTILS/arm-linux-androideabi-4.8" remote="github" revision="master" />
<project path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.8" name="UBERUTILS/arm-eabi-4.8" remote="github" revision="master" />


<!-- TOOLCHAIN SaberMod 4.9-->
<project name="RobbieL811tc/sm-arm-eabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-eabi-4.9" remote="github" revision="master" />
<project name="RobbieL811tc/sm-arm-linux-androideabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-linux-androideabi-4.9" remote="github" revision="master" />

And last but not least is my terminal error

Code:
  HOSTLD  scripts/dtc/dtc
/home/katinatez/android/cm-11.0/kernel/oneplus/msm8974/Makefile:515: recipe for target 'scripts' failed
make[2]: *** [scripts] Error 2
Makefile:130: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory '/home/katinatez/android/cm-11.0/kernel/oneplus/msm8974'
build/core/tasks/kernel.mk:175: recipe for target 'TARGET_KERNEL_BINARIES' failed
make: *** [TARGET_KERNEL_BINARIES] Error 2
make: *** Waiting for unfinished jobs....
target StaticLib: libc_nomalloc (/home/katinatez/android/cm-11.0/out/target/product/bacon/obj/STATIC_LIBRARIES/libc_nomalloc_intermediates/libc_nomalloc.a)
external/sqlite/dist/sqlite3.c: In function 'pcache1Fetch':
external/sqlite/dist/sqlite3.c:39405:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
external/sqlite/dist/sqlite3.c:39407:25: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
external/sqlite/dist/sqlite3.c: At top level:
external/sqlite/dist/sqlite3.c:98075:1: warning: missing initializer [-Wmissing-field-initializers]
external/sqlite/dist/sqlite3.c:98075:1: warning: (near initialization for 'sqlite3Apis.aggregate_count') [-Wmissing-field-initializers]
[[email protected] cm-11.0]$

Hope I gave you plenty of info to help me figure out my error in compiling.
Any help would be appreciated.
Thank You
There might have been an error in compiling the toolchain itself, try switching
Code:
<!-- TOOLCHAIN SaberMod 4.9-->
<project name="RobbieL811tc/sm-arm-eabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-eabi-4.9" remote="github" revision="master" />
to
Code:
<!-- TOOLCHAIN SaberMod 4.9-->
<project name="SaberMod/arm-eabi-4.9" path="prebuilts/gcc/linux-x86/arm/sm-arm-eabi-4.9" remote="github" revision="master" />
 

Top Liked Posts

  • There are no posts matching your filters.
  • 117
    Introduction
    Since the only guide I could find for switching toolchains in Android is one on linaro from a few years ago in the Galaxy nexus forum, I decided to make one and post it here. Custom toolchains can provide an overall better android experience to the end user by increasing speed, buttery smoothness, and even fixing bugs! Note: They can also produce bugs on some devices/ROMs.

    Preface:
    There are two mainstream custom toolchains, SaberMod and Linaro, which provide different improvements. In short, SaberMod is built for max speed, while Linaro is built for some subtle speed increases with much more smoothness.
    Click for ARM info
    For ARM devices, there are also 2 different toolchains used in Android; arm-linux-androideabi, which compiles the ROM, and arm-linux-eabi, which compiles the kernel. The recommended version for androideabi is 4.9, but higher should be used once the bugs are worked out/if it works for your device.
    Click for AARCH64 (ARM64) info
    For 64 bit ARM devices, there is one main toolchain,; aarch64-linux, which compiles both the ROM and the kernel. The recommended version is 4.9, because as of now 5.0 won't work with the kernel without heavy revision.

    Switching ARM Toolchains

    Step 1:
    Run the following commands from your source directory to download the 4.9 toolchain for ROM and 4.9 toolchain for kernel

    If using Linaro:
    Code:
     git clone -b linaro-4.9-arm-linux-androideabi https://github.com/ArchiDroid/Toolchain prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-linaro-4.8
    Code:
    git clone -b linaro-4.9-arm-linux-eabi https://github.com/ArchiDroid/Toolchain prebuilts/gcc/linux-x86/arm/arm-linux-eabi-linaro-4.9

    If using SaberMod: Download from http://sabermod.com

    If Using UBER
    Code:
    git clone https://bitbucket.org/UBERTC/arm-linux-androideabi-4.9.git prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-UB-4.8
    Code:
    git clone https://bitbucket.org/UBERTC/arm-eabi-4.9.git prebuilts/gcc/linux-x86/arm/arm-linux-eabi-UB-4.9

    Step 2 :
    Here's where things get a little tricky. Step 2 is different for different android sources. If you use a rom that has GCC Freedom, use the first method. If not, open the file in your source directory in gedit /build/core/combo/TARGET_linux-arm.mk and ctrl+f to search for "TARGET_GCC_VERSION_AND" without the quotes. If it's found, use the first method. If not, use method 2.

    Method 1: To actually use the toolchains, you'll need to change a few things in /build/core/combo/TARGET_linux-arm.mk. An example of what you need to change is shown below:

    Code:
    ifeq ($(strip $(TARGET_GCC_VERSION_AND)),)
         TARGET_GCC_VERSION_AND := SM-4.9
         else
         TARGET_GCC_VERSION_AND := $(TARGET_GCC_VERSION_AND)
         endif
         ifeq ($(strip $(TARGET_GCC_VERSION_ARM)),)
         TARGET_GCC_VERSION_ARM := SM-4.9
         else
         TARGET_GCC_VERSION_ARM := $(TARGET_GCC_VERSION_ARM)
         endif
         # Specify Target Custom GCC Chains to use:
         TARGET_GCC_VERSION_AND := SM-4.8
         TARGET_GCC_VERSION_ARM := SM-4.9

    Notice how the target versions are each listed in two places?(AND is for androideabi and ARM is eabi) Just change the versions at the bottom where it says to specify the custom toolchain to the suffix of the toolchain you chose, for example linaro-4.8 and
    SM-4.9 . Save and your done!

    Method 2: Open /build/envsetup.sh in gedit or another text editor and look for the following section of code:

    Code:
    export ANDROID_EABI_TOOLCHAIN=
        local ARCH=$(get_build_var TARGET_ARCH)
        case $ARCH in
            x86) toolchaindir=x86/i686-linux-android-$targetgccversion/bin
                ;;
            arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
                ;;
            mips) toolchaindir=mips/mipsel-linux-android-$targetgccversion/bin
                ;;
            *)
                echo "Can't find toolchain for unknown architecture: $ARCH"
                toolchaindir=xxxxxxxxx
                ;;
        esac
        if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
            export ANDROID_EABI_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
        fi
     
        unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
        case $ARCH in
            arm)
                toolchaindir=arm/arm-eabi-$targetgccversion/bin
                if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
                     export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
                     ARM_EABI_TOOLCHAIN_PATH=":$gccprebuiltdir/$toolchaindir"
                fi
                ;;

    Look at the line "arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin" and change $targetgccversion to the suffix of the androideabi toolchain you downloaded in step 1, such as linaro-4.8. Now look at the lines

    Code:
    unset ARM_EABI_TOOLCHAIN ARM_EABI_TOOLCHAIN_PATH
        case $ARCH in
            arm)
                toolchaindir=arm/arm-eabi-$targetgccversion/bin

    and change $targetgccversion to the suffix of the eabi toolchain you downloaded in step 1, such as linaro-4.9. Save your file and you did it!


    Switching AARCH64 Toolchains

    Both ROM and Kernel use the same toolchain for AARCH64, so we need to clone it first.
    Step 1:
    Run the following commands from your source directory to download the 4.8 toolchain for ROM and 4.9 toolchain for kernel

    If using Linaro:
    Code:
     git clone https://android.git.linaro.org/git-ro/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9-linaro.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-linaro-4.9

    If using SaberMod 4.9:
    Code:
    git clone https://github.com/SaberMod/aarch64-linux-android-4.9.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-SM-4.9

    Step 2:
    To actually use the toolchain, you'll need to change a few things in /build/core/combo/TARGET_linux-arm64.mk. An example of what you need to change is shown below:
    Code:
    ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
    TARGET_GCC_VERSION := 4.9
    else
    TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
    endif
    See where TARGET_GCC_VERSION is defined as 4.9? change 4.9 to your toolchain version, SM-4.9 or linaro-4.9, to switch toolchains. Save the file and you're golden!

    Congrats, you just upgraded to better toolchains! Make sure you run "make clobber && rm -rf ~/.ccache" before your next build.
    32
    More Links

    I decided to add Links to all (known/published) custom toolchains available with a short description of each! Feel free to tell me if I miss any.

    SaberMod Git
    SaberMod aims to optimize Android as much as possible, using only the latest and fastest sources for toolchains. SaberMod also uses its own fixes and patches for graphite, ISL, and other optimizations.
    UBERTC Git
    UBER is focused on well rounded performace, starting with a GNU base, and building up smoothness, and battery by using Linaro and AOSP patches
    Linaro (Switch to Linaro branch)
    Linaro is the toolchain of Linaro Group, focussing on adding better support for ARM based targets
    ArchiToolchain (Also under branches)
    ArchiToolchain's goal is minimalism, by simply optimizing for a variety of targets.
    Boosted TC
    Little is known about boosted TC other than it was based on SM, and is likely incompatible with Lollipop (for ROMs)
    Hyper Toolchains
    Hyper Toolchains combines popular toolchains (Currently SM, Uber and Linaro) in various ways to create unique results, without a main goal.
    9
    Haha quite the accusations. I said the source for the toolchains was based on gnu and my aosp ports to gnu as well as other changes by me. You obviously never looked at the source code for the toolchains. Get back to me when you grow a brain.
    hahaa I'm not going to reduce to name calling of calling you "Slow" or telling you to "grow a brain"

    Facts are facts dude. Your repos don't have commit history. You would like everyone to think you're this awesome developer who codes up toolchains out of thin air BUT you're not. Your one trick is old and is not even that good.....

    I'm not going to continue this pony show. You have more then proved to everyone that you have no ground to stand on. You repeatedly dodge questions and things like a politician but just like one, the people can see the lies coming out your mouth
    6
    did you tried the commit if it fixes the issue?

    But using a Google 4.8 compiled ROM works with a SaberMod 4.9.3 compiled kernel. I compile my custom kernel with it.
    This patch is already inside lollipop branch :(.
    Yes exactly, as I wrote and @fusionjack didn't read it carefuly, I can boot with 4.9 for kernel just fine. It's ROM toolchain issue!

    yeah... i said that several weeks ago.. lol :D
    that was assumption because it was my first time i compiled rom for sony device.
    i tried last night to compile the kernel with google 4.8 but device still doesn't boot. it looks the rom toolchain that is causing it...BUT if i replace the boot.img of the rom (which compiled with SM 4.8.5) with the one from official rom, the device boots fine.
    so, at least for me, i can compiled the rom with SM 4.8.5 like usual but needs to replace the boot.img to make it boot.
    this looks to me that inside the boot.img causes the device doesn't boot. i'm not familiar with boot.img, afaik what's inside is the kernel, ramdisk and some of rom's lib? if yes, then i suspect the rom's lib is the culprit. if we know which libs and if we could compile them with other toolchain then probably it'll work.

    again...this is just my assumption and i just share what i have right now. i appreciate all of your comments. @sparksco, don't get me wrong...i really really want to compile rom and kernel with SM for sony device. i post here because i saw some familiar users that build roms with SM. thanks.
    6
    If you want to see who's kanging compare gnu gcc to AOSP gcc. Then throw UBERTC on top of sabermod with merges from gnu which is already in sabermod gcc. Get real.

    https://android.googlesource.com/toolchain/gcc/+log/master/gcc-4.9

    https://android.googlesource.com/toolchain/gcc/+/1bc5aee63eb72b341f506ad058502cd0361f0d10

    Where's the gnu commit history?
    https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/heads/gcc-4_9-branch
    That interesting @sparksco that you're talking about commit history

    Where's the commit history for your repo......
    https://github.com/SaberMod/aarch64-linux-android-4.9

    Here's the one with FULL commit history pulled directly from Google
    https://github.com/Mazda--/aarch64-linux-android-4.9