Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp302511pxu; Tue, 1 Dec 2020 11:38:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOdhPM1rRWA76EhBBpKzj0jyL5sfayOpD43cRSv8KfjV6P+MPbXVso7rasqYIYhr6Trn7l X-Received: by 2002:a50:e68b:: with SMTP id z11mr4826264edm.25.1606851502358; Tue, 01 Dec 2020 11:38:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606851502; cv=none; d=google.com; s=arc-20160816; b=GVXSYQanSuq98i3RPMawafUe+xPBoLAd7DNIfgnIiDC6z7u1NK7EU4t8RyrHhujES+ Z+0BNr3yswBqM7+sPT1D5kUhs/Lc/GrEAvK9i1OoTNBHUIAnHcx6CVG1O5EgIRz30xNs GvnR31n4f5rTUA6JRHMDSaTRrdOF8FjV13CTc8o+iswoPm0gFCKhbovcGDyim8FH7OJ8 FwF2qIL6vCRqlJNVdYnIcNuGXkAInTrDB3qxZR8FQvpO7gS6UHJBh7cx57RClhS2iE1W uMGrveG7sao+/mV4SpRUWHtDls4vKkKqgJOfrBTyRs0h94MxDn+Lp/Q5aBuQPkfZBfRK PMoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=c1CoK4finTSZO6vcWRJXjfyRV2nI90vuCrlegb32z8I=; b=r0tlarEpOSGamIyLcABQ0GRl33hsgN1HjlouT0fnwdfULLp3THISmkMjXpsTS41qj2 OjamI1rdLy6YbziyOtGpwOaipi4qgjVPs25Z8DHvd7MOgAVi4fDLC2r98dTK4Kmi2Tsr NdyYlj9umEkwNKGnMux2OnDFgRa9mdAaqk1To3u/JFXtsT4zUiNRdDuCsFbyO3VSawf1 bOiQGYDVTLMEIwITFYLEiCs5m/+nX5kpdgOr94296RnHL7QJlrH6/zd/KCZwoGePAey5 3IOSomfNiGyl+fE7N3Pq57je3nT/NhnZMvllyWVpSdqnMslZwof+7uvBQzWYYk784Skk /8OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="IrUm2r/E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si470555edu.535.2020.12.01.11.38.00; Tue, 01 Dec 2020 11:38:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="IrUm2r/E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404260AbgLATd3 (ORCPT + 99 others); Tue, 1 Dec 2020 14:33:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:52884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgLATd3 (ORCPT ); Tue, 1 Dec 2020 14:33:29 -0500 Received: from localhost (searspoint.nvidia.com [216.228.112.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F8E220679; Tue, 1 Dec 2020 19:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606851168; bh=a74wrcvSdNVouX66ceR1u93Jt6L/lg6Baa0mbtbwhN0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IrUm2r/Eami47ViRMKJ4EU634PV4FUp0Q1Lvu3vP1TXFiqxWFs0OcJ7SXMA5dzz+w BwY7vio9ApsRvMQJBgkLxRHixU/wh5H5rz9srfZ99tI76frObamA2fuNgZQPNMfnBu HxmXCzYVuNa2h5ph+EhTu8WIQM42tuCOCAJOu3qc= Date: Tue, 1 Dec 2020 21:32:43 +0200 From: Leon Romanovsky To: Andrii Nakryiko Cc: Masahiro Yamada , Alexei Starovoitov , Andrii Nakryiko , Michal Marek , Linux Kbuild mailing list , open list , Edward Srouji , Saeed Mahameed , bpf , Kernel Team , Networking Subject: Re: [PATCH bpf-next] kbuild: Restore ability to build out-of-tree modules Message-ID: <20201201193243.GG3286@unreal> References: <20201201143700.719828-1-leon@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 10:01:23AM -0800, Andrii Nakryiko wrote: > On Tue, Dec 1, 2020 at 6:37 AM Leon Romanovsky wrote: > > > > From: Leon Romanovsky > > > > The out-of-tree modules are built without vmlinux target and request > > to recompile that target unconditionally causes to the following > > compilation error. > > > > [root@server kernel]# make > > <..> > > make -f ./scripts/Makefile.modpost > > make -f ./scripts/Makefile.modfinal > > make[3]: *** No rule to make target 'vmlinux', needed by '/my_temp/out-of-tree-module/kernel/test.ko'. Stop. > > make[2]: *** [scripts/Makefile.modpost:117: __modpost] Error 2 > > make[1]: *** [Makefile:1703: modules] Error 2 > > make[1]: Leaving directory '/usr/src/kernels/5.10.0-rc5_for_upstream_base_2020_11_29_11_34' > > make: *** [Makefile:80: modules] Error 2 > > > > As a solution separate between build paths that has vmlinux target and paths without. > > > > Fixes: 5f9ae91f7c0d ("kbuild: Build kernel module BTFs if BTF is enabled and pahole supports it") > > Reported-by: Edward Srouji > > Signed-off-by: Leon Romanovsky > > --- > > e732b538f455 ("kbuild: Skip module BTF generation for out-of-tree > external modules") ([0]) was supposed to take care of this. Did you > try it? My tree doesn't have this patch yet, so my questions can be stupid: 1. Will it print "Skipping BTF generation for ... due to unavailability of vmlinux" line if my .config doesn't have "CONFIG_DEBUG_INFO_BTF_MODULES"? I hope it is not. 2. Reliance on existence of vmlinux can be problematic, no one promises us that "make clean" is called before and there are no other leftovers from previous builds. And in general, the idea that such invasive change in build infrastructure came without any Ack from relevant maintainers doesn't look right to me. Thanks > > [0] https://patchwork.kernel.org/project/netdevbpf/patch/20201121070829.2612884-1-andrii@kernel.org/ > > > > Not proficient enough in Makefile, but it fixes the issue. > > --- > > scripts/Makefile.modfinal | 5 +++++ > > scripts/Makefile.modpost | 4 ++++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal > > index 02b892421f7a..8a7d0604e7d0 100644 > > --- a/scripts/Makefile.modfinal > > +++ b/scripts/Makefile.modfinal > > @@ -48,9 +48,14 @@ if_changed_except = $(if $(call newer_prereqs_except,$(2))$(cmd-check), \ > > $(cmd); \ > > printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) > > > > +ifdef MODPOST_VMLINUX > > # Re-generate module BTFs if either module's .ko or vmlinux changed > > $(modules): %.ko: %.o %.mod.o scripts/module.lds vmlinux FORCE > > +$(call if_changed_except,ld_ko_o,vmlinux) > > +else > > +$(modules): %.ko: %.o %.mod.o scripts/module.lds FORCE > > + +$(call if_changed_except,ld_ko_o) > > +endif > > ifdef CONFIG_DEBUG_INFO_BTF_MODULES > > +$(if $(newer-prereqs),$(call cmd,btf_ko)) > > endif > > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost > > index f54b6ac37ac2..f5aa5b422ad7 100644 > > --- a/scripts/Makefile.modpost > > +++ b/scripts/Makefile.modpost > > @@ -114,8 +114,12 @@ targets += $(output-symdump) > > > > __modpost: $(output-symdump) > > ifneq ($(KBUILD_MODPOST_NOFINAL),1) > > +ifdef MODPOST_VMLINUX > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal MODPOST_VMLINUX=1 > > +else > > $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal > > endif > > +endif > > > > PHONY += FORCE > > FORCE: > > -- > > 2.28.0 > >