[HOW-TO] Sync Xylons source, build with GCC 4.9, Linaro, enable -O3, & use CCACHE

Do you want more in-depth tutorials?

  • No thanks, there is already an abundance of guides

    Votes: 0 0.0%

  • Total voters
    1
  • Poll closed .
Status
Not open for further replies.
Search This thread

MBQ_

Senior Member
Sep 3, 2011
14,799
22,998
29
Phoenix, Arizona
MBQonXDA.com
cd to your Desktop
command time: (copy/paste em)
Code:
mkdir ~/bin
export PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo

then:
Code:
sudo gedit ~/.bashrc
put export PATH=~/bin:$PATH at the bottom, of it
to enable CCACHE, put this code at the bottom of your bash.rc
Code:
EXPORT USE_CCACHE=1
export CCACHE_DIR=/path/to/your/ccache/folder (mine is /home/mbq/Desktop/ccache
export CCACHE_LOGFILE=/path/to/your/ccache/ccache.log
save it

then:
Code:
mkdir ~/XYAOSP
cd ~/XYAOSP
repo init -u [url]https://github.com/XYAOSP/platform_manifest[/url] -b jb4.2
repo sync -j16 (or -j8, or -j32.. whichever you want)

then:
when youre synced up..
if you want to watch CCACHE to make sure it's working, cd to:
Code:
/path/to/your/XYAOSP/prebuilts/misc/linux-x86/cache
then:
Code:
ccache -s

to change the size of your CCACHE, cd to:
Code:
/path/to/your/XYAOSP/prebuilts/misc/linux-x86
then:
Code:
ccache -M 20
(20=20GB, you can set it all the way to 100)

make sure ccache is getting hits. (The first build will take way longer than usual, so be patient). :)

to call linaro out correctly, open your xylon folder, go to build, and edit envsetup.sh (if you see a lock on the file(s), enter this:
Code:
sudo chmod -R 777 /path/to/your/XYAOSP/build

then, find:
Code:
    # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
    export ANDROID_EABI_TOOLCHAIN=
    local ARCH=$(get_build_var TARGET_ARCH)
    case $ARCH in
        x86) toolchaindir=x86/i686-linux-android-4.6/bin
            ;;
        arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
            ;;
        mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
            ;;
        *)
            echo "Can't find toolchain for unknown architecture: $ARCH"
            toolchaindir=xxxxxxxxx
            ;;
and change:
Code:
        arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
to:
Code:
        arm) toolchaindir=linaro/bin

and:
Code:
    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
            ;;
        mips) toolchaindir=mips/mips-eabi-4.4.3/bin
            ;;
        *)
            # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
            ;;

change:
Code:
    case $ARCH in
        arm)
            toolchaindir=arm/arm-eabi-$targetgccversion/bin
to:
Code:
    case $ARCH in
        arm)
            toolchaindir=linaro/bin

(Make sure linaro is in
Code:
/path/to/your/XYAOSP/prebuilts/gcc/linux-x86/linaro
)

to enable -O3 optimizations, go to:
Code:
/path/to/your/XYAOSP/build/core/combo
open: select.mk

edit:
Code:
ifneq ($(TARGET_USE_02),true)
$(combo_target)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
$(combo_target)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
else
$(combo_target)GLOBAL_CFLAGS := -O3 -g -Wstrict-aliasing=2
ifneq ($(combo_target),HOST_)
(combo_target)RELEASE_CFLAGS += -Werror=strict-aliasing
endif
endif
$(combo_target)GLOBAL_LDFLAGS := -Wl,-O3
$(combo_target)GLOBAL_ARFLAGS := crsP
change anything -O2 to -O3
save it

then: go to the build/core/combo
then: TARGET_linux-arm.mk

change:
Code:
ifeq ($(TARGET_USE_O3),true)
TARGET_arm_CFLAGS :=    -Os \
                        -fomit-frame-pointer \
                        -fstrict-aliasing    \
                        -fno-tree-vectorize
else
TARGET_arm_CFLAGS :=    -O3 \
                        -fomit-frame-pointer \
                        -fstrict-aliasing    \
                        -funswitch-loops
endif
to:
Code:
ifeq ($(TARGET_USE_O2),true)
TARGET_arm_CFLAGS :=    -Os \
                        -fomit-frame-pointer \
                        -fstrict-aliasing    \
                        -fno-tree-vectorize
