From patchwork Thu Nov 16 07:46:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 119021 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5278073qgn; Wed, 15 Nov 2017 23:48:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMbH8vtbQXFV2IZ/uMZu9GsgXXw+ab10NUt9NBQ97d+E3XIRNtGPdtTEERukVoANVF+27W2q X-Received: by 10.159.241.1 with SMTP id q1mr828806plr.383.1510818534944; Wed, 15 Nov 2017 23:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510818534; cv=none; d=google.com; s=arc-20160816; b=Pvk7BoxhCe1Y42q8325xWDS4sB5EtY89Nk4eoq51Sot7cf00uLA5TGpHuMx5AKBJIY FkTM3ieP5cTAl6CRlWF9rhDsLHdaUXLl6b4JOLo84XIRGfV8Nx601bCovbX3Hff3zD78 CwJMCocbqhAZSIWtXOcVy6GtgXQcNtnwBr6uJJBquMgF0qjvxP8KQGbX/Bm2xfg0xnF4 hnP7ZWu9Gb/YkqH+inJjXgP8FfeKGgfe6j+SCHbRY45kFFviDEqrEa05iKk96IYud5Ws +OwCQi2hrcdmFWzaqdZVqSvFF6GwaNa1C/NQ2AmJBbs/khTaEvjWyi3oEZdvBQFtUyQr 6lTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=946oera2CwSCjMd06g9WkzN6GxdWzyddIv9Hht8c13s=; b=PvGOKuc7pGfpTU5FiXEguPq7vyjlf6WZKSJNVc8O2xjGuo5RUaEoiwDhpeDjD9cGwo XVX66duue2WWoNMhnpW9kZ/j4Q++HWrLVB7Jns+mz3Zy0oalGrU2bdmi/5MzlgWhcRiC 33AurSkOcJdVIO5kf1nHChVq1e2iU9LrW+Bum4Puc/0GjfX3Hcn5ydIS1hVuTprr4i8c pcCEainlpnCsXr7dCTerSNupgH0eOz9uOQHd0gwtj7DqWYIg3cTcdplr+XZ+IXBgR0sB AJzGEmfYbhqgK2n1/e5WsFKO9DRp9hIqWmlYV7IrhIzkUdymBZRYPMHQ8GvzCY62bw7Z xbfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=2TsOuB/3; 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 n15si487317pfj.278.2017.11.15.23.48.54; Wed, 15 Nov 2017 23:48:54 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=2TsOuB/3; 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 S933624AbdKPHsw (ORCPT + 28 others); Thu, 16 Nov 2017 02:48:52 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:37479 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933477AbdKPHsa (ORCPT ); Thu, 16 Nov 2017 02:48:30 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id vAG7kgbr014686; Thu, 16 Nov 2017 16:46:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com vAG7kgbr014686 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510818403; bh=946oera2CwSCjMd06g9WkzN6GxdWzyddIv9Hht8c13s=; h=From:To:Cc:Subject:Date:From; b=2TsOuB/3ARxw+VaTwAGcHxN9gvb8DL/gztSkOEfZsgT1pMEQVZVWCY+RzXEQy4gsD yXqCoqdfGY83DoE8OuBxq9V9vSLFvEC7DA2tksZ5sNkAbKIUpD65FArPL76mKDO1Z6 fRy+33IJGwaC4+awje7bGxGOY67dZDXEJJBLMnuYI9QwGsrjJRh6rtprZUEumJGgqZ i1DhYJNZP8wn2C2S7ABsr2nH6XcSErvXpIYeldBnmXrCcFN4YhEXk1+YhlmdzYbDmr fMv2wj7eWBzSg7ZuEEkQEx13jXnq8qvz63BGa62zhBFqLl8tEGvvyDVTBy6I9leL3F GuZMU1ebnfI/w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Cao jin , Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: define KBUILD_MODNAME even if multiple modules share objects Date: Thu, 16 Nov 2017 16:46:36 +0900 Message-Id: <1510818396-17443-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 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 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(-) -- 2.7.4 Tested-by: Cao jin Reviewed-by: Cao jin 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)