diff options
author | Peter Kümmel <syntheticpp@gmx.net> | 2015-03-06 13:34:06 +0100 |
---|---|---|
committer | Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | 2015-03-07 15:01:53 +0100 |
commit | 814f63ec32585f281855587fe0a287cee32e4232 (patch) | |
tree | c0ed8855f0431ae8e4b32fbba73bcfb1669c5d79 /toolchain | |
parent | 518cdabb896235c8c5c43e9d65a7222961c18579 (diff) | |
download | buildroot-814f63ec32585f281855587fe0a287cee32e4232.tar.gz buildroot-814f63ec32585f281855587fe0a287cee32e4232.zip |
toolchain: add link-time-optimization support
Add a new option BR2_GCC_ENABLE_LTO that builds gcc and binutils with
LTO support.
Individual packages still have to enable LTO explicitly by passing '-flto' to
GCC, which passes it on to the linker. This option does not add that flag
globally. Some packages detect if the compiler supports LTO and enable the flag
if it does.
To support LTO, ar and ranlib must be called with an argument which triggers the
usage of the LTO plugin. Since GCC doesn't call these tools itself, it instead
provides wrappers for ar and ranlib that pass the LTO arguments. This way
existing Makefiles don't need to be changed for LTO support. However, these
wrappers are called <tuple>-gcc-ar which matches the pattern to link to the
buildroot wrapper in the external toolchain logic. So the external toolchain
logic is updated to provide the correct symlink.
[Thomas:
- Add a separate BR2_BINUTILS_ENABLE_LTO option to enable LTO
support in binutils. This is a blind option, selected by
BR2_GCC_ENABLE_LTO. It just avoids having binutils.mk poke
directly into gcc Config.in options.
- Remove the check on the AVR32 special gcc version, which we don't
support anymore.
- Adapt the help text of the LTO Config.in option to no longer
mention "Since version 4.5", since we only support gcc >= 4.5 in
Buildroot anyway.
- Fix typo in toolchain-external.mk comment.]
Signed-off-by: Peter Kümmel <syntheticpp@gmx.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'toolchain')
-rw-r--r-- | toolchain/toolchain-external/toolchain-external.mk | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/toolchain/toolchain-external/toolchain-external.mk b/toolchain/toolchain-external/toolchain-external.mk index 78138d370a..612c49d2e1 100644 --- a/toolchain/toolchain-external/toolchain-external.mk +++ b/toolchain/toolchain-external/toolchain-external.mk @@ -647,12 +647,20 @@ endif # Build toolchain wrapper for preprocessor, C and C++ compiler and setup # symlinks for everything else. Skip gdb symlink when we are building our # own gdb to prevent two gdb's in output/host/usr/bin. +# When the link-time-optimazation flag '-flto' is used, then the compiler +# and binutils have to support lto. ar/ranlib need to be called with the +# lto plugin. The wrappers *-gcc-ar and *-gcc-ranlib provided by GCC could +# be used as drop-ins for ar/runlib when Makefiles are used which do not +# pass the lto arguments. define TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER $(Q)$(call MESSAGE,"Building ext-toolchain wrapper") mkdir -p $(HOST_DIR)/usr/bin; cd $(HOST_DIR)/usr/bin; \ for i in $(TOOLCHAIN_EXTERNAL_CROSS)*; do \ base=$${i##*/}; \ case "$$base" in \ + *-ar|*-ranlib|*-nm) \ + ln -sf $$(echo $$i | sed 's%^$(HOST_DIR)%../..%') .; \ + ;; \ *cc|*cc-*|*++|*++-*|*cpp) \ ln -sf ext-toolchain-wrapper $$base; \ ;; \ |