[PATCH v2 5/6] Run check-installed-headers concurrently for each header
Sam James
sam@gentoo.org
Fri Jul 3 11:05:54 GMT 2026
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> The check-installed-headers-c/-cxx tests ran one script invocation per
> subdirectory over all of its installed headers, performing about 80
> compiler invocations per header serially.
>
> Give each header its own intermediate target so the compiler
> invocations parallelize under the make jobserver, recording the
> per-header script exit status next to the output. The .out target
> concatenates the per-header outputs in the original $(headers) order
> and fails if any recorded status is non-zero, so both the .out contents
> (verified byte-identical for all 76 files) and the tests.sum results
> are unchanged.
>
> Results on a x86_64 machine [1] from a make check with run-built-tests=no
> show neutral results, and on aarch64 machine [2] it improves from 241.574s
> to 182.405.
>
> [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
Reviewed-by: Sam James <sam@gentoo.org>
> ---
> Makefile | 37 ++++++++++++++++++++++++++-----------
> Rules | 38 +++++++++++++++++++++++++++-----------
> 2 files changed, 53 insertions(+), 22 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 79dbe0f40d3..5f2293dfd7d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -684,26 +684,41 @@ $(objpfx)check-local-headers.out: scripts/check-local-headers.sh
> $(evaluate-test)
>
> ifneq "$(headers)" ""
> -# Special test of all the installed headers in this directory.
> +# Special test of all the installed headers in this directory. See
> +# Rules for the per-header split rationale.
> tests-special += $(objpfx)check-installed-headers-c.out
> libof-check-installed-headers-c := testsuite
> -$(objpfx)check-installed-headers-c.out: \
> ++cih-c-iouts := $(patsubst %,$(objpfx)check-installed-headers-c/%.iout,\
> + $(headers))
> +$(+cih-c-iouts): $(objpfx)check-installed-headers-c/%.iout: \
> scripts/check-installed-headers.sh $(headers)
> - $(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \
> - "$(CC) $(test-config-cflags-finput-charset-ascii) \
> - $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
> - $(headers) > $@; \
> + $(make-target-directory)
> + ($(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \
> + "$(CC) $(test-config-cflags-finput-charset-ascii) \
> + $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
> + $*; echo $$? > $@-ret) > $@T; \
> + mv -f $@T $@
> +$(objpfx)check-installed-headers-c.out: $(+cih-c-iouts)
> + cat $^ > $@; \
> + ! grep -qv '^0$$' $(+cih-c-iouts:%=%-ret); \
> $(evaluate-test)
This is clever :)
>
> ifneq "$(CXX)" ""
> tests-special += $(objpfx)check-installed-headers-cxx.out
> libof-check-installed-headers-cxx := testsuite
> -$(objpfx)check-installed-headers-cxx.out: \
> ++cih-cxx-iouts := $(patsubst %,$(objpfx)check-installed-headers-cxx/%.iout,\
> + $(headers))
> +$(+cih-cxx-iouts): $(objpfx)check-installed-headers-cxx/%.iout: \
> scripts/check-installed-headers.sh $(headers)
> - $(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \
> - "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \
> - $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> - $(headers) > $@; \
> + $(make-target-directory)
> + ($(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \
> + "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \
> + $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> + $*; echo $$? > $@-ret) > $@T; \
> + mv -f $@T $@
> +$(objpfx)check-installed-headers-cxx.out: $(+cih-cxx-iouts)
> + cat $^ > $@; \
> + ! grep -qv '^0$$' $(+cih-cxx-iouts:%=%-ret); \
> $(evaluate-test)
> endif # $(CXX)
>
> diff --git a/Rules b/Rules
> index 385246f07df..a74043e6059 100644
> --- a/Rules
> +++ b/Rules
> @@ -80,15 +80,24 @@ common-generated += dummy.o dummy.c
>
> ifneq "$(headers)" ""
> # Test that all of the headers installed by this directory can be compiled
> -# in isolation.
> +# in isolation. Each header gets its own intermediate target so that the
> +# it can run concurrently under -j; the .out target concatenates the per-header
> +# results in the original $(headers) order.
> tests-special += $(objpfx)check-installed-headers-c.out
> libof-check-installed-headers-c := testsuite
> -$(objpfx)check-installed-headers-c.out: \
> ++cih-c-iouts := $(patsubst %,$(objpfx)check-installed-headers-c/%.iout,\
> + $(headers))
> +$(+cih-c-iouts): $(objpfx)check-installed-headers-c/%.iout: \
> $(..)scripts/check-installed-headers.sh $(headers)
> - $(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \
> - "$(CC) $(test-config-cflags-finput-charset-ascii) \
> - $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
> - $(headers) > $@; \
> + $(make-target-directory)
> + ($(SHELL) $(..)scripts/check-installed-headers.sh c $(supported-fortify) \
> + "$(CC) $(test-config-cflags-finput-charset-ascii) \
> + $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
> + $*; echo $$? > $@-ret) > $@T; \
> + mv -f $@T $@
> +$(objpfx)check-installed-headers-c.out: $(+cih-c-iouts)
> + cat $^ > $@; \
> + ! grep -qv '^0$$' $(+cih-c-iouts:%=%-ret); \
> $(evaluate-test)
>
> ifneq "$(CXX)" ""
> @@ -96,12 +105,19 @@ ifneq "$(CXX)" ""
> # in isolation as C++.
> tests-special += $(objpfx)check-installed-headers-cxx.out
> libof-check-installed-headers-cxx := testsuite
> -$(objpfx)check-installed-headers-cxx.out: \
> ++cih-cxx-iouts := $(patsubst %,$(objpfx)check-installed-headers-cxx/%.iout,\
> + $(headers))
> +$(+cih-cxx-iouts): $(objpfx)check-installed-headers-cxx/%.iout: \
> $(..)scripts/check-installed-headers.sh $(headers)
> - $(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \
> - "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \
> - $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> - $(headers) > $@; \
> + $(make-target-directory)
> + ($(SHELL) $(..)scripts/check-installed-headers.sh c++ $(supported-fortify) \
> + "$(CXX) $(test-config-cxxflags-finput-charset-ascii) \
> + $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
> + $*; echo $$? > $@-ret) > $@T; \
> + mv -f $@T $@
> +$(objpfx)check-installed-headers-cxx.out: $(+cih-cxx-iouts)
> + cat $^ > $@; \
> + ! grep -qv '^0$$' $(+cih-cxx-iouts:%=%-ret); \
> $(evaluate-test)
> endif # $(CXX)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 418 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260703/007077f6/attachment.sig>
More information about the Libc-alpha
mailing list