Skip to content

Commit

Permalink
Merge tag 'kbuild-fixes-v5.19' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Linus Torvalds committed Jun 12, 2022
2 parents 2275c6b + 1f7a6cf commit e3b8e2d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
12 changes: 12 additions & 0 deletions Documentation/process/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ you probably needn't concern yourself with pcmciautils.
GNU C 5.1 gcc --version
Clang/LLVM (optional) 11.0.0 clang --version
GNU make 3.81 make --version
bash 4.2 bash --version
binutils 2.23 ld -v
flex 2.5.35 flex --version
bison 2.0 bison --version
Expand Down Expand Up @@ -84,6 +85,12 @@ Make

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

Bash
----

Some bash scripts are used for the kernel build.
Bash 4.2 or newer is needed.

Binutils
--------

Expand Down Expand Up @@ -362,6 +369,11 @@ Make

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

Bash
----

- <ftp://ftp.gnu.org/gnu/bash/>

Binutils
--------

Expand Down
4 changes: 2 additions & 2 deletions scripts/Makefile.build
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE

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

$(obj)/%.mod: FORCE
$(call if_changed,mod)
Expand Down
36 changes: 21 additions & 15 deletions scripts/check-local-export
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,31 @@

set -e

# catch errors from ${NM}
set -o pipefail

# Run the last element of a pipeline in the current shell.
# Without this, the while-loop would be executed in a subshell, and
# the changes made to 'symbol_types' and 'export_symbols' would be lost.
shopt -s lastpipe

declare -A symbol_types
declare -a export_symbols

exit_code=0

# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm) shows
# 'no symbols' diagnostic (but exits with 0). It is harmless and hidden by
# '2>/dev/null'. However, it suppresses real error messages as well. Add a
# hand-crafted error message here.
#
# TODO:
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
# binutils to 2.37, llvm to 13.0.0.
# Then, the following line will be really simple:
# ${NM} --quiet ${1} |

{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } } |
while read value type name
do
# Skip the line if the number of fields is less than 3.
Expand All @@ -37,21 +57,7 @@ do
if [[ ${name} == __ksymtab_* ]]; then
export_symbols+=(${name#__ksymtab_})
fi

# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm)
# shows 'no symbols' diagnostic (but exits with 0). It is harmless and
# hidden by '2>/dev/null'. However, it suppresses real error messages
# as well. Add a hand-crafted error message here.
#
# Use --quiet instead of 2>/dev/null when we upgrade the minimum version
# of binutils to 2.37, llvm to 13.0.0.
#
# Then, the following line will be really simple:
# done < <(${NM} --quiet ${1})
done < <(${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } )

# Catch error in the process substitution
wait $!
done

for name in "${export_symbols[@]}"
do
Expand Down
6 changes: 3 additions & 3 deletions scripts/gdb/linux/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def invoke(self, arg, from_tty):
filename = arg

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

Expand Down
5 changes: 2 additions & 3 deletions scripts/nsdeps
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ generate_deps() {
local mod=${1%.ko:}
shift
local namespaces="$*"
local mod_source_files="`cat $mod.mod | sed -n 1p \
| sed -e 's/\.o/\.c/g' \
| sed "s|[^ ]* *|${src_prefix}&|g"`"
local mod_source_files=$(sed "s|^\(.*\)\.o$|${src_prefix}\1.c|" $mod.mod)

for ns in $namespaces; do
echo "Adding namespace $ns to module $mod.ko."
generate_deps_for_ns $ns "$mod_source_files"
Expand Down

0 comments on commit e3b8e2d

Please sign in to comment.