Переглянути джерело

package/Makefile.in: use gcc wrappers for binutils tools

This will use gcc-ar, gcc-nm and gcc-ranlib instead of the normal
binutils tools. The difference is that with the wrappers, gcc plugins
will be automatically picked up.

gcc 4.7 introduced these wrappers, to detect the prefix and keep gcc
specifics out of Makefile.in, a new variable BR2_TOOLCHAIN_BUTILS_PREFIX
will be used to carry the prefix on supported versions.

Note that binutils added some automatic loading with the 'bfd-plugins'
directory (somewhere around 2.28), but the first implementation had
issues, and generally depends on correctly setup symlinks (often broken,
may point to some other gcc's library). The wrappers always work
painless.

The original motivation (now ~2 years in use) was to add "-flto
-ffat-lto-objects" to both BR2_TARGET_OPTIMIZATION and
BR2_TARGET_LDFLAGS, and have target binaries lto optimized.

Not all packages will compile with this option, further work could
white/blacklist packages (adding -fno-lto to the options).

Signed-off-by: Norbert Lange <nolange79@gmail.com>
[yann.morin.1998@free.fr: don't introduce a Config.in blind option]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Norbert Lange 4 роки тому
батько
коміт
c08fa13d36
1 змінених файлів з 10 додано та 3 видалено
  1. 10 3
      package/Makefile.in

+ 10 - 3
package/Makefile.in

@@ -210,16 +210,23 @@ else
 TARGET_CROSS = $(HOST_DIR)/bin/$(TOOLCHAIN_EXTERNAL_PREFIX)-
 endif
 
+# gcc-4.7 and later ships with wrappers that will automatically pass
+# arguments to the binutils tools. Those are paths to necessary linker
+# plugins.
+ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
+TARGET_GCC_WRAPPERS_PREFIX = gcc-
+endif
+
 # Define TARGET_xx variables for all common binutils/gcc
-TARGET_AR       = $(TARGET_CROSS)ar
+TARGET_AR       = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)ar
 TARGET_AS       = $(TARGET_CROSS)as
 TARGET_CC       = $(TARGET_CROSS)gcc
 TARGET_CPP      = $(TARGET_CROSS)cpp
 TARGET_CXX      = $(TARGET_CROSS)g++
 TARGET_FC       = $(TARGET_CROSS)gfortran
 TARGET_LD       = $(TARGET_CROSS)ld
-TARGET_NM       = $(TARGET_CROSS)nm
-TARGET_RANLIB   = $(TARGET_CROSS)ranlib
+TARGET_NM       = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)nm
+TARGET_RANLIB   = $(TARGET_CROSS)$(TARGET_GCC_WRAPPERS_PREFIX)ranlib
 TARGET_READELF  = $(TARGET_CROSS)readelf
 TARGET_OBJCOPY  = $(TARGET_CROSS)objcopy
 TARGET_OBJDUMP  = $(TARGET_CROSS)objdump