From 4f1c3d5cff2cd8a83f5fe13e73e6d57b22d860e4 Mon Sep 17 00:00:00 2001 From: tinebp Date: Thu, 19 Nov 2026 03:36:42 -0800 Subject: [PATCH] tests: build the kernel library and a missing simulator once before the per-test makes Every kernel and regression test links a sw/kernel library, and each test's own Makefile builds it on demand. With make -jN at tests/kernel or tests/regression on a tree where the library was not built yet, every test directory started its own build of sw/kernel at the same time: a clean -j8 run compiled and archived the library four times concurrently, and an archive step could miss an object another build was rewriting ("ar: vx_spawn.c.2.o: No such file"). tests/Makefile runs kernel and regression side by side and so raced the same way, and the kernel tests' runs built a missing simulator once per test. Build the library once, as a prerequisite of build-% and run-% in tests/kernel and tests/regression and of kernel and regression in tests/Makefile, and in tests/kernel build a missing simulator once (sim-) before the per-test runs, so the per-test makes find both up to date. Clean -j4 builds of tests/kernel, of five regression tests and of tests' kernel-lib and kernel targets now archive each library once. Co-Authored-By: Claude Opus 5.5 --- tests/Makefile | 11 ++++++++--- tests/kernel/Makefile | 19 +++++++++++++++---- tests/regression/Makefile | 11 +++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 8f52c09d5b..fd543e6a3c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,10 +6,15 @@ all: unittest kernel regression opencl riscv unittest: $(MAKE) -C unittest -kernel: +# kernel and regression both link the sw/kernel libraries: build them once +# first, so the two don't build them at the same time under -j. +kernel-lib: + $(MAKE) -C $(ROOT_DIR)/sw/kernel + +kernel: kernel-lib $(MAKE) -C kernel -regression: +regression: kernel-lib $(MAKE) -C regression opencl: @@ -41,4 +46,4 @@ clean: $(MAKE) -C graphics clean $(MAKE) -C mpi clean -.PHONY: all unittest kernel regression opencl riscv hip graphics mpi \ No newline at end of file +.PHONY: all kernel-lib unittest kernel regression opencl riscv hip graphics mpi \ No newline at end of file diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile index f405770a97..cf542efca3 100644 --- a/tests/kernel/Makefile +++ b/tests/kernel/Makefile @@ -22,20 +22,31 @@ backend_tests = $(filter-out $(EXCLUDE) $(EXCLUDE_$(1)),$(TESTS)) all: $(addprefix build-,$(ACTIVE_TESTS)) clean: $(addprefix clean-,$(TESTS)) +# The per-test runs build a missing simulator on demand; sim- builds +# it once first, so parallel runs don't each start the same build. define backend_rule -.PHONY: run-$(1) +.PHONY: run-$(1) sim-$(1) run-$(1): $$(addprefix run-$(1)-,$$(call backend_tests,$(1))) +sim-$(1): + @test -e $$(ROOT_DIR)/sim/$(1)/$(1) || $$(MAKE) -C $$(ROOT_DIR)/sim/$(1) +run-$(1)-%: kernel-lib sim-$(1) + $$(MAKE) -C $$* run-$(1) endef $(foreach b,$(BACKENDS),$(eval $(call backend_rule,$(b)))) +# --- shared kernel library ------------------------------------------- +# Every test links sw/kernel's libvortex.a. Build it once, before the +# per-test makes run in parallel, so they don't each start the same build. +.PHONY: kernel-lib +kernel-lib: + $(MAKE) -C $(ROOT_DIR)/sw/kernel + # --- pattern recipes -------------------------------------------------- .PHONY: build-% clean-% -build-%: +build-%: kernel-lib $(MAKE) -C $* all clean-%: $(MAKE) -C $* clean -run-%: - $(MAKE) -C $(word 2,$(subst -, ,$*)) run-$(word 1,$(subst -, ,$*)) diff --git a/tests/regression/Makefile b/tests/regression/Makefile index 1dabd029c6..ab4ad46a17 100644 --- a/tests/regression/Makefile +++ b/tests/regression/Makefile @@ -50,10 +50,17 @@ run-$(1): $$(addprefix run-$(1)-,$$(call backend_tests,$(1))) endef $(foreach b,$(BACKENDS),$(eval $(call backend_rule,$(b)))) +# --- shared kernel library ------------------------------------------- +# Every test links a sw/kernel library. Build it once, before the per-test +# makes run in parallel, so they don't each start the same build. +.PHONY: kernel-lib +kernel-lib: + $(MAKE) -C $(ROOT_DIR)/sw/kernel + # --- pattern recipes -------------------------------------------------- .PHONY: build-% clean-% -build-%: +build-%: kernel-lib $(MAKE) -C $* all clean-%: @@ -61,5 +68,5 @@ clean-%: # run--: split "-" on the first dash. # Subdir names must not contain '-' (none currently do). -run-%: +run-%: kernel-lib $(MAKE) -C $(word 2,$(subst -, ,$*)) run-$(word 1,$(subst -, ,$*))