[glibc] Makerules: run test-container helper through the built loader

Adhemerval Zanella via Glibc-cvs <[email protected]> Fri, 3 Jul 2026 23:34:25 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1ab000387207a968f7cd18a5f3e3e7dcdadad139

commit 1ab000387207a968f7cd18a5f3e3e7dcdadad139
Author: Adhemerval Zanella <[email protected]>
Date:   Wed Jul 1 10:40:04 2026 -0300

    Makerules: run test-container helper through the built loader
    
    The tests-container rule launches support/test-container, which is always
    dynamically linked, through $(test-via-rtld-prefix).  That prefix is empty
    for tests listed in tests-static/xtests-static, so for a static container
    test the helper ran under the system loader/libc instead of the newly
    built one.
    
    Reviewed-by: Florian Weimer <[email protected]>

Diff:
---
 Makeconfig | 9 +++++++++
 Rules      | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Makeconfig b/Makeconfig
index 6cd590cf21..e7dbd9fb9e 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -823,8 +823,15 @@ $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
 run-via-rtld-prefix =							      \
   $(if $(strip $(filter $(notdir $(built-program-file)),		      \
 			$(tests-static) $(xtests-static))),, $(rtld-prefix))
+# $(container-via-rtld-prefix) is like $(run-via-rtld-prefix), but for the
+# support/test-container helper, which is always dynamically linked even
+# when the test it launches is static.  It must therefore always run
+# through the newly built loader, unlike $(run-via-rtld-prefix) which is
+# empty for tests listed in tests-static or xtests-static.
+container-via-rtld-prefix = $(rtld-prefix)
 else
 run-via-rtld-prefix =
+container-via-rtld-prefix =
 endif
 # $(run-program-env) is the default environment variable settings to
 # use when running a program built with the newly built library.
@@ -891,6 +898,7 @@ endif
 
 ifeq (yes,$(build-hardcoded-path-in-tests))
 test-via-rtld-prefix =
+test-container-via-rtld-prefix =
 test-program-prefix-before-env = $(test-wrapper-env)
 test-program-prefix-after-env =
 test-program-prefix = $(test-program-prefix-before-env) $(run-program-env) \
@@ -902,6 +910,7 @@ test-program-cmd = $(test-program-cmd-before-env) $(run-program-env) \
 host-test-program-cmd = $(built-program-file)
 else
 test-via-rtld-prefix = $(run-via-rtld-prefix)
+test-container-via-rtld-prefix = $(container-via-rtld-prefix)
 test-program-prefix-before-env = $(run-program-prefix-before-env)
 test-program-prefix-after-env = $(run-program-prefix-after-env)
 test-program-prefix = $(run-program-prefix)
diff --git a/Rules b/Rules
index a74043e605..71495028fb 100644
--- a/Rules
+++ b/Rules
@@ -429,7 +429,7 @@ $(objpfx)%.out: /dev/null $(objpfx)%	# Make it 2nd arg for canned sequence.
 # and pid namespaces) in which to run, should be added to
 # tests-container.
 $(tests-container:%=$(objpfx)%.out): $(objpfx)%.out : $(if $(wildcard $(objpfx)%.files),$(objpfx)%.files,/dev/null) $(objpfx)%
-	$(test-wrapper-env) $(run-program-env) $(test-via-rtld-prefix) \
+	$(test-wrapper-env) $(run-program-env) $(test-container-via-rtld-prefix) \
 	  $(common-objpfx)support/test-container env $(run-program-env) $($*-ENV) $(test-tunables) \
 	  $(host-test-program-cmd) $($*-ARGS) > $@; \
 	$(evaluate-test)