From patchwork Thu Mar 8 01:05:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 130929 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp5855113lja; Wed, 7 Mar 2018 17:06:44 -0800 (PST) X-Google-Smtp-Source: AG47ELsHATYxF+lHBu7XWiYEI2fg+oo2v6rpz/guSgqfKOjrbErmnZHeFYjEHoZld65GuUGKScva X-Received: by 10.99.96.18 with SMTP id u18mr20194417pgb.124.1520471204150; Wed, 07 Mar 2018 17:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520471204; cv=none; d=google.com; s=arc-20160816; b=JOEtx7hQ8Q64ynJJxWoHPkPPdoS1NNFNjTg/eQHk7GkHHlgbXYJHjlJb4slfLVpSKZ ItBr/iJ5CstCCVN5eUR/ho2//anTJdjy5b4feT+OifLVhyADKoDmAZIk1nyOlchcoRbS 7j0znnWKZF87hAypLxpbFCDX4ejtaeqIhUPNJe12nJOxJSYLNQVJAlKu7ePl6OuI0bWm IGuwT8njZ6rvp/REM6VB96lNosOHmma3L6KQtejx0JjpHazLTD5ZmAZvuJrzSy0yiYsV QTGHuhwsMsqds+QW/eNGTurcgbVZ6HjaUtPgsiQh7aHDcnU955UQo+K8IefbzDsioDeQ tFLg== 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 k11-v6si13624305pls.58.2018.03.07.17.06.43; Wed, 07 Mar 2018 17:06:44 -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 S1755234AbeCHBGi (ORCPT + 28 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(-) -- 2.7.4 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: