Skip to content

Commit e3b8e2d

Browse files
committed
Merge tag 'kbuild-fixes-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada: - Make the *.mod build rule portable for POSIX awk - Fix regression of 'make nsdeps' - Make scripts/check-local-export working for older bash versions - Fix scripts/gdb to extract the .config data from vmlinux * tag 'kbuild-fixes-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: scripts/gdb: change kernel config dumping method scripts/check-local-export: avoid 'wait $!' for process substitution scripts/nsdeps: adjust to the format change of *.mod files kbuild: avoid regex RS for POSIX awk
2 parents 2275c6b + 1f7a6cf commit e3b8e2d

File tree

5 files changed

+40
-23
lines changed

5 files changed

+40
-23
lines changed

Documentation/process/changes.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ you probably needn't concern yourself with pcmciautils.
3232
GNU C 5.1 gcc --version
3333
Clang/LLVM (optional) 11.0.0 clang --version
3434
GNU make 3.81 make --version
35+
bash 4.2 bash --version
3536
binutils 2.23 ld -v
3637
flex 2.5.35 flex --version
3738
bison 2.0 bison --version
@@ -84,6 +85,12 @@ Make
8485

8586
You will need GNU make 3.81 or later to build the kernel.
8687

88+
Bash
89+
----
90+
91+
Some bash scripts are used for the kernel build.
92+
Bash 4.2 or newer is needed.
93+
8794
Binutils
8895
--------
8996

@@ -362,6 +369,11 @@ Make
362369

363370
- <ftp://ftp.gnu.org/gnu/make/>
364371

372+
Bash
373+
----
374+
375+
- <ftp://ftp.gnu.org/gnu/bash/>
376+
365377
Binutils
366378
--------
367379

scripts/Makefile.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
251251

252252
# To make this rule robust against "Argument list too long" error,
253253
# ensure to add $(obj)/ prefix by a shell command.
254-
cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \
255-
$(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@
254+
cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \
255+
$(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@
256256

257257
$(obj)/%.mod: FORCE
258258
$(call if_changed,mod)

scripts/check-local-export

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,31 @@
88

99
set -e
1010

11+
# catch errors from ${NM}
12+
set -o pipefail
13+
14+
# Run the last element of a pipeline in the current shell.
15+
# Without this, the while-loop would be executed in a subshell, and
16+
# the changes made to 'symbol_types' and 'export_symbols' would be lost.
17+
shopt -s lastpipe
18+
1119
declare -A symbol_types
1220
declare -a export_symbols
1321

1422
exit_code=0
1523

24+
# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows
25+
# 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by
26+
# '2>/dev/null'. However, it suppresses real error messages as well. Add a
27+
# hand-crafted error message here.
28+
#
29+
# TODO:
30+
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
31+
# binutils to 2.37, llvm to 13.0.0.
32+
# Then, the following line will be really simple:
33+
# ${NM} --quiet ${1} |
34+
35+
{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } } |
1636
while read value type name
1737
do
1838
# Skip the line if the number of fields is less than 3.
@@ -37,21 +57,7 @@ do
3757
if [[ ${name} == __ksymtab_* ]]; then
3858
export_symbols+=(${name#__ksymtab_})
3959
fi
40-
41-
# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm)
42-
# shows 'no symbols' diagnostic (but exits with 0). It is harmless and
43-
# hidden by '2>/dev/null'. However, it suppresses real error messages
44-
# as well. Add a hand-crafted error message here.
45-
#
46-
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version
47-
# of binutils to 2.37, llvm to 13.0.0.
48-
#
49-
# Then, the following line will be really simple:
50-
# done < <(${NM} --quiet ${1})
51-
done < <(${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } )
52-
53-
# Catch error in the process substitution
54-
wait $!
60+
done
5561

5662
for name in "${export_symbols[@]}"
5763
do

scripts/gdb/linux/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def invoke(self, arg, from_tty):
2424
filename = arg
2525

2626
try:
27-
py_config_ptr = gdb.parse_and_eval("kernel_config_data + 8")
28-
py_config_size = gdb.parse_and_eval(
29-
"sizeof(kernel_config_data) - 1 - 8 * 2")
27+
py_config_ptr = gdb.parse_and_eval("&kernel_config_data")
28+
py_config_ptr_end = gdb.parse_and_eval("&kernel_config_data_end")
29+
py_config_size = py_config_ptr_end - py_config_ptr
3030
except gdb.error as e:
3131
raise gdb.GdbError("Can't find config, enable CONFIG_IKCONFIG?")
3232

scripts/nsdeps

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ generate_deps() {
3434
local mod=${1%.ko:}
3535
shift
3636
local namespaces="$*"
37-
local mod_source_files="`cat $mod.mod | sed -n 1p \
38-
| sed -e 's/\.o/\.c/g' \
39-
| sed "s|[^ ]* *|${src_prefix}&|g"`"
37+
local mod_source_files=$(sed "s|^\(.*\)\.o$|${src_prefix}\1.c|" $mod.mod)
38+
4039
for ns in $namespaces; do
4140
echo "Adding namespace $ns to module $mod.ko."
4241
generate_deps_for_ns $ns "$mod_source_files"

0 commit comments

Comments
 (0)