Received: by 10.223.164.202 with SMTP id h10csp649525wrb; Fri, 17 Nov 2017 06:32:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMYnyv0QyY5IqI6IRBHQWHdC7cBW5vMyKIN0FH4nZMj5fB907eAkHz54jaeu3N99tSnyyK11 X-Received: by 10.159.216.141 with SMTP id s13mr5330622plp.125.1510929175643; Fri, 17 Nov 2017 06:32:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510929175; cv=none; d=google.com; s=arc-20160816; b=SijE9iy3ONoQZDLKp4uf1j8iR4UjQ44yZ7exn7DR8rCyUPU8WbsuZo2cucB0fw4wMu f1SPcAirLfqQqcND0ZrIl0xNnSfooZ/aW3pbbQvtxEbxOXVmxvyNKZtJW82dmYJwofjE gu73r8kfdkDtUnUS4C6ZMlVMuk/bzc9FfFhraBmErvC+Qsv1R/jXTWi1soJqvffKZqbX On2JFazuW4yTvbmfwZoyOzS+F5N5m/2oLcdZwOOVM7ONDDdmQ/efqImtpevR5bk4fuXq szeYM4/uGPXf83xg/zffYeDrEZtnNAe45fTcnMxRd4Nyz1MWPia0XOBcEYdc3kQdFvdI p3Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=Zk5Da87qZvXv/du9qkR6IaDSELI8fX+/s4e/xZbfgpg=; b=t/uqnb+MKjxI511eDABgK2pGNQ2u9cp1GhirZUfASFR1VwQ4q4zJn1iaVX4R0rCUFJ 9TkhId1Y70Z/87vW/HSL+QVcx160XOBhTsGlbh4XiCbnE8wbHZE3ix8d2/QtVyY+Pifp wYHBn13wizH2KHiKt+o5qOrlvyG64j13WcxnT4k1Zn27fG9Xs2GZuTIisdKKPt1EAWKN MUS+XBG5zBLHT01ao4vn/XZbvETHST3IsyJU0SWgBY+kh7kzyuROYhBNEo1Mj3fXFjbk odyAwE96F407WyPEC0eznHst/9heq/sWVNy9jimwAAvS9ZsnFCLXSazryEGoVfrIvDZY 248g== ARC-Authentication-Results: i=1; mx.google.com; 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 s9si2823213pgr.631.2017.11.17.06.32.42; Fri, 17 Nov 2017 06:32:55 -0800 (PST) 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; 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 S1757204AbdKQHVP (ORCPT + 91 others); Fri, 17 Nov 2017 02:21:15 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:24741 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751599AbdKQHVK (ORCPT ); Fri, 17 Nov 2017 02:21:10 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="30255086" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 17 Nov 2017 15:21:08 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id B8A07480D734; Fri, 17 Nov 2017 15:21:02 +0800 (CST) Received: from [10.167.226.60] (10.167.226.60) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 17 Nov 2017 15:21:03 +0800 Subject: Re: [PATCH] kbuild: define KBUILD_MODNAME even if multiple modules share objects To: Masahiro Yamada , CC: Sam Ravnborg , Michal Marek , Michal Marek , References: <1510818396-17443-1-git-send-email-yamada.masahiro@socionext.com> From: Cao jin Message-ID: <5952fd94-d3a9-620f-2326-74f16fbe029c@cn.fujitsu.com> Date: Fri, 17 Nov 2017 15:20:29 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1510818396-17443-1-git-send-email-yamada.masahiro@socionext.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.226.60] X-yoursite-MailScanner-ID: B8A07480D734.A6257 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/16/2017 03:46 PM, Masahiro Yamada wrote: > Currently, KBUILD_MODNAME is defined only when $(modname) contains > just one word. If an object is shared between multiple modules, > undefined KBUILD_MODNAME causes a build error. > > A simple test case is as follows: > > 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, we do not know what to define for KBUILD_MODNAME when > compiling foo-bar-common.o ("foo" or "bar" ?), so one reasonable > solution is let it fall back to $(basetarget) (= "foo-bar-common"). > > It would be better to avoid such a design where possible, but we > already have such a case, for example, > drivers/net/ethernet/cavium/liquidio/Makefile > > I slightly refactored implementation; we can check $(word 2, $(modname)) > instead of $(filter 1,$(words $(modname))). > > Signed-off-by: Masahiro Yamada > --- > > scripts/Makefile.lib | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index 5fbc46d..9f9a7df 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -86,8 +86,7 @@ subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) > # 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,$(if $(word 2,$(modname)),$(basetarget),$(modname))) > > orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ > $(ccflags-y) $(CFLAGS_$(basetarget).o) > I like this style of the refactor, because it is a bit more readable according to human mind,  and it also behave the same as before in the case drivers/net/ethernet/cavium/liquidio/Makefile: modname = $(basetarget). So: Tested-by: Cao jin Reviewed-by: Cao jin -- Sincerely, Cao jin From 1584208143843177959@xxx Thu Nov 16 07:50:18 +0000 2017 X-GM-THRID: 1584208143843177959 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread