Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1189499rwb; Wed, 28 Sep 2022 14:41:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54ZxB39M8VGRWtpAufDV/WdUPssUDU/7XTr2ZG7BurHVeH0i0VwfRUN74NpsIcvR+RKaJ+ X-Received: by 2002:a17:90b:2242:b0:200:1c81:c108 with SMTP id hk2-20020a17090b224200b002001c81c108mr27653pjb.89.1664401291530; Wed, 28 Sep 2022 14:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664401291; cv=none; d=google.com; s=arc-20160816; b=hetYnyXywHhpIrJQB70gqJC/RNY2ODV706kPzbnfFIHh8QoPB5cZFGKMTePZWWbpS8 Dwcfab88v0/k5R7cHSynyuJH/wA31Rrj2u+H9nPA/fOmufxJ31Ma+I29UMLdSWC0Rspe CXEyVG6jjBKryx9yJjIdXFdBaYGTFsgkfGHpJdikpUzJATi38zlk4kLLSSo1tNv1bxHB 2i4EeCtz8VCEl3082vj872Hh5ar6lfsfbzxCov4wCPhKBC3UWzJWpUikIAZ8/oCUE34U 9QUu7RxcQ8DKhQEDUMlEBFfgnry27mYrO9yBDXmTy11B/OGG2E4xo9B0Uj21YCfjeSiA ca+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=9up+bTK5BWQ+kwLY4kLOa7NGKSwEXLj5uD5cGziJ5To=; b=F2Y/T6Azvt5QeNMjXP1S7fY+QLM2ZOx2VNjJVYyQbap/b9o0m3aGFiAXs3BFF2+oMH X7lZM4jL5nq85pT16vOERiWUZEJrRS7Fskh3F48FcHChxgEIOz4kfy8r8Lz3bXpAOaka 87QJWvZsN2Qh6+ObnXms+ef2SJuTndMAjO+xM7yaQN/5UBRFS6w1a3bqbBxCqvR6rfHV lbHDRRF6TcJsCPeEbwJLD1/bsJmAFPaW5zgm0+yAXfEDF0uxj7Ojpk/AUSlimu4OHluM dDbYMQPcF6QY/dt+r2GSEGEIRK0E4NTVX6M8ukLxChlzWrxbWci3Npo9AWnCDlHkjTpl r+Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=l3lK4KpE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a170902d4cf00b00177e4c70845si6857232plg.580.2022.09.28.14.41.20; Wed, 28 Sep 2022 14:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=l3lK4KpE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S233194AbiI1VQM (ORCPT + 99 others); Wed, 28 Sep 2022 17:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234388AbiI1VPv (ORCPT ); Wed, 28 Sep 2022 17:15:51 -0400 Received: from condef-01.nifty.com (condef-01.nifty.com [202.248.20.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2A46476D9; Wed, 28 Sep 2022 14:10:33 -0700 (PDT) Received: from conssluserg-02.nifty.com ([10.126.8.81])by condef-01.nifty.com with ESMTP id 28SL6gC7000770; Thu, 29 Sep 2022 06:06:42 +0900 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 28SL5q68001910; Thu, 29 Sep 2022 06:05:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 28SL5q68001910 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1664399153; bh=9up+bTK5BWQ+kwLY4kLOa7NGKSwEXLj5uD5cGziJ5To=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=l3lK4KpEimBu9kNN3NdsTgWZYUiRP6a7evwtiMaAed7gzcGZk1vlv4lwASNgN08ez q+A+DR7SHnqJFBdBj+AJXKhaOB4FHXIOeY82ygyJgElxazdlSVFkQCoqf7XKcgRUPi qUw2gO/lULtJCu7Lj6Ad1PLo1npHKWo42VSVM9f6538MOkFkcn4qn0YqZRrnlJibBb SxoadZyn7VuaEp53OpYL2UK0Gm0z9g8lPr9Cnj/PMx8Gla8T2HHJJ3KkGBCc2GVZCj csKUWv60JDvWXNkeoDYXgUbCaErF0yCzzB1JuAaE7kIP0+/QXo8K53n0Uekyp1AxAe +j48axC9FlBlQ== X-Nifty-SrcIP: [209.85.167.181] Received: by mail-oi1-f181.google.com with SMTP id s125so16797537oie.4; Wed, 28 Sep 2022 14:05:53 -0700 (PDT) X-Gm-Message-State: ACrzQf3Pd69jcEclYFnIXBLan3MmFcH7fIGEkDOZPpEx5ZiUNwuOcOIx E+YfozMARUrgFy6Ttw35d5CW13gcRUTXKQ9P4BA= X-Received: by 2002:a54:400c:0:b0:34f:9913:262 with SMTP id x12-20020a54400c000000b0034f99130262mr5193714oie.287.1664399152276; Wed, 28 Sep 2022 14:05:52 -0700 (PDT) MIME-Version: 1.0 References: <20220924181915.3251186-1-masahiroy@kernel.org> <20220924181915.3251186-6-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Thu, 29 Sep 2022 06:05:15 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 5/7] kbuild: unify two modpost invocations To: Nicolas Schier Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Nick Desaulniers , Nathan Chancellor Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 4:59 AM Nicolas Schier wrote: > > On Sun, 25 Sep 2022 03:19:13 +0900 Masahiro Yamada wrote: > > Currently, modpost is executed twice; first for vmlinux, second > > for modules. > > > > This commit merges them. > > > > Current build flow > > ================== > > > > 1) build obj-y and obj-m objects > > 2) link vmlinux.o > > 3) modpost for vmlinux > > 4) link vmlinux > > 5) modpost for modules > > 6) link modules (*.ko) > > > > The build steps 1) through 6) are serialized, that is, modules are > > built after vmlinux. You do not get benefits of parallel builds when > > scripts/link-vmlinux.sh is being run. > > > > New build flow > > ============== > > > > 1) build obj-y and obj-m objects > > 2) link vmlinux.o > > 3) modpost for vmlinux and modules > > 4a) link vmlinux > > 4b) link modules (*.ko) > > > > In the new build flow, modpost is invoked just once. > > > > vmlinux and modules are built in parallel. One exception is > > CONFIG_DEBUG_INFO_BTF_MODULES=y, where modules depend on vmlinux. > > > > Signed-off-by: Masahiro Yamada > > --- > > > > (no changes since v1) > > > > Makefile | 30 ++++++++++--- > > scripts/Makefile.modfinal | 2 +- > > scripts/Makefile.modpost | 93 ++++++++++++--------------------------- > > scripts/link-vmlinux.sh | 3 -- > > 4 files changed, 53 insertions(+), 75 deletions(-) > > > > diff --git a/Makefile b/Makefile > > index b5dfb54b1993..cf9d7b1d8c14 100644 > > --- a/Makefile > > +++ b/Makefile > > @@ -1152,7 +1152,7 @@ cmd_link-vmlinux = \ > > $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ > > $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) > > > > -vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE > > +vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) modpost FORCE > > +$(call if_changed_dep,link-vmlinux) > > > > targets := vmlinux > > @@ -1428,7 +1428,13 @@ endif > > # Build modules > > # > > > > -modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare > > +# *.ko are usually independent of vmlinux, but CONFIG_DEBUG_INFOBTF_MODULES > > +# is an exception. > > +ifdef CONFIG_DEBUG_INFO_BTF_MODULES > > +modules: vmlinux > > +endif > > + > > +modules: modules_prepare > > > > # Target to prepare building external modules > > modules_prepare: prepare > > @@ -1741,8 +1747,12 @@ ifdef CONFIG_MODULES > > $(MODORDER): $(build-dir) > > @: > > > > -modules: modules_check > > - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost > > +# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. > > +# This is solely useful to speed up test compiles. > > +modules: modpost > > +ifneq ($(KBUILD_MODPOST_NOFINAL),1) > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal > > +endif > > > > PHONY += modules_check > > modules_check: $(MODORDER) > > @@ -1773,6 +1783,11 @@ KBUILD_MODULES := > > > > endif # CONFIG_MODULES > > > > +PHONY += modpost > > +modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ > > + $(if $(KBUILD_MODULES), modules_check) > > + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost > > + > > # Single targets > > # --------------------------------------------------------------------------- > > # To build individual files in subdirectories, you can do like this: > > @@ -1792,16 +1807,19 @@ single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) > > single-no-ko := $(filter-out $(single-ko), $(MAKECMDGOALS)) \ > > $(foreach x, o mod, $(patsubst %.ko, %.$x, $(single-ko))) > > > > -$(single-ko): single_modpost > > +$(single-ko): single_modules > > @: > > $(single-no-ko): $(build-dir) > > @: > > > > # Remove MODORDER when done because it is not the real one. > > PHONY += single_modpost > > PHONY += single_modules Thank you for your close review! I will fix it locally. > > Reviewed-by: Nicolas Schier > -- Best Regards Masahiro Yamada