Skip to contentSkip to conversation

kbuild: fix ld-version.sh to not be affected by locale

PATCH In review Masahiro Yamada 3 participants 3 messages Mar 12, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: fix ld-version.sh to not be affected by locale

ld-version.sh checks the output from $(LD) --version, but it has a problem on some locales.

For example, in Italian:

  $ LC_MESSAGES=it_IT.UTF-8 ld --version | head -n 1
  ld di GNU (GNU Binutils for Debian) 2.35.2

This makes ld-version.sh fail because it expects "GNU ld" for the BFD linker case.

Add LC_ALL=C to override the user's locale.

BTW, setting LC_MESSAGES=C (or LANG=C) is not enough because it is ineffective if LC_ALL is set on the user's environment.

---

 scripts/ld-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/ld-version.sh +1 -1
index 30debf78aa09..1bf3aadde9de 100755
@@ -29,7 +29,7 @@ orig_args="$@"
 # Get the first line of the --version output.
 IFS='
 '
-set -- $("$@" --version)
+set -- $(LC_ALL=C "$@" --version)
 
 # Split the line on spaces.
 IFS=' '
Signature · 1 line
2.27.0
#1 lore raw
Quoted 12 lines · Masahiro Yamada

ld-version.sh checks the output from $(LD) --version, but it has a problem on some locales.

For example, in Italian:

  $ LC_MESSAGES=it_IT.UTF-8 ld --version | head -n 1
  ld di GNU (GNU Binutils for Debian) 2.35.2

This makes ld-version.sh fail because it expects "GNU ld" for the BFD linker case.

Quoted 8 lines

Add LC_ALL=C to override the user's locale.

BTW, setting LC_MESSAGES=C (or LANG=C) is not enough because it is ineffective if LC_ALL is set on the user's environment.

Recensito-Da: Nick Desaulniers <[email protected]>

In realtà non parlo italiano, ma so come usare Google Translate.

Quoted 21 lines

---

 scripts/ld-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/ld-version.sh +1 -2
index 30debf78aa09..1bf3aadde9de 100755
@@ -29,7 +29,7 @@ orig_args="$@"
 # Get the first line of the --version output.
 IFS='
 '
-set -- $("$@" --version)
+set -- $(LC_ALL=C "$@" --version)
 
 # Split the line on spaces.
 IFS=' '
--

2.27.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

ld-version.sh checks the output from $(LD) --version, but it has a problem on some locales.

For example, in Italian:

  $ LC_MESSAGES=it_IT.UTF-8 ld --version | head -n 1
  ld di GNU (GNU Binutils for Debian) 2.35.2

This makes ld-version.sh fail because it expects "GNU ld" for the BFD linker case.

Quoted 8 lines

Add LC_ALL=C to override the user's locale.

BTW, setting LC_MESSAGES=C (or LANG=C) is not enough because it is ineffective if LC_ALL is set on the user's environment.

LGTM, this is Debian's recommendation as well:
https://wiki.debian.org/Locale

Quoted 21 lines

---

 scripts/ld-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/ld-version.sh +1 -1
index 30debf78aa09..1bf3aadde9de 100755
@@ -29,7 +29,7 @@ orig_args="$@"
 # Get the first line of the --version output.
 IFS='
 '
-set -- $("$@" --version)
+set -- $(LC_ALL=C "$@" --version)
 
 # Split the line on spaces.
 IFS=' '
Signature · 1 line
2.27.0