Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
kbuild: replace LANG=C with LC_ALL=C
Browse files Browse the repository at this point in the history
LANG gives a weak default to each LC_* in case it is not explicitly
defined. LC_ALL, if set, overrides all other LC_* variables.

  LANG  <  LC_CTYPE, LC_COLLATE, LC_MONETARY, LC_NUMERIC, ...  <  LC_ALL

This is why documentation such as [1] suggests to set LC_ALL in build
scripts to get the deterministic result.

LANG=C is not strong enough to override LC_* that may be set by end
users.

[1]: https://reproducible-builds.org/docs/locales/

Signed-off-by: Masahiro Yamada <[email protected]>
Acked-by: Michael Ellerman <[email protected]> (powerpc)
Reviewed-by: Matthias Maennich <[email protected]>
Acked-by: Matthieu Baerts <[email protected]> (mptcp)
Reviewed-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
masahir0y committed May 1, 2021
1 parent 885480b commit 77a8827
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/boot/wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ if [ -z "$kernel" ]; then
kernel=vmlinux
fi

LANG=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
LC_ALL=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
case "$elfformat" in
elf64-powerpcle) format=elf64lppc ;;
elf64-powerpc) format=elf32ppc ;;
Expand Down
2 changes: 1 addition & 1 deletion scripts/nsdeps
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ generate_deps() {
for source_file in $mod_source_files; do
sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
offset=$(wc -l ${source_file}.tmp | awk '{print $1;}')
cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp
cat $source_file | grep MODULE_IMPORT_NS | LC_ALL=C sort -u >> ${source_file}.tmp
tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp
if ! diff -q ${source_file} ${source_file}.tmp; then
mv ${source_file}.tmp ${source_file}
Expand Down
2 changes: 1 addition & 1 deletion scripts/recordmcount.pl
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ sub update_funcs
#
# Step 2: find the sections and mcount call sites
#
open(IN, "LANG=C $objdump -hdr $inputfile|") || die "error running $objdump";
open(IN, "LC_ALL=C $objdump -hdr $inputfile|") || die "error running $objdump";

my $text;

Expand Down
2 changes: 1 addition & 1 deletion scripts/setlocalversion
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ scm_version()
fi

# Check for svn and a svn repo.
if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then
if rev=$(LC_ALL=C svn info 2>/dev/null | grep '^Last Changed Rev'); then
rev=$(echo $rev | awk '{print $NF}')
printf -- '-svn%s' "$rev"

Expand Down
2 changes: 1 addition & 1 deletion scripts/tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -326,5 +326,5 @@ esac

# Remove structure forward declarations.
if [ -n "$remove_structs" ]; then
LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
LC_ALL=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
fi
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/mptcp/mptcp_connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ check_mptcp_disabled()
ip netns exec ${disabled_ns} sysctl -q net.mptcp.enabled=0

local err=0
LANG=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
grep -q "^socket: Protocol not available$" && err=1
ip netns delete ${disabled_ns}

Expand Down
2 changes: 1 addition & 1 deletion usr/gen_initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ dir_filelist() {
header "$1"

srcdir=$(echo "$1" | sed -e 's://*:/:g')
dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LANG=C sort)
dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" | LC_ALL=C sort)

# If $dirlist is only one line, then the directory is empty
if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
Expand Down

0 comments on commit 77a8827

Please sign in to comment.