Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2575633ybe; Thu, 12 Sep 2019 11:31:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzecnVvGSOAZVxyTwDZJalfroWpWNir+895QQEamBc+f5L/C+VfA9EWw/tlQS3UF0Db9/0q X-Received: by 2002:a50:886d:: with SMTP id c42mr41219459edc.24.1568313073373; Thu, 12 Sep 2019 11:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568313073; cv=none; d=google.com; s=arc-20160816; b=HKo4mCWAqcwM0g+/Q+GZOjM/fdyecJvShIXsnm8LErAH19nbc3ViDzUeCm5zLCPogg Z0Ab6MtPjGJ8/gUbSkK57mmmcEsv7gYGehq478EA1zJOC48sVpeMi6jzGoxCwYMsAeH5 v0G4qR2LfNa86/QVPQm4Z2KHA0OYzlvrPXr2YQOILa2XbNUMQlNp32ArGpdWeD+htWhT vjg4ZBgk1w9QOA5Ar3rqNvJrqXztXW2f8dUywvEbKe/NKgVZQZJpkkIo1gNXOI/n2NXe 640M+p8aM33bFb1bi+oUEPYJa+jn8VgF2iqJOE2+/6MNT0V33N221enkb9Bs7twdafxL 5KmA== 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; bh=ODIkurWAfHrOiVaGlkYrz/KE7y0sW22uQuzTjixHoH8=; b=MwI3kr/bPBZi/J6t+XZUbvIPRNnJDHK5veUb6u+bY7wrsF171tYTkAIZsYjlUWlb1m MDPRihGmlNn91NFEefT2J281AqehaqBCvO9f+XiCGA1zMoIjPyNWde+Ml9aZZZgT09iv 5x1lbLticD43Bz8C0pYRp2M3hwC6gdxuaD74Q801iBemd7NwMew1+HYA7pASHZ6P250F 1c5KzsX/t3fitvcWV3lbANAfYGnq7nUfSsvYbpGmw4Gwx9i2s/PnmAnvwGLozqU1Mnkq tTkBvVrQx/3r+/GmatHL/gL1IheZjvUi3oxlr7fu1czczFx4C3u8tnkuKlOmg06/4kSm MFTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Ccvw0IiV; 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 f43si17156017edf.422.2019.09.12.11.30.49; Thu, 12 Sep 2019 11:31:13 -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=Ccvw0IiV; 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 S1733180AbfILQXK (ORCPT + 99 others); Thu, 12 Sep 2019 12:23:10 -0400 Received: from conuserg-07.nifty.com ([210.131.2.74]:42383 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730132AbfILQXJ (ORCPT ); Thu, 12 Sep 2019 12:23:09 -0400 Received: from grover.flets-west.jp (softbank126125143222.bbtec.net [126.125.143.222]) (authenticated) by conuserg-07.nifty.com with ESMTP id x8CGMu1b021030; Fri, 13 Sep 2019 01:22:57 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com x8CGMu1b021030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1568305377; bh=ODIkurWAfHrOiVaGlkYrz/KE7y0sW22uQuzTjixHoH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ccvw0IiV5YLTG5lkl7gvdD9ne+M3KJmq27iAmX6sFJ2q5bNgwy/iN48SwURh9Wrmr qrTMWCM4CnFJY/rM7iAPE+y+/riADB6fBeCvgED9NOrfPO0uymNHaqeUjkf0/G+o60 9HnU2Hhvkl18tu9boSA7o0xKBktXDXnQcdyIcXx7NDNMJ9nUfniPCAz1IHJ4CYs+vb ft+H2Dfv/c5pl+gnaep5Fk7VQCcTdsqfdH75q/In2PIjY78X0Meu5MXEa2/xN2xB6M 7ruAy1VSYuo/PEIuQ/LnfA/4Rpt0pL/mML9m1YXoRj0TWMQsF1Zq8H7qdWVSr/qmuG CmlvJwC+hUoHQ== X-Nifty-SrcIP: [126.125.143.222] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Michal Marek , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] kbuild: warn orphan built-in objects Date: Fri, 13 Sep 2019 01:22:52 +0900 Message-Id: <20190912162254.9603-2-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190912162254.9603-1-yamada.masahiro@socionext.com> References: <20190912162254.9603-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org obj-y specifies objects linked into vmlinux, but they are actually linked if and only if that sub-directory is visited by the chain of obj-y. If you have an orphan obj-y object, it is a bug, but may not be easy to notice. This commit provides build-time warning. I tested x86 allmodconfig based on v5.3-rc4, and I saw one warning: warning: 'sound/soc/sprd/sprd-mcdt.o' will not be linked to vmlinux even though obj-y is specified. This is a proper warning. sound/soc/sprd/sprd-mcdt.o is compiled as built-in since CONFIG_SND_SOC_SPRD_MCDT is boolean. However, CONFIG_SND and CONFIG_SND_SOC are tristate, and set to m by allmodconfig. So, Kbuild descends into sound/soc/, then sound/soc/sprd/ by obj-m. Thus, sound/soc/sprd/sprd-mcdt.o is not linked to vmlinux. More warnings for arm allmodconfig, all of which are valid: warning: 'drivers/video/fbdev/mmp/hw/mmp_ctrl.o' 'drivers/video/fbdev/mmp/hw/mmp_spi.o' will not be linked to vmlinux even though obj-y is specified. warning: 'drivers/video/fbdev/mmp/panel/tpo_tj032md01bw.o' will not be linked to vmlinux even though obj-y is specified. warning: 'sound/soc/pxa/mmp-pcm.o' will not be linked to vmlinux even though obj-y is specified. Signed-off-by: Masahiro Yamada --- Changes in v2: - fix false-positive warning for arm64 scripts/Makefile.build | 12 ++++++++---- scripts/link-vmlinux.sh | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 6c3e6cb0c0af..fb29c898604a 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -52,6 +52,10 @@ ifndef obj $(warning kbuild: Makefile.build is included improperly) endif +PHONY += __warn-orphan-obj-y +__warn-orphan-obj-y: + @echo "warning: $(patsubst %,'%',$(real-obj-y)) will not be linked to vmlinux even though obj-y is specified." >&2 + ifeq ($(need-modorder),) ifneq ($(obj-m),) $(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.) @@ -68,6 +72,8 @@ endif ifdef need-builtin builtin-target := $(obj)/built-in.a +else ifneq ($(real-obj-y),) +builtin-target := __warn-orphan-obj-y endif ifeq ($(CONFIG_MODULES)$(need-modorder),y1) @@ -386,16 +392,14 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ; # # Rule to compile a set of .o files into one .a file (without symbol table) # -ifdef builtin-target quiet_cmd_ar_builtin = AR $@ cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) -$(builtin-target): $(real-obj-y) FORCE +$(obj)/built-in.a: $(real-obj-y) FORCE $(call if_changed,ar_builtin) -targets += $(builtin-target) -endif # builtin-target +targets += $(obj)/built-in.a # # Rule to create modules.order file diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 2438a9faf3f1..8961d999b86b 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -216,7 +216,7 @@ else fi; # final build of init/ -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1 #link vmlinux.o info LD vmlinux.o -- 2.17.1