else
TARGET_arm_CFLAGS :=    -O3 \
                        -fomit-frame-pointer \
                        -fstrict-aliasing    \
                        -funswitch-loops
endif
and:
Code:
ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
    ifeq ($(TARGET_USE_O2),true)
    TARGET_thumb_CFLAGS :=  -mthumb \
                            -O2 \
                            -fomit-frame-pointer \
                            -fno-strict-aliasing \
                            -fno-tree-vectorize
    else
    TARGET_thumb_CFLAGS :=  -mthumb \
                            -O3 \
                            -fomit-frame-pointer \
                            -fno-strict-aliasing \
                            -fno-tree-vectorize
    endif
else
TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
endif
to:
Code:
ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
    ifeq ($(TARGET_USE_O3),true)
    TARGET_thumb_CFLAGS :=  -mthumb \
                            -O3 \
                            -fomit-frame-pointer \
                            -fno-strict-aliasing \
                            -fno-tree-vectorize
    else
    TARGET_thumb_CFLAGS :=  -mthumb \
                            -O3 \
                            -fomit-frame-pointer \
                            -fno-strict-aliasing \
                            -fno-tree-vectorize
    endif
else
TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
endif
^^ Make any of these changes prior to building

to build with GCC 4.9, go to build/core/config.mk and find TARGET_GCC_VERSION := 4.7, change it to 4.9

to get linaro, download this: http://releases.linaro.org/13.04/co...13.04-2-2013-04-13_12-08-43-linux-x86.tar.bz2

then change the folders name to 'linaro'

move it to prebuilts/gcc/linux-x86

then, to build..
Code:
. build/envsetup.sh
croot
brunch device -j(2, 4, 8, 16, or 32, your choice)
*Note: Because CCACHE is enabled, it will take a while for your first build to complete. ~2-5 hours

Hope this helps!
 
Last edited:

sert00

Senior Member
May 28, 2011
1,091
496
cesena,IT
if you have a 4x cpu you can go for -j8\-k16 and so on.i always used -j16 in the past,now it's big time i don't anything.
Great 3ad kyler,you explain all very well,especially the toolchain part rather that other guides out there.I stopped build for myself some months ago,but definetly a good howto for who have time and effort to try.
^__^
 

beekay201

Senior Member
Nov 8, 2010
5,224
1,221
If you change TARGET_GCC_VERSION to 4.9... You'll need to wget Linaro 4.9.. No?

Sent from my Nexus
 

-Jesco-

Senior Member
Jun 28, 2012
2,717
2,735
quick question :p why dont we use full 4.9 like what Daxx done in his maguro UKG build ?
 

pmbabu

Senior Member
Jan 4, 2011
319
125
Nice guide thanks!

Can you pls. tell me how much space will the "sources" occupy during/after the first sync-up? Although am on unlimited broadband, would like to know this. I read in one of the threads (about CM 10.1 sources sync-up) that it is about 40GB. Is this right?
 

KemikalElite

Senior Member
Jan 28, 2011
664
228
Google Pixel 3
OnePlus 7 Pro
I just tried to self-compile a xyUltimatum build and I used the SaberMod GCC 4.9 toolchain since there's not a 4.9 of Linaro out yet and got an error related to the compiler itself.

Code:
external/aac/libAACenc/src/aacenc_tns.cpp: In function 'INT FDKaacEnc_TnsEncode(TNS_INFO*, TNS_DATA*, INT, const TNS_CONFIG*, INT, FIXP_DBL*, INT, INT)':
external/aac/libAACenc/src/aacenc_tns.cpp:1004:5: error: definition in block 48 follows the use
 INT FDKaacEnc_TnsEncode(
     ^
for SSA_NAME: value_155 in statement:
# DEBUG D#405 => MAX_EXPR <value_155, _111>
external/aac/libAACenc/src/aacenc_tns.cpp:1004:5: internal compiler error: verify_ssa failed
0xc2358c verify_ssa(bool)
	../.././../gcc/gcc-SaberMod/gcc/tree-ssa.c:1046
0x9f66e2 execute_function_todo
	../.././../gcc/gcc-SaberMod/gcc/passes.c:1970
0x9f704d execute_todo
	../.././../gcc/gcc-SaberMod/gcc/passes.c:2002
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [/home/kemikalelite/android/out/target/product/maguro/obj/STATIC_LIBRARIES/libFraunhoferAAC_intermediates/libAACenc/src/aacenc_tns.o] Error 1

Since the ROM and toolchain are from two different sources I'm not sure if it was caused by something with the ROM's source or if its just caused from a bug in the toolchain and whether or not it should be reported to the Saber dev.
 

MBQ_

Senior Member
Sep 3, 2011
14,799
22,998
29
Phoenix, Arizona
MBQonXDA.com
I just tried to self-compile a xyUltimatum build and I used the SaberMod GCC 4.9 toolchain since there's not a 4.9 of Linaro out yet and got an error related to the compiler itself.

Code:
external/aac/libAACenc/src/aacenc_tns.cpp: In function 'INT FDKaacEnc_TnsEncode(TNS_INFO*, TNS_DATA*, INT, const TNS_CONFIG*, INT, FIXP_DBL*, INT, INT)':
external/aac/libAACenc/src/aacenc_tns.cpp:1004:5: error: definition in block 48 follows the use
 INT FDKaacEnc_TnsEncode(
     ^
for SSA_NAME: value_155 in statement:
# DEBUG D#405 => MAX_EXPR <value_155, _111>
external/aac/libAACenc/src/aacenc_tns.cpp:1004:5: internal compiler error: verify_ssa failed
0xc2358c verify_ssa(bool)
../.././../gcc/gcc-SaberMod/gcc/tree-ssa.c:1046
0x9f66e2 execute_function_todo
../.././../gcc/gcc-SaberMod/gcc/passes.c:1970
0x9f704d execute_todo
../.././../gcc/gcc-SaberMod/gcc/passes.c:2002
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [/home/kemikalelite/android/out/target/product/maguro/obj/STATIC_LIBRARIES/libFraunhoferAAC_intermediates/libAACenc/src/aacenc_tns.o] Error 1

Since the ROM and toolchain are from two different sources I'm not sure if it was caused by something with the ROM's source or if its just caused from a bug in the toolchain and whether or not it should be reported to the Saber dev.

I'd submit a bug report

Sent from my Galaxy Nexus using xda premium
 
  • Like
Reactions: KemikalElite
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 19
    cd to your Desktop
    command time: (copy/paste em)
    Code:
    mkdir ~/bin
    export PATH=~/bin:$PATH
    curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
    chmod a+x ~/bin/repo

    then:
    Code:
    sudo gedit ~/.bashrc
    put export PATH=~/bin:$PATH at the bottom, of it
    to enable CCACHE, put this code at the bottom of your bash.rc
    Code:
    EXPORT USE_CCACHE=1
    export CCACHE_DIR=/path/to/your/ccache/folder (mine is /home/mbq/Desktop/ccache
    export CCACHE_LOGFILE=/path/to/your/ccache/ccache.log
    save it

    then:
    Code:
    mkdir ~/XYAOSP
    cd ~/XYAOSP
    repo init -u [url]https://github.com/XYAOSP/platform_manifest[/url] -b jb4.2
    repo sync -j16 (or -j8, or -j32.. whichever you want)

    then:
    when youre synced up..
    if you want to watch CCACHE to make sure it's working, cd to:
    Code:
    /path/to/your/XYAOSP/prebuilts/misc/linux-x86/cache
    then:
    Code:
    ccache -s

    to change the size of your CCACHE, cd to:
    Code:
    /path/to/your/XYAOSP/prebuilts/misc/linux-x86
    then:
    Code:
    ccache -M 20
    (20=20GB, you can set it all the way to 100)

    make sure ccache is getting hits. (The first build will take way longer than usual, so be patient). :)

    to call linaro out correctly, open your xylon folder, go to build, and edit envsetup.sh (if you see a lock on the file(s), enter this:
    Code:
    sudo chmod -R 777 /path/to/your/XYAOSP/build

    then, find:
    Code:
        # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
        export ANDROID_EABI_TOOLCHAIN=
        local ARCH=$(get_build_var TARGET_ARCH)
        case $ARCH in
            x86) toolchaindir=x86/i686-linux-android-4.6/bin
                ;;
            arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
                ;;
            mips) toolchaindir=mips/mipsel-linux-android-4.6/bin
                ;;
            *)
                echo "Can't find toolchain for unknown architecture: $ARCH"
                toolchaindir=xxxxxxxxx
                ;;
    and change:
    Code:
            arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
    to:
    Code:
            arm) toolchaindir=linaro/bin

    and:
    Code:
        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
                ;;
            mips) toolchaindir=mips/mips-eabi-4.4.3/bin
                ;;
            *)
                # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
                ;;

    change:
    Code:
        case $ARCH in
            arm)
                toolchaindir=arm/arm-eabi-$targetgccversion/bin
    to:
    Code:
        case $ARCH in
            arm)
                toolchaindir=linaro/bin

    (Make sure linaro is in
    Code:
    /path/to/your/XYAOSP/prebuilts/gcc/linux-x86/linaro
    )

    to enable -O3 optimizations, go to:
    Code:
    /path/to/your/XYAOSP/build/core/combo
    open: select.mk

    edit:
    Code:
    ifneq ($(TARGET_USE_02),true)
    $(combo_target)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
    $(combo_target)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
    else
    $(combo_target)GLOBAL_CFLAGS := -O3 -g -Wstrict-aliasing=2
    ifneq ($(combo_target),HOST_)
    (combo_target)RELEASE_CFLAGS += -Werror=strict-aliasing
    endif
    endif
    $(combo_target)GLOBAL_LDFLAGS := -Wl,-O3
    $(combo_target)GLOBAL_ARFLAGS := crsP
    change anything -O2 to -O3
    save it

    then: go to the build/core/combo
    then: TARGET_linux-arm.mk

    change:
    Code:
    ifeq ($(TARGET_USE_O3),true)
    TARGET_arm_CFLAGS :=    -Os \
                            -fomit-frame-pointer \
                            -fstrict-aliasing    \
                            -fno-tree-vectorize
    else
    TARGET_arm_CFLAGS :=    -O3 \
                            -fomit-frame-pointer \
                            -fstrict-aliasing    \
                            -funswitch-loops
    endif
    to:
    Code:
    ifeq ($(TARGET_USE_O2),true)
    TARGET_arm_CFLAGS :=    -Os \
                            -fomit-frame-pointer \
                            -fstrict-aliasing    \
                            -fno-tree-vectorize
    else
    TARGET_arm_CFLAGS :=    -O3 \
                            -fomit-frame-pointer \
                            -fstrict-aliasing    \
                            -funswitch-loops
    endif
    and:
    Code:
    ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
        ifeq ($(TARGET_USE_O2),true)
        TARGET_thumb_CFLAGS :=  -mthumb \
                                -O2 \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -fno-tree-vectorize
        else
        TARGET_thumb_CFLAGS :=  -mthumb \
                                -O3 \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -fno-tree-vectorize
        endif
    else
    TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
    endif
    to:
    Code:
    ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
        ifeq ($(TARGET_USE_O3),true)
        TARGET_thumb_CFLAGS :=  -mthumb \
                                -O3 \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -fno-tree-vectorize
        else
        TARGET_thumb_CFLAGS :=  -mthumb \
                                -O3 \
                                -fomit-frame-pointer \
                                -fno-strict-aliasing \
                                -fno-tree-vectorize
        endif
    else
    TARGET_thumb_CFLAGS := $(TARGET_arm_CFLAGS)
    endif
    ^^ Make any of these changes prior to building

    to build with GCC 4.9, go to build/core/config.mk and find TARGET_GCC_VERSION := 4.7, change it to 4.9

    to get linaro, download this: http://releases.linaro.org/13.04/co...13.04-2-2013-04-13_12-08-43-linux-x86.tar.bz2

    then change the folders name to 'linaro'

    move it to prebuilts/gcc/linux-x86

    then, to build..
    Code:
    . build/envsetup.sh
    croot
    brunch device -j(2, 4, 8, 16, or 32, your choice)
    *Note: Because CCACHE is enabled, it will take a while for your first build to complete. ~2-5 hours

    Hope this helps!
    3
    Reserved! Just in case
    1
    repo sync -j16 (or -j8, or -j32.. whichever you want)

    What's the difference between them. Trying to build for toro :D wondering which one I should use, thanks :)

    How many threads of each core is used

    Sent from my Galaxy Nexus using xda premium
    1
    should I dl the CCATCH separately? and what about ccatch.log? how to address that?

    Yeah, and just call it in your bashrc

    Sent from my Galaxy Nexus using xda premium
    1
    Nice guide thanks!

    Can you pls. tell me how much space will the "sources" occupy during/after the first sync-up? Although am on unlimited broadband, would like to know this. I read in one of the threads (about CM 10.1 sources sync-up) that it is about 40GB. Is this right?

    20-40GB

    Sent from my Galaxy Nexus using xda premium