path: root/package
diff options
authorGravatar Arnout Vandecappelle <arnout@mind.be>2015-10-04 13:28:42 +0100
committerGravatar Peter Korsgaard <peter@korsgaard.com>2015-10-04 18:22:20 +0200
commit919c06c28295f19ca49459b98d8954148b381360 (patch)
tree015fb197ccd5b976347ac758a5376afca9c3bb57 /package
parentf6ae24379b551cbfc6447b25a241ffa76d366ddc (diff)
gcc: use toolchain wrapper
We have a toolchain wrapper for external toolchain, but it is also beneficial for internal toolchains, for the following reasons: 1. It can make sure that BR2_TARGET_OPTIMIZATION is passed to the compiler even if a package's build system doesn't honor CFLAGS. 2. It allows us to do the unsafe path check (i.e. -I/usr/include) without patching gcc. 3. It makes it simpler to implement building each package with a separate staging directory (per-package staging). 4. It makes it simpler to implement a compiler hash check for ccache. The wrapper is reused from the external toolchain. A third CROSS_PATH_ option is added to the wrapper: in this case, the real executable is in the same directory, with the extension .real. The creation of the simple symlinks is merged with the creation of the wrapper symlinks, otherwise part of the -gcc-ar handling logic would have to be repeated. The complex case-condition could be refactored with the one for the external toolchain, but then it becomes even more complex because they each have special corner cases. For example, the internal toolchain has to handle *.real to avoid creating an extra indirection after host-gcc-{final,initial}-rebuild. Instead of creating the .real files, it would also have been possible to install the internal toolchain in $(HOST_DIR)/opt, similar to what we do for the external toolchain. However, then we would also have to copy things to the sysroot and do more of the magic that the external toolchain is doing. So keeping it in $(HOST_DIR)/usr/bin is much simpler. Note that gcc-initial has to be wrapped as well, because it is used for building libc and we want to apply the same magic when building libc. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Cc: Fabio Porcedda <fabio.porcedda@gmail.com> Cc: Jérôme Oufella <jerome.oufella@savoirfairelinux.com> Reviewed-by: Romain Naour <romain.naour@openwide.fr> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Diffstat (limited to 'package')
3 files changed, 43 insertions, 8 deletions
diff --git a/package/gcc/gcc-final/gcc-final.mk b/package/gcc/gcc-final/gcc-final.mk
index 3426ba483b..2c16fdf6b3 100644
--- a/package/gcc/gcc-final/gcc-final.mk
+++ b/package/gcc/gcc-final/gcc-final.mk
@@ -96,14 +96,11 @@ endef
-# Create <arch>-linux-<tool> symlinks
- (cd $(HOST_DIR)/usr/bin; for i in $(GNU_TARGET_NAME)-*; do \
- ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
- done)
+# Note: this must be done after CREATE_CC_SYMLINKS, otherwise the
+# -cc symlink to the wrapper is not created.
# In gcc 4.7.x, the ARM EABIhf library loader path for (e)glibc was not
# correct, so we create a symbolic link to make things work
diff --git a/package/gcc/gcc-initial/gcc-initial.mk b/package/gcc/gcc-initial/gcc-initial.mk
index 6bb7997b9f..4b03e47296 100644
--- a/package/gcc/gcc-initial/gcc-initial.mk
+++ b/package/gcc/gcc-initial/gcc-initial.mk
@@ -62,4 +62,8 @@ HOST_GCC_INITIAL_MAKE_OPTS += all-target-libgcc
HOST_GCC_INITIAL_INSTALL_OPTS += install-target-libgcc
$(eval $(host-autotools-package))
diff --git a/package/gcc/gcc.mk b/package/gcc/gcc.mk
index 501fcea50f..b9da39812a 100644
--- a/package/gcc/gcc.mk
+++ b/package/gcc/gcc.mk
@@ -235,4 +235,38 @@ HOST_GCC_COMMON_CONF_OPTS += \
+# The LTO support in gcc creates wrappers for ar, ranlib and nm which load
+# the lto plugin. These wrappers are called *-gcc-ar, *-gcc-ranlib, and
+# *-gcc-nm and should be used instead of the real programs when -flto is
+# used. However, we should not add the toolchain wrapper for them, and they
+# match the *cc-* pattern. Therefore, an additional case is added for *-ar,
+# *-ranlib and *-nm.
+# Avoid that a .real is symlinked a second time.
+# Also create <arch>-linux-<tool> symlinks.
+ $(Q)cd $(HOST_DIR)/usr/bin; \
+ for i in $(GNU_TARGET_NAME)-*; do \
+ case "$$i" in \
+ *.real) \
+ ;; \
+ *-ar|*-ranlib|*-nm) \
+ ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
+ ;; \
+ *cc|*cc-*|*++|*++-*|*cpp) \
+ rm -f $$i.real; \
+ mv $$i $$i.real; \
+ ln -sf toolchain-wrapper $$i; \
+ ln -sf toolchain-wrapper $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
+ ln -snf $$i.real $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}.real; \
+ ;; \
+ *) \
+ ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
+ ;; \
+ esac; \
+ done
include $(sort $(wildcard package/gcc/*/*.mk))