Could you share your changes?
Would be nice to try what you have done.
Sure.
Add Linaro's GCC 6.1. I did this by modifying .repo/local_manifests/roomservice.xml with the following:
<remote fetch="https://android-git.linaro.org/git/" name="linaro" />
<project name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-6.1-linaro.git" path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-6.1" remote="linaro" revision="master" />
Then, make the build system use it by modifying build/core/combo/TARGET_linux-arm.mk
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
+$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 6.1
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
+$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 6.1
(linaro now has GCC 6.2 too; it was not available back then so I haven't tried it)
Second change: the kernel we have doesn't build with GCC 6 because it only has headers for 4 and 5. However, headers for 5 work for 6, so do this:
- find a file /kernel/samsung/msm8930-common/include/linux/compiler-gcc5.h
- and copy it into a file named /kernel/samsung/msm8930-common/include/linux/compiler-gcc6.h
From now on, I mostly did this: "try to build, and if something fails because warning is treated as error, change the corresponding makefile to remove -Werror from it". Occasionally I would fix the code to avoid the warning instead, especially if it's obvious that the code is faulty.
This led to a large set of changes and unfortunately at this point I don't even know which of them are necessary anymore. It's always a mess to keep track of those
So, here's a full repo diff I currently have. I haven't built for ~three weeks so it might be out of date. It will almost certainly contain changes that aren't strictly needed.
https://www.dropbox.com/s/d14h255masgkg2e/diff.diff?dl=0
Moreover, this diff contains some optimisation flags that are independent from GCC 6 - mostly in build/core/combo/TARGET_linux-arm.mk. You should see it's got -O3 on place of -Os, and -Wl,O1 passed to the linker. You can use them without any GCC changes.
One last thing: after using -O3, the recovery image is too large to fit on our devices. I "faked" a larger recovery space in our device/samsung/serrano-common/rootdir/fstab.qcom to avoid build errors, but the recovery image is unusable.
Hopefully this helps a bit. I always end up with a mess of changes, not remembering why I did this-and-and-that, sorry about that :/
[edit] I just remembered something: if you use CCACHE, you need to clear it (or point it to a new location) because CCACHE is not aware you're using a new GCC and would provide cache hits, returning binaries from previous GCC. Such a trap.