Skip to content

Commit b1cabd6

Browse files
committed
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 <knowak@microsoft.com>
1 parent 24a935b commit b1cabd6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

build_library/toolchain_util.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,14 @@ binutils_set_latest_profile() {
490490
# The extra flag can be blank, hardenednopie, and so on. See gcc-config -l
491491
# Usage: gcc_get_latest_profile chost [extra]
492492
gcc_get_latest_profile() {
493-
local prefix="${1}-"
494-
local suffix="${2+-$2}"
493+
local prefix=${1}
494+
local suffix=${2+-${2}}
495495
local status
496-
gcc-config -l | cut -d' ' -f3 | grep "^${prefix}[0-9\\.]*${suffix}$" | tail -n1
496+
gcc-config --list-profiles --nocolor | \
497+
sed -e 's/^\s*//' | \
498+
cut -d' ' -f2 | \
499+
grep "^${prefix}-[0-9\\.]*${suffix}$" | \
500+
tail -n1
497501

498502
# return 1 if anything in the above pipe failed
499503
for status in ${PIPESTATUS[@]}; do

0 commit comments

Comments
 (0)