Commit bc35d4bd authored by Masahiro Yamada's avatar Masahiro Yamada

scripts/nsdeps: support nsdeps for external module builds

scripts/nsdeps is written to take care of only in-tree modules.
Perhaps, this is not a bug, but just a design. At least,
Documentation/core-api/symbol-namespaces.rst focuses on in-tree modules.

Having said that, some people already tried nsdeps for external modules.
So, it would be nice to support it.
Reported-by: default avatarSteve French <smfrench@gmail.com>
Reported-by: default avatarJessica Yu <jeyu@kernel.org>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: default avatarJessica Yu <jeyu@kernel.org>
Acked-by: default avatarJessica Yu <jeyu@kernel.org>
Reviewed-by: default avatarMatthias Maennich <maennich@google.com>
Tested-by: default avatarMatthias Maennich <maennich@google.com>
parent bbc55bde
...@@ -152,3 +152,6 @@ in-tree modules:: ...@@ -152,3 +152,6 @@ in-tree modules::
- notice the warning of modpost telling about a missing import - notice the warning of modpost telling about a missing import
- run `make nsdeps` to add the import to the correct code location - run `make nsdeps` to add the import to the correct code location
You can also run nsdeps for external module builds. A typical usage is::
$ make -C <path_to_kernel_src> M=$PWD nsdeps
...@@ -1008,6 +1008,7 @@ endif ...@@ -1008,6 +1008,7 @@ endif
PHONY += prepare0 PHONY += prepare0
export MODORDER := $(extmod-prefix)modules.order export MODORDER := $(extmod-prefix)modules.order
export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
...@@ -1620,7 +1621,7 @@ _emodinst_post: _emodinst_ ...@@ -1620,7 +1621,7 @@ _emodinst_post: _emodinst_
$(call cmd,depmod) $(call cmd,depmod)
clean-dirs := $(KBUILD_EXTMOD) clean-dirs := $(KBUILD_EXTMOD)
clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps
PHONY += / PHONY += /
/: /:
......
...@@ -66,7 +66,7 @@ __modpost: ...@@ -66,7 +66,7 @@ __modpost:
else else
MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
$(if $(KBUILD_NSDEPS),-d modules.nsdeps) $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
MODPOST += $(wildcard vmlinux) MODPOST += $(wildcard vmlinux)
......
...@@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then ...@@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then
exit 1 exit 1
fi fi
if [ "$KBUILD_EXTMOD" ]; then
src_prefix=
else
src_prefix=$srctree/
fi
generate_deps_for_ns() { generate_deps_for_ns() {
$SPATCH --very-quiet --in-place --sp-file \ $SPATCH --very-quiet --in-place --sp-file \
$srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2 $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2
...@@ -32,7 +38,7 @@ generate_deps() { ...@@ -32,7 +38,7 @@ generate_deps() {
local namespaces="$*" local namespaces="$*"
local mod_source_files="`cat $mod.mod | sed -n 1p \ local mod_source_files="`cat $mod.mod | sed -n 1p \
| sed -e 's/\.o/\.c/g' \ | sed -e 's/\.o/\.c/g' \
| sed "s|[^ ]* *|${srctree}/&|g"`" | sed "s|[^ ]* *|${src_prefix}&|g"`"
for ns in $namespaces; do for ns in $namespaces; do
echo "Adding namespace $ns to module $mod.ko." echo "Adding namespace $ns to module $mod.ko."
generate_deps_for_ns $ns "$mod_source_files" generate_deps_for_ns $ns "$mod_source_files"
...@@ -54,4 +60,4 @@ generate_deps() { ...@@ -54,4 +60,4 @@ generate_deps() {
while read line while read line
do do
generate_deps $line generate_deps $line
done < modules.nsdeps done < $MODULES_NSDEPS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment