Skip to contentSkip to conversation

scripts: override locale from environment when running recordmcount.pl

PATCH Superseded Daniel Dadap 2 participants 5 messages Apr 24, 2019 – Apr 28, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts: override locale from environment when running recordmcount.pl

recordmcount.pl uses a set of regular expressions to parse the output of objdump(1). However, if objdump(1) output is localized, it may not match the regular expressions, thereby preventing recordmcount.pl from parsing object files correctly.

In order to allow recordmcount.pl to function correctly regardless of the current locale settings, set LANG=C when running objdump(1). LC_ALL is already unset in the top-level Makefile, so it is not necessary to also override that environment variable.

---
 scripts/recordmcount.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.pl +1 -1
index 68841d01162c..b7bcdc71e6e8 100755
@@ -493,7 +493,7 @@ sub update_funcs
 #
 # Step 2: find the sections and mcount call sites
 #
-open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump";
+open(IN, "env LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
 
 my $text;
 
Signature · 1 line
2.18.1
#1 lore raw
Quoted 22 lines · Daniel Dadap

recordmcount.pl uses a set of regular expressions to parse the output of objdump(1). However, if objdump(1) output is localized, it may not match the regular expressions, thereby preventing recordmcount.pl from parsing object files correctly.

In order to allow recordmcount.pl to function correctly regardless of the current locale settings, set LANG=C when running objdump(1). LC_ALL is already unset in the top-level Makefile, so it is not necessary to also override that environment variable.

---
 scripts/recordmcount.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.pl +0 -0
index 68841d01162c..b7bcdc71e6e8 100755

scripts/recordmcount.pl sub update_funcs · line 496

Quoted 5 lines
scripts/recordmcount.pl +1 -1
@@ -493,7 +493,7 @@ sub update_funcs
 #
 # Step 2: find the sections and mcount call sites
 #
-open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump";
+open(IN, "env LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";

Just to be consistent with the other places,
is 'env' necessary?

arch/powerpc/boot/wrapper:LANG=C elfformat="${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'"
scripts/tags.sh: LANG=C sed -i -e
'/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 tools/testing/selftests/rcutorture/bin/config2frag.sh:LANG=C sed -e 's/^# CONFIG_\([a-zA-Z0-9_]*\) is not set$/CONFIG_\1=n/'

Quoted 5 lines
scripts/recordmcount.pl +0 -1
 my $text;
 
--

2.18.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 31 lines · Masahiro Yamada
Quoted 21 lines · Daniel Dadap

recordmcount.pl uses a set of regular expressions to parse the output of objdump(1). However, if objdump(1) output is localized, it may not match the regular expressions, thereby preventing recordmcount.pl from parsing object files correctly.

In order to allow recordmcount.pl to function correctly regardless of the current locale settings, set LANG=C when running objdump(1). LC_ALL is already unset in the top-level Makefile, so it is not necessary to also override that environment variable.

---
  scripts/recordmcount.pl | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.pl +0 -0
index 68841d01162c..b7bcdc71e6e8 100755

scripts/recordmcount.pl sub update_funcs · line 496

Quoted 5 lines
scripts/recordmcount.pl +1 -1
@@ -493,7 +493,7 @@ sub update_funcs
  #
  # Step 2: find the sections and mcount call sites
  #
-open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump";
+open(IN, "env LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";

Just to be consistent with the other places,
is 'env' necessary?

Quoted 6 lines

arch/powerpc/boot/wrapper:LANG=C elfformat="${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'"
scripts/tags.sh: LANG=C sed -i -e
'/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1 tools/testing/selftests/rcutorture/bin/config2frag.sh:LANG=C sed -e 's/^# CONFIG_\([a-zA-Z0-9_]*\) is not set$/CONFIG_\1=n/'

It's probably not strictly necessary; the 'env' is there in case of a shell that doesn't allow setting environment variables on the command line like that, but if Kbuild already presumes a shell that does allow it, I'm happy to send a v2 that omits the 'env'.

Quoted 7 lines
Quoted 6 lines
scripts/recordmcount.pl +0 -1
  my $text;
 
--

2.18.1

#3 lore raw

PATCH v2 1/1 scripts: override locale from environment when running recordmcount.pl

recordmcount.pl uses a set of regular expressions to parse the output of objdump(1). However, if objdump(1) output is localized, it may not match the regular expressions, thereby preventing recordmcount.pl from parsing object files correctly.

In order to allow recordmcount.pl to function correctly regardless of the current locale settings, set LANG=C when running objdump(1). LC_ALL is already unset in the top-level Makefile, so it is not necessary to also override that environment variable.

---
 scripts/recordmcount.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.pl +1 -1
index 68841d01162c..ffea46287f83 100755
@@ -493,7 +493,7 @@ sub update_funcs
 #
 # Step 2: find the sections and mcount call sites
 #
-open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump";
+open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
 
 my $text;
 
Signature · 1 line
2.18.1
#4 lore raw
Quoted 6 lines · Daniel Dadap

recordmcount.pl uses a set of regular expressions to parse the output of objdump(1). However, if objdump(1) output is localized, it may not match the regular expressions, thereby preventing recordmcount.pl from parsing object files correctly.

Quoted 7 lines

In order to allow recordmcount.pl to function correctly regardless of the current locale settings, set LANG=C when running objdump(1). LC_ALL is already unset in the top-level Makefile, so it is not necessary to also override that environment variable.

Applied to linux-kbuild.
Thanks.

Quoted 20 lines
---
 scripts/recordmcount.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/recordmcount.pl +1 -2
index 68841d01162c..ffea46287f83 100755
@@ -493,7 +493,7 @@ sub update_funcs
 #
 # Step 2: find the sections and mcount call sites
 #
-open(IN, "$objdump -hdr $inputfile|") || die "error running $objdump";
+open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
 
 my $text;
 
--

2.18.1

Signature · 2 lines
Best Regards
Masahiro Yamada