Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp376134iob; Wed, 11 May 2022 16:56:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzz3O2LbgP3mBFSt3bDjgJhLPAYSB4Mfz0UNOw8v6HUE0LFkzG5HvzAURLaVWzMzn0tC00t X-Received: by 2002:a17:906:3099:b0:6f3:e8e1:87cd with SMTP id 25-20020a170906309900b006f3e8e187cdmr27105808ejv.290.1652313379114; Wed, 11 May 2022 16:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652313379; cv=none; d=google.com; s=arc-20160816; b=f9R0gGXq4Csu0bxgbJSf6jT5+ClrFLTCx5t33tFyIAQ3UPcAUlxx9r2rYzWrwEfyLt hVYuxQ+pfStlH5aKxNoNCukrBIAu3JujkPfNHISws+26A9vyXrgzG3A3w8yIA21kvXLA Jbx5cGvx8qyJ4080rnz/1gDo2rrCIaEmkP8lpf2BZ+NwURxAOLN8uHhl8CVIB/qIDp2D TedNENpwGlbL4e7oUdcChU0vlAZ4nUOJhh+JMMiZMDfaPDJSPWNG7oUWpSJqgcP6n4o4 p/lZ9MsjyAmLkl2c6xF0eRZfs/EqrFeXz7CEAPu+FTf80MhB4yuoTqxJrUVPMA4R3MTk XbTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=tcr+72ZYpbdDhhd7b5O3qNkSWb92WQKtLNqtDxevyAs=; b=b/ZUVmvok8gwMz+HLO2TqXZCJMcDi4vhsn21liu1PjJbPOxXaO4xRzWNMxIaQXj4p4 nCAFZBj0P6/Z0btKx7nKga26O1P8jmrWG+rMs+XO1jz1PCE6R43h1yFVGwrGEiACbV0U 0mvrPyD75rcm57r8aHVEo4BkS5Zoq9XNwp2Vir7GRuv06jysI3CrnQ+SF+ykCzll+amr g8S2dvwZmwLmUMfUmwIVTg3LsnnZLA4YNxhHWbntonz9i5Fa2yDlbksJ9NQtqROYUyec BbfQspnW195MtAkDds6jlbj9uNra3Hfv+7L97WhQPlW/E4ieB0RpPgQcRzmU9Mx+1v5c 3jew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=1xN57X9s; 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 gv43-20020a1709072beb00b006e8c6d60ee5si4466271ejc.13.2022.05.11.16.55.50; Wed, 11 May 2022 16:56:19 -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=1xN57X9s; 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 S1345075AbiEKQuE (ORCPT + 99 others); Wed, 11 May 2022 12:50:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345026AbiEKQtq (ORCPT ); Wed, 11 May 2022 12:49:46 -0400 Received: from conuserg-08.nifty.com (conuserg-08.nifty.com [210.131.2.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A06195DD9; Wed, 11 May 2022 09:49:41 -0700 (PDT) Received: from grover.jp (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-08.nifty.com with ESMTP id 24BGlWc4031975; Thu, 12 May 2022 01:47:41 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com 24BGlWc4031975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1652287662; bh=tcr+72ZYpbdDhhd7b5O3qNkSWb92WQKtLNqtDxevyAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1xN57X9s6ScLJ/Z2hb1pNWWGLy1nt5xrcw/SRTDzpwMQbvnE8A08WHb1tRL2DBKCO +pXkDzpxbY81fwxbG0a4ZZkdXAogExaeNGygVj8OuLcQNuJ7AiRunzbNiBtIc7spg1 8+kVanlYtmiRWoi0IcsTtPqIxwux0W9L6x/FwUyQ60BvJ379AzCT3xh3/e9TxPIp5S Pc8nBrjlOMjG0duMJdm6spy738mTTr+f+FFcKcDaOyjaayqqqYRWWVZ0bHOrh9LfyX sMYGko/4vxzWoqMu0AiEUGkSvhzF7286ufk7BC0AMXMVPovVKTcm1HkwUoJrVQMncw 9gXlUynDCRMKg== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Peter Zijlstra , linux-modules@vger.kernel.org, llvm@lists.linux.dev, Ard Biesheuvel , Sami Tolvanen , Masahiro Yamada Subject: [PATCH v5 09/12] kbuild: make built-in.a rule robust against too long argument error Date: Thu, 12 May 2022 01:45:11 +0900 Message-Id: <20220511164514.2741934-10-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220511164514.2741934-1-masahiroy@kernel.org> References: <20220511164514.2741934-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Kbuild runs at the top of objtree instead of changing the working directory to subdirectories. I think this design is nice overall but some commands have a scalability issue. The build command of built-in.a is one of them whose length scales with: O(D * N) Here, D is the length of the directory path (i.e. $(obj)/ prefix), N is the number of objects in the Makefile, O() is the big O notation. The deeper directory the Makefile directory is located, the more easily it will hit the too long argument error. We can make it better. Trim the $(obj)/ by Make's builtin function, and restore it by a shell command (sed). With this, the command length scales with: O(D + N) In-tree modules still have some room to the limit (ARG_MAX=2097152), but this is more future-proof for big modules in a deep directory. For example, you can build i915 as builtin (CONFIG_DRM_I915=y) and compare drivers/gpu/drm/i915/.built-in.a.cmd with/without this commit. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Tested-by: Nathan Chancellor --- (no changes since v2) Changes in v2: - New patch scripts/Makefile.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c2a173b3fd60..8f1a355df7aa 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -374,7 +374,10 @@ $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ; # quiet_cmd_ar_builtin = AR $@ - cmd_ar_builtin = rm -f $@; $(AR) cDPrST $@ $(real-prereqs) + cmd_ar_builtin = rm -f $@; \ + echo $(patsubst $(obj)/%,%,$(real-prereqs)) | \ + sed -E 's:([^ ]+):$(obj)/\1:g' | \ + xargs $(AR) cDPrST $@ $(obj)/built-in.a: $(real-obj-y) FORCE $(call if_changed,ar_builtin) -- 2.32.0