The version-string from binutils-linaro looks to be blamed. It once was:
GNU ld (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04) 2.23.1
and the linker plugin works with this version of Linaro prebuilt toolchain. Now it is:
GNU ld (crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04) 2.24.0.20140311 Linaro 2014.03 GNU ld (crosstool-NG linaro-1.13.1-4.9-2014.08 - Linaro GCC 4.9-2014.08) 2.24.0.20140801 Linaro 2014.08
and the linker plugin is not supported:
$ arm-linux-gnueabihf-gcc -flto -fuse-linker-plugin -o hello hello.c arm-linux-gnueabihf-gcc: error: -fuse-linker-plugin is not supported in this configuration
Look into gcc/configure script. It uses the version of ld to determine whether ld supports linker plugin. It extracts the version by doing something like:
$ arm-linux-gnueabihf-ld --version | sed 1q | sed -n -e 's,^.*[ ]([0-9][0-9]*.[0-9][0-9]*.*)$,\1,p'
and it will extract the last 2014.03 or 2014.08. By using proper substitution expression like 's,^GNU ld (.*) ([0-9][.0-9]*).*$,\1,p', the script may enable linker plugin.
However, patching the script looks like a bad idea, because it doesn’t help handling the version of gold:
GNU gold (GNU Binutils for Ubuntu 2.24) 1.11 GNU gold (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 - Linaro GCC 2013.04 2.23.1) 1.11 GNU gold (crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04 2.24.0.20140311 Linaro 2014.03) 1.11 GNU gold (crosstool-NG linaro-1.13.1-4.9-2014.08 - Linaro GCC 4.9-2014.08 2.24.0.20140801 Linaro 2014.08) 1.11
I couldn’t find a reasonable general expression to extract the version.
From: linaro-toolchain-bounces@lists.linaro.org [mailto:linaro-toolchain-bounces@lists.linaro.org] On Behalf Of 박주형 Sent: Monday, October 27, 2014 10:15 PM To: linaro-android@lists.linaro.org; linaro-toolchain@lists.linaro.org Subject: Enabling back linker plugin for Linaro Android toolchain
I'm using Linaro Android toolchain's arm-eabi- for compiling my Android Linux kernel with LTO.
The main benefits of my kernel is that it uses LTO(Link-Time-Optimizations). (Patches found here: https://github.com/andikleen/linux-misc)
But now, it's broken with Linaro Android toolchains from 2014.09~
Building Linux kernel with LTO requires Linker plugin with the toolchain.
But for some reason, linker plugin is disabled with 2014.09 and 2014.10 (Which I used from here : https://android-build.linaro.org/builds/~linaro-android/toolchain-4.9-2014.0... https://android-build.linaro.org/builds/~linaro-android/toolchain-4.9-2014.1... )
LTO build works flawlessly with 2014.08.
With 2014.09 and 2014.10, I get the following error : cc1: error: -fno-fat-lto-objects are supported only with linker plugin
If I explicitly remove " -fno-fat-lto-objects " from the Makefile, the linker fails to link all of the object files.
I would like to ask Linaro to enable back the Linker plugin support :)
Thanks in advance..