When a building package has -flto option leads to building error

We must use the gcc-ar wrapper instead of ar to invoke ar with the right
plugin arguments for handling the LTO objects when -flto is specified.

Signed-off-by: Che-Wei Chuang <[email protected]>
Signed-off-by: Nylon Chen <[email protected]>
---
 rules.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/rules.mk b/rules.mk
index 80cb3d63f4..8d1c2b7cd2 100644
--- a/rules.mk
+++ b/rules.mk
@@ -256,9 +256,15 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
   TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
   TARGET_NM:=$(TARGET_CROSS)gcc-nm
 else
-  TARGET_AR:=$(TARGET_CROSS)ar
-  TARGET_RANLIB:=$(TARGET_CROSS)ranlib
-  TARGET_NM:=$(TARGET_CROSS)nm
+  ifeq ($(ARCH),nds32)
+    TARGET_AR:=$(TARGET_CROSS)gcc-ar
+    TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
+    TARGET_NM:=$(TARGET_CROSS)gcc-nm
+  else
+    TARGET_AR:=$(TARGET_CROSS)ar
+    TARGET_RANLIB:=$(TARGET_CROSS)ranlib
+    TARGET_NM:=$(TARGET_CROSS)nm
+  endif
 endif
 
 BUILD_KEY=$(TOPDIR)/key-build
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to