[openwrt/openwrt] scripts: ext-toolchain: fix wrong prefix in print_config generation

LEDE Commits lede-commits at lists.infradead.org
Sun Dec 4 07:07:47 PST 2022


ansuel pushed a commit to openwrt/openwrt.git, branch openwrt-21.02:
https://git.openwrt.org/1e764ea7df11e1d51e60336f420ca73480b8c055

commit 1e764ea7df11e1d51e60336f420ca73480b8c055
Author: Christian Marangi <ansuelsmth at gmail.com>
AuthorDate: Sun Jul 3 02:20:11 2022 +0200

    scripts: ext-toolchain: fix wrong prefix in print_config generation
    
    The parsed prefix in print_config is wrong and this produce broken
    generated .config that won't work with any external toolchain.
    
    Currently the prefix from a CC of
    
    'arm-openwrt-linux-muslgnueabi-gcc-12.1.0'
    
    produce a prefix
    
    'arm-openwrt-linux-muslgnueabi-gcc-'
    
    This is wrong as the real prefix should be
    
    'arm-openwrt-linux-muslgnueabi-'
    
    This is probably caused by a change in how the toolchain is now handled
    that now append also the gcc version. Probably in ancient days the
    version wasn't part of the name and the prefix generation stripped the
    '-gcc' instead of the gcc version.
    
    Fix this and correctly strip the gcc version and the gcc suffix to
    correctly call toolchain bins.
    
    Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
    (cherry picked from commit 53c293262fce844c8291ab82e6726a8489d3c57b)
---
 scripts/ext-toolchain.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/ext-toolchain.sh b/scripts/ext-toolchain.sh
index 4da287591a..b52f170b32 100755
--- a/scripts/ext-toolchain.sh
+++ b/scripts/ext-toolchain.sh
@@ -281,8 +281,11 @@ print_config() {
 	local mksubtarget
 
 	local target="$("$CC" $CFLAGS -dumpmachine)"
+	local version="$("$CC" $CFLAGS -dumpversion)"
 	local cpuarch="${target%%-*}"
-	local prefix="${CC##*/}"; prefix="${prefix%-*}-"
+
+	# get CC; strip version; strip gcc and add - suffix
+	local prefix="${CC##*/}"; prefix="${prefix%-$version}"; prefix="${prefix%-*}-"
 	local config="${0%/scripts/*}/.config"
 
 	# if no target specified, print choice list and exit




More information about the lede-commits mailing list