History

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.

Masahiro Yamada committed 7 years ago

Commit bc35d4b1 parent bbc55bd4 files · +14 −4Browse files

Unified · Split

4 files
  1. Documentation/core-api/symbol-namespaces.rst +3 −0
  2. Makefile +2 −1
  3. scripts/Makefile.modpost +1 −1
  4. scripts/nsdeps +8 −2
Documentation/core-api/symbol-namespaces.rst+3−0
@@ -152,3 +152,6 @@ in-tree modules:: · 151 unmodified lines
152 - notice the warning of modpost telling about a missing import152 - notice the warning of modpost telling about a missing import
153 - run `make nsdeps` to add the import to the correct code location153 - run `make nsdeps` to add the import to the correct code location
154 154
155You can also run nsdeps for external module builds. A typical usage is::
156
157 $ make -C <path_to_kernel_src> M=$PWD nsdeps
Makefile+2−1
@@ -1008,6 +1008,7 @@ endif · 1007 unmodified lines
1008PHONY += prepare01008PHONY += prepare0
1009 1009
1010export MODORDER := $(extmod-prefix)modules.order1010export MODORDER := $(extmod-prefix)modules.order
1011export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
1011 1012
1012ifeq ($(KBUILD_EXTMOD),)1013ifeq ($(KBUILD_EXTMOD),)
1013core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/1014core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
@@ -1620,7 +1621,7 @@ _emodinst_post: _emodinst_ · 606 unmodified lines
1620 $(call cmd,depmod)1621 $(call cmd,depmod)
1621 1622
1622clean-dirs := $(KBUILD_EXTMOD)1623clean-dirs := $(KBUILD_EXTMOD)
1623clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers1624clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps
1624 1625
1625PHONY += /1626PHONY += /
1626/:1627/:
scripts/Makefile.modpost+1−1
@@ -66,7 +66,7 @@ __modpost: · 65 unmodified lines
66else66else
67 67
68MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \68MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \
69 $(if $(KBUILD_NSDEPS),-d modules.nsdeps)69 $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS))
70 70
71ifeq ($(KBUILD_EXTMOD),)71ifeq ($(KBUILD_EXTMOD),)
72MODPOST += $(wildcard vmlinux)72MODPOST += $(wildcard vmlinux)
scripts/nsdeps+8−2
@@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then · 20 unmodified lines
21 exit 121 exit 1
22fi22fi
23 23
24if [ "$KBUILD_EXTMOD" ]; then
25 src_prefix=
26else
27 src_prefix=$srctree/
28fi
29
24generate_deps_for_ns() {30generate_deps_for_ns() {
25 $SPATCH --very-quiet --in-place --sp-file \31 $SPATCH --very-quiet --in-place --sp-file \
26 $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $232 $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2
@@ -32,7 +38,7 @@ generate_deps() { · 5 unmodified lines
32 local namespaces="$*"38 local namespaces="$*"
33 local mod_source_files="`cat $mod.mod | sed -n 1p \39 local mod_source_files="`cat $mod.mod | sed -n 1p \
34 | sed -e 's/\.o/\.c/g' \40 | sed -e 's/\.o/\.c/g' \
35 | sed "s|[^ ]* *|${srctree}/&|g"`"41 | sed "s|[^ ]* *|${src_prefix}&|g"`"
36 for ns in $namespaces; do42 for ns in $namespaces; do
37 echo "Adding namespace $ns to module $mod.ko."43 echo "Adding namespace $ns to module $mod.ko."
38 generate_deps_for_ns $ns "$mod_source_files"44 generate_deps_for_ns $ns "$mod_source_files"
@@ -54,4 +60,4 @@ generate_deps() { · 15 unmodified lines
54while read line60while read line
55do61do
56 generate_deps $line62 generate_deps $line
57done < modules.nsdeps63done < $MODULES_NSDEPS