From 67bda67620c46f7305acff1be67dd7a1c533d447 Mon Sep 17 00:00:00 2001
Message-ID: <67bda67620c46f7305acff1be67dd7a1c533d447.1781662612.git.sam@gentoo.org>
In-Reply-To: <70d8957b93edfae1f58c41c184cd6053d13d3b75.1781662612.git.sam@gentoo.org>
References: <70d8957b93edfae1f58c41c184cd6053d13d3b75.1781662612.git.sam@gentoo.org>
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon, 15 Jun 2026 16:32:40 -0300
Subject: [PATCH 4/6] Makefile: Do not install the container testroot if not
 running tests

Every subdirectory tests target depends on
$(objpfx)testroot.pristine/install.stamp, whose recipe performs a full
DESTDIR installation (about 12s and 154MB on x86_64).  The testroot is
only consumed by the container tests, which do not run when
run-built-tests is no, so skip it entirely in that case.

This saves about 10s on x86_64 [1] and 30s on aarch64 [2].

[1] Ryzen 5900x, 12c/24t, gcc 16.1.1, binutils 2.26, and GNU make 4.3
[2] N1, 80c, gcc 15.1.1, binutils 2.25, GNU make 4.3
---
 Makefile | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Makefile b/Makefile
index 055cd3f46e..8bac760b15 100644
--- a/Makefile
+++ b/Makefile
@@ -764,8 +764,13 @@ else
 LINKS_DSO_PROGRAM = links-dso-program
 endif
 
+# The testroot is only used by the container tests, which are not run
+# when run-built-tests is no; skip the installation entirely in that
+# case.
+ifeq ($(run-built-tests),yes)
 $(tests-container) $(addsuffix /tests,$(subdirs)) : \
 		$(objpfx)testroot.pristine/install.stamp
+endif
 $(objpfx)testroot.pristine/install.stamp :
 	test -d $(objpfx)testroot.pristine || \
 	  mkdir $(objpfx)testroot.pristine
-- 
2.54.0

