From patchwork Thu May 5 07:22:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 1626753 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=B+r/E+5a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kv57F2s0dz9s2R for ; Thu, 5 May 2022 17:34:33 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Kv57F1QHMz3fNM for ; Thu, 5 May 2022 17:34:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=B+r/E+5a; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kernel.org (client-ip=210.131.2.79; helo=conuserg-12.nifty.com; envelope-from=masahiroy@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.a=rsa-sha256 header.s=dec2015msa header.b=B+r/E+5a; dkim-atps=neutral Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Kv4wp4YjRz3c7f for ; Thu, 5 May 2022 17:25:30 +1000 (AEST) Received: from grover.sesame (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-12.nifty.com with ESMTP id 2457Nenw019426; Thu, 5 May 2022 16:23:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com 2457Nenw019426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1651735437; bh=xE0zb58nWCbd4r50BnRJTvTiW15HyULrsFF3iZrvMeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+r/E+5aY2J1v1nIavEEf+kQi0g3HQwxBGWI1Y8L7Ku513rz2PBE0V88DpxH4ZH0i yBjE/9UE+sG2EQQ+f4CZzTQjHAuIRFEzd59wKFq4+LiwTFnCQu4d7aRkVMSVlHYQAZ QKazYDJHYXPO7cLgb1OHgCsOSs1EQHS1NEj4oJ1o6IasaqaHw9+3pQPWAsQlyTbSwP nDIMVpBvqyZdDv+yU7B0oMa6rqJtrPvygvC3tNzMmw0ozxeRSwvcOawdFFbV0sqpG3 GBwSrJxJdu7o+jVAWrYYwEjayv+5CkO+qddYY5SPiDmXl6JBgee4tRIRQb+oHfiIa4 hfajBXYt5RAqw== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Subject: [PATCH v3 14/15] kbuild: make built-in.a rule robust against too long argument error Date: Thu, 5 May 2022 16:22:43 +0900 Message-Id: <20220505072244.1155033-15-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220505072244.1155033-1-masahiroy@kernel.org> References: <20220505072244.1155033-1-masahiroy@kernel.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, Nicolas Schier a , Peter Zijlstra , Nick Desaulniers , Masahiro Yamada , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Luis Chamberlain , Sami Tolvanen , linuxppc-dev@lists.ozlabs.org, Ard Biesheuvel , Kees Cook Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 scapability 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 --- (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 0436ff94800e..cea48762299c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -370,7 +370,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)