From 59ef07e24f19070bec79e552821c654a68ba4cf9 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Thu, 22 Jan 2026 11:00:18 +0100 Subject: [PATCH] build_library: Fix setting gcc profile with latest gcc-config In order to fix some bash-completion issues, the output of "gcc-config -l" has changed slightly - it received one more leading space in the output. Old output: [1] aarch64-cros-linux-gnu-15 * New output: [1] aarch64-cros-linux-gnu-15 * This has added another field from cut's point of view, as it was splitting the line into fields by single spaces, which means that instead of getting "aarch64-cros-linux-gnu-15" we were getting "[1]". This has caused grep to match nothing, setting the error status in PIPESTATUS and finally a function failure. Instead of fiddling with leading empty fields, just strip the leading spaces, dammit. Signed-off-by: Krzesimir Nowak --- build_library/toolchain_util.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build_library/toolchain_util.sh b/build_library/toolchain_util.sh index 2b064ecbef..ce2a662283 100644 --- a/build_library/toolchain_util.sh +++ b/build_library/toolchain_util.sh @@ -490,10 +490,14 @@ binutils_set_latest_profile() { # The extra flag can be blank, hardenednopie, and so on. See gcc-config -l # Usage: gcc_get_latest_profile chost [extra] gcc_get_latest_profile() { - local prefix="${1}-" - local suffix="${2+-$2}" + local prefix=${1} + local suffix=${2+-${2}} local status - gcc-config -l | cut -d' ' -f3 | grep "^${prefix}[0-9\\.]*${suffix}$" | tail -n1 + gcc-config --list-profiles --nocolor | \ + sed -e 's/^\s*//' | \ + cut -d' ' -f2 | \ + grep "^${prefix}-[0-9\\.]*${suffix}$" | \ + tail -n1 # return 1 if anything in the above pipe failed for status in ${PIPESTATUS[@]}; do