[Samsung Galaxy S (4G Model)] DJLamontagneIII:
Building Your ROM With The Linaro Toolchain

This guide will help you build your ROM with the Linaro toolchain, and any other 4.7, 4.8+ toolchains. Using one of these "updated" toolchains requires you to be able to search, read, and be able find information to be able to fix errors you may encounter varying from device to device, and depending on your Global optimization level. This guide is more for setting up your build and leaves you to play with the flags and optimizations. It takes a little work to get your environment set up but that's all the fun :p..​

1. Getting the toolchain

First you will need to get the toolchain. You can either pull it from a repo or download the zip straight from Linaro or Google. Keep in mind that the ROM is compiled with the arm-linux-androideabi and the kernel with arm-eabi. You can find all the release versions of Linaro's toolchains here along with nightly builds LINK, And Googles toolchains for Linux and Darwin here LINK. Focusing on building with Linux the path for them is "prebuilts/gcc/linux-x86/arm" with Linaro you can just extract the one folder into the directory but Google has them split up into arm-linux-androideabi-4.7, and arm-eabi-4.7.

2. Setting up your build repo

You will need to edit the build repo to point to the updated toolchains. From step one we either put the Linaro folder or Google's toolchains into the "prebuilts/gcc/linux-x86/arm" directory. Remember the names of the folder or toolchains as we will need them in these edits, Using the linaro folder name for both arm-linux-androideabi, and arm-eabi lines or just replacing them with the updated Google versions. You can follow this commit as a guide to setting up your Build repo Toolchain Edits

3. Dealing with build errors

From Linaro:

Getting rid of -fno-strict-aliasing enables rather efficient additional optimizations – but requires that the code being compiled follows some rules traditionally not enforced by compilers.

Given the traditional lack of enforcement, there’s lots of code out there (including, unfortunately, in the AOSP codebase) that violates those rules.

Fortunately, gcc can help us detect those violations: With -fstrict-aliasing -Werror=strict-aliasing, most aliasing violations can be turned into built time errors instead of random crashes at runtime. This allowed us to detect many aliasing violations in the code, and fix them (where doable with reasonable effort), or work around them by enabling -fno-strict-aliasing just for a particular subdirectory containing code not ready for dropping it.

There are many Projects in your source you will have to add patches to fix the violations or workarounds. I have 40+ patches to fix the numerous errors in my builds:eek:. Many can be found from Linaro's Gitweb LINK, and you can get some of them from CM Review LINK. This is the hard part and Google search can be your best friend :silly:.

4. Optimizations

Once you get your setup going successfully you can play around with some optimizations. You can find some information about flag optimizations from Linaro LINK and GNU LINK. an example can be like this for -O3 LINK, or more stable -O2 with some added flags that would be enabled by -O3 LINK. there's also options like Linaros string handling routines LINK.

MISC Links

DJLaMontagneIII Github

CM Review Linaro commits

Linaro Gitweb

Linaro Downloads

Google Source

SaberMod Github

trailblazerz Github

Please feel free to reference my Github for patches you may need and feel free to post any build errors you may be stuck on and need help because others my be in the same boat, but please use hide tags or pastebin for the terminal outputs:good:.