From patchwork Mon Mar 19 09:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132027 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp2476017ljb; Mon, 19 Mar 2018 02:02:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELujp/ylpeAEx8sB7gFDgnK4wMKv7S6Z42msR5XOdRHfOCm+UzEvlfnEv9CyA25YPHToI4T0 X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr11716907plt.303.1521450166237; Mon, 19 Mar 2018 02:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521450166; cv=none; d=google.com; s=arc-20160816; b=TXa2RH0QenG6B1zQa80XPcvMMXZvQoFiazibtbk8YpmbA9TSME+bXli/mBdSJN95kg 07k1dc50zpUmXk87CdCGfOWbAfHQs9ZIgYnqWuSW6gle3mL8IXVvesDiVjDUT4PIET2i EPbDY1BaEEFrvzfXHPk3dvAUoKSYbwrYL/B+HbgfjvTCmUPgDGYmN0gdP191XuMGAzNb i3bYkxJl0jqpxytz7bZz83TZ57mTqrHTYrLLg4e9pNaGXXqiCdhHOR4mU2FGlK1iL5dm 2IwYMFnndpNfNvw3Xzj4gWA+0oFv28n1omLMQDms97fjJir1uneiJTKZ9wmNKk67M9Q6 1dkg== 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 :arc-authentication-results; bh=FMYkrRtcw40ThDSxNw+8i2XtQSBoeeABpm1A0EPSLSE=; b=JjbvtPJWfRxCytAXrHFOFve2F7aEfDaXq3AZkbiDUPLjpbe6vFPBn7OGiZU5ZXAtM0 Q+MvlBzuemWK1nDYfg9hy6n7Q3qncm8H5RY/hZwtGcB1e44cXWIdjUWtKSCO7eBP7eOC RWvFCXRCOM63oYgStXOcR0BoS+TBBpu7LvMtPLcrKuDYyVbGhY4PlhPxB+ufY7svx5+y DD2wtOlh16j510u1CIClmLO8bGYE7Vm4NvjFS0KYGlrFkqPlSfz27ARQfwof78EqOUtm FdCYVzEBA+LfwVUz29MmsZvnf+8gItsCLMViMHHrgRFHq1uhoTs5uhrqxD3DphZnNFhb vx0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=hap6KvJd; 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 p3si10075416pfh.84.2018.03.19.02.02.45; Mon, 19 Mar 2018 02:02:46 -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=hap6KvJd; 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 S932899AbeCSJCm (ORCPT + 28 others); Mon, 19 Mar 2018 05:02:42 -0400 Received: from conuserg-08.nifty.com ([210.131.2.75]:50351 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932805AbeCSJCZ (ORCPT ); Mon, 19 Mar 2018 05:02:25 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id w2J91Vk6014340; Mon, 19 Mar 2018 18:01:32 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com w2J91Vk6014340 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521450092; bh=FMYkrRtcw40ThDSxNw+8i2XtQSBoeeABpm1A0EPSLSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hap6KvJd001Vr17+dQxQuzEGD8fat4ZNm7+WmycoxhkbK7Hv6Dks/IkU/p12xkeQf wZanjoD7TcU8iLXktfn+lhtgiYRRHEV7i36tOB6wS7H6j4qHV1p3QDA2N1GZfQ6lKp 3muY6gd1Qd+IuXpDDxViCVSz9hvW2ffKPY0zqiMFQ1HAdQHEXY+6KwMduquY3rjOPB akRPkS0LXaksAdgu8Fp89e0E8y/sVy6JmFrNIxmgqCyMj4mU5BFTlVmc5IUP2EEvvj bD9oO9SOcSpjXOD41rn4Y+E3X4cIWoPLkurHwrgqCDksgD6MK1mSE2v7pNRg4pZXWC TT9edKmEIxz1Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Cao jin , linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek Subject: [PATCH v2 2/5] kbuild: define KBUILD_MODNAME even if multiple modules share objects Date: Mon, 19 Mar 2018 18:01:24 +0900 Message-Id: <1521450087-27291-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521450087-27291-1-git-send-email-yamada.masahiro@socionext.com> References: <1521450087-27291-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, KBUILD_MODNAME is defined only when $(modname) contains just one word. If an object is shared among multiple modules, undefined KBUILD_MODNAME could cause a build error. For example, if CONFIG_DYNAMIC_DEBUG is enabled, any call of printk() populates .modname, then fails to build due to undefined KBUILD_MODNAME. Take the following code as an example: obj-m += foo.o obj-m += bar.o foo-objs := foo-bar-common.o foo-main.o bar-objs := foo-bar-common.o bar-main.o In this case, there is room for argument what to define for KBUILD_MODNAME when foo-bar-common.o is being compiled. "foo", "bar", or what else? One idea is to define colon-separated modules that share the object, in this case, "bar:foo" (modules are sorted alphabetically by $(sort ...). Signed-off-by: Masahiro Yamada Reviewed-by: Cao jin --- Changes in v2: - Remove comments that will be no longer true scripts/Makefile.lib | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 4eedd6e..7feb960 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -87,13 +87,9 @@ subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) # These flags are needed for modversions and compiling, so we define them here # $(modname_flags) defines KBUILD_MODNAME as the name of the module it will # end up in (or would, if it gets compiled in) -# Note: Files that end up in two or more modules are compiled without the -# KBUILD_MODNAME definition. The reason is that any made-up name would -# differ in different configs. name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) -modname_flags = $(if $(filter 1,$(words $(modname))),\ - -DKBUILD_MODNAME=$(call name-fix,$(modname))) +modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) @@ -174,8 +170,10 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into -modname-multi = $(sort $(foreach m,$(multi-used),\ - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) +# If the object belongs to two or more multi-part objects, all of them are +# concatenated with a colon separator. +modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ + $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))) # Useful for describing the dependency of composite objects # Usage: