From patchwork Tue Oct 29 12:38:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 178025 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4815870ill; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJWczg9EHJ5YHOFTxgtXN9xeLtGLEpETAFbQ09rgAcpguURDnpCCswwadIkMfLo2p9J+hh X-Received: by 2002:a50:b966:: with SMTP id m93mr24979506ede.228.1572352753390; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572352753; cv=none; d=google.com; s=arc-20160816; b=LgaVzKuC6XYwsEqp8SrK4s+hH7DGLEGJRaZT1JDQl8OXr3EMWJC55u/Qm2pPJv3NBc p9K3R9xGxTzdDXPY5LOsoJjsahOh78vLqOz3Pe5GJPFZ3XCP27AqH+olB0wbu8pqAEUv MHdtEiar9g7mOUljzabgUA7vcaPUslGQp6zli/oBnYeMwTCBAcf9RoEu/Y06HzJwZH78 /PkvQSFwJ8lcTCXYrU/T6fHixG6evjNrrT9fiSdObHCvaq63Jxpj2rSvGnR1nJ2O3s4P Yn9dLAij5m9E0GhGtK35tjYa4bMN6zd4dReTdL1QVrJamhEO6YWq6W8yRMuyZrAlF/xj Mh2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=z/tV1UVFmLOh9LhEg5n7pGMfQ61W9oGUm9h6rNaYBKY=; b=mdR1ctQs8qA740qV1WQTammp2XjLUBUTAEA0Kbw9lPJDjYgFQfqDvPAj+Cx1/FoOdy upFk+gTBwh1iSjApE4escOAfTIM2JyFikHbLKILsTanVTPWtDvDIdNrIMykDDwWfpjap CDwZlaC+RewDtTT6rx6bCq/wgAydRhw0hFJFetD6tM+5MhhaFY+5aql+K4NPyb3ymeaD 316tS6TP08B+pt5VizCfKQUuwfdmOwGov4xq9dtxrPF8gnsc9+JvMecQWllD3qOX6OV0 L1DtTLrmE/d4GFUrs43XENP2IidWUr7IRRAe98RNXsuozujPYGs+SRwc21cNadCzEySJ JX6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="IF6A2H6/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si9957268eda.435.2019.10.29.05.39.13; Tue, 29 Oct 2019 05:39:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b="IF6A2H6/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387527AbfJ2MjK (ORCPT + 26 others); Tue, 29 Oct 2019 08:39:10 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:34529 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731583AbfJ2MjI (ORCPT ); Tue, 29 Oct 2019 08:39:08 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x9TCcFU8026616; Tue, 29 Oct 2019 21:38:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x9TCcFU8026616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1572352701; bh=z/tV1UVFmLOh9LhEg5n7pGMfQ61W9oGUm9h6rNaYBKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IF6A2H6/659VDSshC51rM8eOxVwdf2Vq7bpkxUuGg9sky0oSfaGheBOHrJBCiZqId sQfatTY7oXNjFOfk89m6ybFLdM2RpDSMQYBTUgBGuCClMWfxPe+66QCy4KfaRDd0/C yMtdbMRElyCd8BFEh1WVLHsJQtV3xaWYeMItKGLRxIl375jvusaLN+YQsqfi7kBsvV Ppc9xa/KFVl4ygOm+N9/RiKzv+ChJR+z3g1+N5bVO4vKrOY6ws9IPRCpADS9W0jdiK al/EGogQTKc83NqQIZqarz5piWxLU87ATvRPpGYVer/EnHYncReYibZ0QLPgcl+T/I rPi+YR6Tx+IDg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Jessica Yu , Matthias Kaehlcke , Masahiro Yamada , Jonathan Corbet , Matthias Maennich , Michal Marek , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] scripts/nsdeps: support nsdeps for external module builds Date: Tue, 29 Oct 2019 21:38:08 +0900 Message-Id: <20191029123809.29301-4-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191029123809.29301-1-yamada.masahiro@socionext.com> References: <20191029123809.29301-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Apparently, 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: Again, `make nsdeps` will eventually add the missing namespace imports for in-tree modules:: ^^^^^^^ Having said that, I already saw at least two people trying nsdeps for external module builds. So, it would be nice to support it. Reported-by: Steve French Reported-by: Jessica Yu Signed-off-by: Masahiro Yamada --- Documentation/core-api/symbol-namespaces.rst | 3 +++ Makefile | 1 + scripts/Makefile.modpost | 2 +- scripts/nsdeps | 10 ++++++++-- 4 files changed, 13 insertions(+), 3 deletions(-) -- 2.17.1 Tested-by: Jessica Yu Acked-by: Jessica Yu Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich diff --git a/Documentation/core-api/symbol-namespaces.rst b/Documentation/core-api/symbol-namespaces.rst index 982ed7b568ac..9b76337f6756 100644 --- a/Documentation/core-api/symbol-namespaces.rst +++ b/Documentation/core-api/symbol-namespaces.rst @@ -152,3 +152,6 @@ in-tree modules:: - notice the warning of modpost telling about a missing import - 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 M=$PWD nsdeps diff --git a/Makefile b/Makefile index 1e3f307bd49b..780a65493866 100644 --- a/Makefile +++ b/Makefile @@ -1007,6 +1007,7 @@ endif PHONY += prepare0 export MODORDER := $(extmod-prefix)modules.order +export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index da37128c3f9f..8359f8af5ee6 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ - $(if $(KBUILD_NSDEPS),-d modules.nsdeps) + $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) diff --git a/scripts/nsdeps b/scripts/nsdeps index 08db427a7fe5..3b8a9e173ebf 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then exit 1 fi +if [ "$KBUILD_EXTMOD" ]; then + src_prefix= +else + src_prefix=$srctree/ +fi + generate_deps_for_ns() { $SPATCH --very-quiet --in-place --sp-file \ $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2 @@ -32,7 +38,7 @@ generate_deps() { local namespaces="$*" local mod_source_files=`cat $mod.mod | sed -n 1p \ | sed -e 's/\.o/\.c/g' \ - | sed "s|[^ ]* *|${srctree}/&|g"` + | sed "s|[^ ]* *|${src_prefix}&|g"` for ns in $namespaces; do echo "Adding namespace $ns to module $mod.ko." generate_deps_for_ns $ns $mod_source_files @@ -54,4 +60,4 @@ generate_deps() { while read line do generate_deps $line -done < modules.nsdeps +done < $MODULES_NSDEPS