Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp280785pxb; Thu, 7 Apr 2022 05:37:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyigCj6b7nC63TSbLl3FQ+VvlvqNAR7YkcM1Ai9PZxj8pVwKuKZlJxO89aRFI/VuXW+FYP6 X-Received: by 2002:a17:907:72d6:b0:6df:8b52:bb50 with SMTP id du22-20020a17090772d600b006df8b52bb50mr13128252ejc.254.1649335034015; Thu, 07 Apr 2022 05:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649335034; cv=none; d=google.com; s=arc-20160816; b=ZaDFAZWSNiY33D34PWWAqlDwvCJ3FlMUxvL9oXWXRhwvXfp8y9nm4ACL0UlNaRxovN TMcouPUckytNmFS6m3EdrSRohqbBq+HY360VSyOrNZOdKn8UQR0s8aJRbL5YYBzj1sMq 70s6+sBqo2C4sc69yB5Zzykgg7ixoQQwMQivR0Iom5mQw6eH7U2ys8A6ZgEh4jEZeKSq G9yLloGF+gt+B4kbBnzcSCYmvKfNhP7V/17zbkErE0xH/IbZWDrd1oqnAfgsurTwtrxm 2dwisbesRVJnS4xRnF/jg7q2ZDrxQQ1CsMYYKg4Ozm+eRsS2FCGnJ/ipiRlSQa0TUawY 5ehQ== 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=lz12cTiaDiO+TL8jlSZOZjXEzJZWXC8B9X7PhEBLIlA=; b=SXducrSiVu/o0/FmQn//h4RTlhP0e02kSsJrfbbhZbvJ6NNeA7+JCpzlJ5e5Qtzr9J BMkBvarBBevQB1/fpsXUgiDM14TOTUlzJMQoMZLPb6Ed5QgpF6Q4yfru9Wf+UIvtmhRh +lsGJ9Ez7KR7wezBR4lBtLDq5rYiWLMd1eCA51XuuX6LrleGTV76rsbGWN26TI7mDry2 jLCx+TwT5PZ9ofhdDFUnTSHFW5n5gm3pTVrQyqj2UvliWHDaRD2jPkUg5G+EoFxWYyEw J/pOVp6cVpYY1lQG2aw2YVoIS037RvOMh1y14oel+DBH4NJRG/DSzHYTdWJOaoDYjWWw u9+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=GNfTfySC; 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 v11-20020a1709062f0b00b006df76385e8asi13853167eji.810.2022.04.07.05.36.48; Thu, 07 Apr 2022 05:37:14 -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=GNfTfySC; 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 S239707AbiDGDLY (ORCPT + 99 others); Wed, 6 Apr 2022 23:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239823AbiDGDLR (ORCPT ); Wed, 6 Apr 2022 23:11:17 -0400 Received: from conssluserg-04.nifty.com (conssluserg-04.nifty.com [210.131.2.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D173D21A0DB; Wed, 6 Apr 2022 20:08:46 -0700 (PDT) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 23738PKt004818; Thu, 7 Apr 2022 12:08:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 23738PKt004818 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1649300905; bh=lz12cTiaDiO+TL8jlSZOZjXEzJZWXC8B9X7PhEBLIlA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GNfTfySCJG4XngQ3SggY+S2KlsuVAu7ItuQwAE5SoPrOWgwAG2wO7O4A7tN6Wv0BU h7hlBues3HGCt6N/vmCJJrVgFbCas5ZzxHK43tah4c7hZOWsoGRTd4buwp2W+JguEn /UKWsIuGt/NJbN1Ov2Sbnbx8MbjKDRgUAbTrmxdHgahksxS30f0sYdYhmNRBjYS+/C jLV7ILFMxriRXZvNNSwLC7n7qo++rnsmNIa4w6pjhdPJqGjsNkixkyMi4O4/IQqpBb r06m0cKuqoHfdh+OMCFEP7my3FlqCcUIA6EeUf2LeDZIoqnJBfTMcAsshxObPmaC/8 PpjVSlpV2s/uw== X-Nifty-SrcIP: [209.85.216.41] Received: by mail-pj1-f41.google.com with SMTP id n6-20020a17090a670600b001caa71a9c4aso4888666pjj.1; Wed, 06 Apr 2022 20:08:25 -0700 (PDT) X-Gm-Message-State: AOAM530wXYeg46U0lxZ5GuoQU+3TMwydDurQAGqGaGiK5KLWD8km2eue ECgeSaoBBJLVu+fzKy7XUGaFFayH5Oo8edJEZcY= X-Received: by 2002:a17:902:b183:b0:14f:c266:20d5 with SMTP id s3-20020a170902b18300b0014fc26620d5mr11858079plr.136.1649300904628; Wed, 06 Apr 2022 20:08:24 -0700 (PDT) MIME-Version: 1.0 References: <20220406153023.500847-1-masahiroy@kernel.org> <20220406153023.500847-8-masahiroy@kernel.org> <960102bb-2944-4be0-ab09-7cd2eb0c2cf9@quicinc.com> In-Reply-To: <960102bb-2944-4be0-ab09-7cd2eb0c2cf9@quicinc.com> From: Masahiro Yamada Date: Thu, 7 Apr 2022 12:07:34 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 7/7] kbuild: read *.mod to get objects passed to $(LD) or $(AR) To: Jeff Johnson Cc: Linux Kbuild mailing list , Linux Kernel Mailing List , Michal Marek , Nick Desaulniers 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, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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, Apr 7, 2022 at 3:13 AM Jeff Johnson wrote: > > On 4/6/2022 8:30 AM, Masahiro Yamada wrote: > > ld and ar support @file, which command-line options are read from. > > > > Now that *.mod lists the member objects in the correct order, without > > duplication, it is ready to be passed to ld and ar. > > > > By using the @file syntax, people will not be worried about the pitfall > > described in the NOTE. > > > > Signed-off-by: Masahiro Yamada > > --- > > > > scripts/Makefile.build | 10 +++------- > > 1 file changed, 3 insertions(+), 7 deletions(-) > > > > diff --git a/scripts/Makefile.build b/scripts/Makefile.build > > index 3da731cf6978..f6a506318795 100644 > > --- a/scripts/Makefile.build > > +++ b/scripts/Makefile.build > > @@ -450,22 +450,18 @@ quiet_cmd_ar_lib = AR $@ > > $(obj)/lib.a: $(lib-y) FORCE > > $(call if_changed,ar_lib) > > > > -# NOTE: > > -# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object > > -# module is turned into a multi object module, $^ will contain header file > > -# dependencies recorded in the .*.cmd file. > > ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),) > > quiet_cmd_link_multi-m = AR [M] $@ > > cmd_link_multi-m = \ > > $(cmd_update_lto_symversions); \ > > rm -f $@; \ > > - $(AR) cDPrsT $@ $(filter %.o,$^) > > + $(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@) > > else > > quiet_cmd_link_multi-m = LD [M] $@ > > - cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) > > + cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) > > endif > > > > -$(multi-obj-m): FORCE > > +$(multi-obj-m): %.o: %.mod FORCE > > $(call if_changed,link_multi-m) > > $(call multi_depend, $(multi-obj-m), .o, -objs -y -m) > > > > Looks like this also addresses the out-of-tree issue described in > > > :) > > /jeff But, not perfectly. This patch fixed the linker part, but the same issue is remaining in cmd_mod. The following patch is an easy fix-up. diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f6a506318795..468f9e646370 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -303,8 +303,8 @@ $(obj)/%.prelink.o: $(obj)/%.o FORCE $(call if_changed,cc_prelink_modules) endif -cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) | \ - $(AWK) -v RS='( |\n)' '!x[$$0]++' > $@ +cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \ + $(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ $(obj)/%.mod: FORCE $(call if_changed,mod) But, please do not submit a patch yet. This patch series is just preparation for yet another bigger clean-up. One of my big goals is to clean up Clang LTO builds. Clang LTO made Kbuild really ugly. I am re-implementing various parts, but I have not completed the work yet. Meanwhile, I incrementally submit prerequisite refactoring patches. The issues of external module builds _might_ be fixed as a side-effect of other refactoring, but I am more interested in what the final code will look like. -- Best Regards Masahiro Yamada