aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/gcc/gcc-final/gcc-final.mk13
-rw-r--r--package/gcc/gcc-initial/gcc-initial.mk4
-rw-r--r--package/gcc/gcc.mk34
-rw-r--r--toolchain/toolchain-wrapper.c4
4 files changed, 46 insertions, 9 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
HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_CREATE_CC_SYMLINKS
-# Create <arch>-linux-<tool> symlinks
-define HOST_GCC_FINAL_CREATE_SIMPLE_SYMLINKS
- (cd $(HOST_DIR)/usr/bin; for i in $(GNU_TARGET_NAME)-*; do \
- ln -snf $$i $(ARCH)-linux$${i##$(GNU_TARGET_NAME)}; \
- done)
-endef
-
-HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_FINAL_CREATE_SIMPLE_SYMLINKS
+HOST_GCC_FINAL_TOOLCHAIN_WRAPPER_ARGS += $(HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS)
+HOST_GCC_FINAL_POST_BUILD_HOOKS += TOOLCHAIN_BUILD_WRAPPER
+# Note: this must be done after CREATE_CC_SYMLINKS, otherwise the
+# -cc symlink to the wrapper is not created.
+HOST_GCC_FINAL_POST_INSTALL_HOOKS += HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
# 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
endif
+HOST_GCC_INITIAL_TOOLCHAIN_WRAPPER_ARGS += $(HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS)
+HOST_GCC_INITIAL_POST_BUILD_HOOKS += TOOLCHAIN_BUILD_WRAPPER
+HOST_GCC_INITIAL_POST_INSTALL_HOOKS += HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_SYMLINKS
+
$(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 += \
--with-long-double-128
endif
+HOST_GCC_COMMON_TOOLCHAIN_WRAPPER_ARGS += -DBR_CROSS_PATH_SUFFIX='".real"'
+
+# 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.
+define HOST_GCC_INSTALL_WRAPPER_AND_SIMPLE_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
+
+endef
+
include $(sort $(wildcard package/gcc/*/*.mk))
diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index ac40decd57..d4d25c7057 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -138,8 +138,10 @@ int main(int argc, char **argv)
/* Fill in the relative paths */
#ifdef BR_CROSS_PATH_REL
ret = snprintf(path, sizeof(path), "%s/" BR_CROSS_PATH_REL "/%s", absbasedir, basename);
-#else /* BR_CROSS_PATH_ABS */
+#elif BR_CROSS_PATH_ABS
ret = snprintf(path, sizeof(path), BR_CROSS_PATH_ABS "/%s", basename);
+#else /* BR_CROSS_PATH_SUFFIX */
+ ret = snprintf(path, sizeof(path), "%s/usr/bin/%s" BR_CROSS_PATH_SUFFIX, absbasedir, basename);
#endif
if (ret >= sizeof(path)) {
perror(__FILE__ ": overflow");