[openwrt/openwrt] toolchain/wrapper: fill and reference info.mk in staging_dir ext toolchain

LEDE Commits lede-commits at lists.infradead.org
Sun Apr 21 08:59:30 PDT 2024


ansuel pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/0e161968a7358cc23af28b627ecb794b3cdaea72

commit 0e161968a7358cc23af28b627ecb794b3cdaea72
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Sat Apr 20 18:29:23 2024 +0200

    toolchain/wrapper: fill and reference info.mk in staging_dir ext toolchain
    
    Currently when external toolchain is used, a info.mk is created (with
    to-be-filled values) but is never actually filled with real values and
    is never actually used in rules.mk.
    
    This info.mk is used down the code with special packages like libgcc to
    reference info like gcc version and package special library.
    
    To mimic what is done with internal toolchain, add the include in
    rules.mk for info.mk also for external library and in fix
    toolchain/wrapper to fill the staging_dir info.mk.
    
    The logic is to check if the external toolchain provide an info.mk and
    if it doesn't we at least fill the GCC_VERSION with the value set in the
    .config file.
    
    With this special library like libgcc correctly reference and have set the
    GCC_VERSION variable.
    
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
 rules.mk                   |  1 +
 toolchain/wrapper/Makefile | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/rules.mk b/rules.mk
index 6f05047f26..84586ac26b 100644
--- a/rules.mk
+++ b/rules.mk
@@ -194,6 +194,7 @@ ifndef DUMP
     endif
   else
     ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
+      -include $(TOOLCHAIN_DIR)/info.mk
       TARGET_CROSS:=$(call qstrip,$(CONFIG_TOOLCHAIN_PREFIX))
       TOOLCHAIN_ROOT_DIR:=$(call qstrip,$(CONFIG_TOOLCHAIN_ROOT))
       TOOLCHAIN_BIN_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_BIN_PATH)))
diff --git a/toolchain/wrapper/Makefile b/toolchain/wrapper/Makefile
index 3398e407c9..e1f8389b1f 100644
--- a/toolchain/wrapper/Makefile
+++ b/toolchain/wrapper/Makefile
@@ -38,6 +38,14 @@ $$(if $$($(1)), \
 endef
 
 
+define Host/SetToolchainInfo
+	if [ -f $(CONFIG_TOOLCHAIN_ROOT)/info.mk ]; then \
+		$(CP) $(CONFIG_TOOLCHAIN_ROOT)/info.mk $(TOOLCHAIN_DIR)/; \
+	else \
+		$(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(CONFIG_GCC_VERSION),' $(TOOLCHAIN_DIR)/info.mk; \
+	fi
+endef
+
 define Host/Prepare
 	$(call toolchain_test,CONFIG_SOFT_FLOAT,softfloat)
 	$(call toolchain_test,CONFIG_IPV6,ipv6)
@@ -53,10 +61,12 @@ endef
 
 define Host/Install
 	$(call toolchain_util,--wrap "$(TOOLCHAIN_DIR)/bin")
+	$(call Host/SetToolchainInfo)
 endef
 
 define Host/Clean
 	rm -rf $(TOOLCHAIN_DIR)/bin
+	rm -rf $(TOOLCHAIN_DIR)/info.mk
 endef
 
 $(eval $(call HostBuild))




More information about the lede-commits mailing list