Received: by 10.223.185.116 with SMTP id b49csp5712859wrg; Wed, 7 Mar 2018 17:08:21 -0800 (PST) X-Google-Smtp-Source: AG47ELtYc3JgjomgBMxl0J7fyzBrXxhJKB+n3p/xvkW0IWe7g5DvMuI+7+GVh9A856P0kfUfApr0 X-Received: by 2002:a17:902:7e0d:: with SMTP id b13-v6mr22039443plm.97.1520471301431; Wed, 07 Mar 2018 17:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520471301; cv=none; d=google.com; s=arc-20160816; b=LbZIPrzi2sMG3e+J08LCHHF7SfktiOTvnbg/Iq/qiE2GPr9JhD0dpU3en9v+dwDECj aIdAG024G3hCWG8xd2iEET3kprHYs0xr4rZ20G5EdOmu+yrESbmabIS7KBrfhqx1NrdJ IQHa76gjKWCwlmhXUFXm0+b+obkbWn3KxBeAggjI4eMdXPfVc731iuzcZOJrMYWH6/2l 7JuXeIbL6Ey4MHXK9xIEzCfgBduxI9zmzsFT/2s7fTYqhWeGBxGgU2e5PHERy4+H/QwW ITDIUII7oEaB3e5WVq858aypeWuwNrNRhiqG+DXqGtfyEXqn6M085hGNJTuPKN/ZB1M2 otyg== 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=Jsb1NMYl/ZZ8jZ+KDutdlTHhYY1QzUJyUSaJT6thqJw=; b=g+GOQIslZL2JYcRmSU4s5wSie0N31WaBS+yNuwkUesZEmdAmyD0y50VdA1pt0zO1ah FvHYF7YAvfXUb+XmksetXU55f8pE9GbzM1pFNAAqbrtKqigJpY2M7uUVRTzOV8EYdL7l u1oCb+1fgyZua/Is1eHyxtPg3eJOWDbxM1GYVOo60/7954a/Z+BG/zRvliCyVAkNhDvy EqCmOc5cMMwe4l8CTEX3DQSX59NnjvvDDIbMvFFw3CjZH18pK9VJ40bK2WnqxWTxXKHH oghiqmCSaMY6O2K32aBOAO1NK2WQkqXiRe/6XZvq45hzMFSPryaimEslDQDDygecQ8yJ 4baw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=hN5r3QPM; 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 a18-v6si13782373plm.773.2018.03.07.17.08.06; Wed, 07 Mar 2018 17:08:21 -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=hN5r3QPM; 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 S1755229AbeCHBGi (ORCPT + 99 others); Wed, 7 Mar 2018 20:06:38 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:60400 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755042AbeCHBF4 (ORCPT ); Wed, 7 Mar 2018 20:05:56 -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 w28156G7018694; Thu, 8 Mar 2018 10:05:08 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w28156G7018694 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1520471109; bh=Jsb1NMYl/ZZ8jZ+KDutdlTHhYY1QzUJyUSaJT6thqJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hN5r3QPM2zRt/JTrp6PhPrdz6b+YPOypq2Vf/0fMjWmC1RC802ERXX2IRySvy0zVp 7R0Lo9TA/y5A3PeKVtCJPuJoS6x3KgtlBsSgQRNiJoSB2xi2mjUxSp6JzgjSJ2Cx6P WF8n2xN+/l6AD+s5cGMOGw9X6iJgPye69BE1lGAhjTFrjxxrFqxP70s/TsBQJ1U2JV HTzgw5oRL3BBs5MMM3DyN1I69z4qoS8PcxFb6r1cjiGsbBH+TqJB8UwsoQYU6faaRK 4OFMfFX+4bFhamHHthnYAuIQ2Mi7g0AKl+zYAv+xaY6wIKziOE3UD07uNteafED6Kt RV/SXI/+r5/rw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Cao jin , Govind Singh , Kalle Valo , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/5] kbuild: define KBUILD_MODNAME even if multiple modules share objects Date: Thu, 8 Mar 2018 10:05:00 +0900 Message-Id: <1520471103-10089-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520471103-10089-1-git-send-email-yamada.masahiro@socionext.com> References: <1520471103-10089-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 --- scripts/Makefile.lib | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index a7e315f..a1fbd6a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -92,8 +92,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,$(modname)) orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) @@ -174,8 +173,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: -- 2.7.4