From ebc9b718cede68ea9a1928450e0e1297cd6e1936 Mon Sep 17 00:00:00 2001 From: Mario Rugiero Date: Thu, 25 Jun 2026 15:28:13 -0300 Subject: [PATCH 1/2] refactor(make): proper per-file dep tracking for ASM programs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the shell for-loop in compile-programs-asm with a pattern rule so make tracks each .s → .elf pair individually and only recompiles files whose source changed. Remove the *-no-compile targets (test-asm-no-compile, test-rust-no-compile, test-no-compile) that existed solely to skip the unconditional loop rebuild; test-asm, test-rust, and test-executor now inline their cargo commands after their compile prerequisites. --- Makefile | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index b5e342c54..be1bce15c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: deps deps-linux deps-macos compile-programs-asm compile-programs-rust compile-bench \ -compile-programs clean-asm clean-rust clean-bench clean-shared clean test test-asm test-no-compile \ -test-asm-no-compile test-rust test-rust-no-compile test-executor flamegraph-prover \ +compile-programs clean-asm clean-rust clean-bench clean-shared clean test test-asm \ +test-rust test-executor test-flamegraph flamegraph-prover \ test-fast test-prover test-prover-all test-disk-spill test-math-cuda test-cuda-integration \ bench-math-cuda bench-prover bench-prover-cuda build check clippy fmt lint regen-ethrex-fixtures \ update-ethrex-fixture-checksums check-ethrex-fixture-checksums @@ -35,7 +35,8 @@ BENCH_ARTIFACTS_DIR=./executor/program_artifacts/bench SHARED_TARGET_DIR=./executor/shared_target -ASM_PROGRAMS = $(wildcard $(ASM_PROGRAMS_DIR)/*.s) +ASM_PROGRAMS := $(wildcard $(ASM_PROGRAMS_DIR)/*.s) +ASM_ARTIFACTS := $(patsubst $(ASM_PROGRAMS_DIR)/%.s,$(ASM_ARTIFACTS_DIR)/%.elf,$(ASM_PROGRAMS)) RUST_PROGRAM_DIRS := $(dir $(wildcard $(RUST_PROGRAMS_DIR)/*/Cargo.toml)) RUST_PROGRAMS := $(notdir $(basename $(RUST_PROGRAM_DIRS:%/=%))) @@ -120,12 +121,13 @@ prepare-sysroot: fi; \ fi -compile-programs-asm: - @mkdir -p $(ASM_ARTIFACTS_DIR) - @set -e; for src in $(ASM_PROGRAMS); do \ - echo "$(CLANG) $(ASM_CFLAGS) $(ASM_LDFLAGS) $$src -o $(ASM_ARTIFACTS_DIR)/$$(basename $$src .s).elf"; \ - $(CLANG) $(ASM_CFLAGS) $(ASM_LDFLAGS) $$src -o $(ASM_ARTIFACTS_DIR)/$$(basename $$src .s).elf; \ - done +compile-programs-asm: $(ASM_ARTIFACTS) + +$(ASM_ARTIFACTS_DIR): + mkdir -p $@ + +$(ASM_ARTIFACTS_DIR)/%.elf: $(ASM_PROGRAMS_DIR)/%.s | $(ASM_ARTIFACTS_DIR) + $(CLANG) $(ASM_CFLAGS) $(ASM_LDFLAGS) $< -o $@ compile-programs-rust: prepare-sysroot $(RUST_ARTIFACTS) @@ -179,22 +181,15 @@ clean-shared: clean: clean-asm clean-rust clean-bench clean-shared -test-executor: compile-programs test-no-compile - -test-asm: compile-programs-asm test-asm-no-compile +test-executor: compile-programs + cargo test -p executor -test-asm-no-compile: +test-asm: compile-programs-asm cargo test -p executor --test asm test-rust: compile-programs-rust cargo test -p executor --test rust -test-rust-no-compile: - cargo test -p executor --test rust - -test-no-compile: - cargo test -p executor - test-flamegraph: cargo test -p executor --test flamegraph From 2e9eef636b9d5925e151fedaef232ff3cfeb9ed0 Mon Sep 17 00:00:00 2001 From: Mauro Toscano <12560266+MauroToscano@users.noreply.github.com> Date: Thu, 25 Jun 2026 15:47:35 -0300 Subject: [PATCH 2/2] refactor(make): use order-only dir prereqs for Rust/Bench pattern rules (#713) Move `mkdir -p` out of the Rust and Bench recipe bodies and into dedicated directory targets with order-only prerequisites, matching the pattern already used for ASM artifacts in this branch. --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index be1bce15c..81bc03a8c 100644 --- a/Makefile +++ b/Makefile @@ -136,14 +136,19 @@ compile-bench: prepare-sysroot $(BENCH_ARTIFACTS) compile-programs: compile-programs-asm compile-programs-rust compile-bench +$(RUST_ARTIFACTS_DIR): + mkdir -p $@ + +$(BENCH_ARTIFACTS_DIR): + mkdir -p $@ + # Compile rust (64-bit) # Order-only `| prepare-sysroot` so a direct `make .../foo.elf` provisions the sysroot # first (the aggregate compile-programs-rust/compile-bench targets already do, but a # bare pattern-rule invocation like `make -B .../ethrex.elf` would otherwise skip it # and fail to compile guest C dependencies). Order-only because prepare-sysroot is # .PHONY — a normal prereq would force a rebuild every time; its recipe is idempotent. -$(RUST_ARTIFACTS_DIR)/%.elf: $(RUST_PROGRAMS_DIR)/%/Cargo.toml | prepare-sysroot - @mkdir -p $(RUST_ARTIFACTS_DIR) +$(RUST_ARTIFACTS_DIR)/%.elf: $(RUST_PROGRAMS_DIR)/%/Cargo.toml | prepare-sysroot $(RUST_ARTIFACTS_DIR) cd $(RUST_PROGRAMS_DIR)/$* && \ CARGO_TARGET_DIR=$(abspath $(SHARED_TARGET_DIR)) \ CFLAGS_riscv64im_lambda_vm_elf="$(SYSROOT_CFLAGS)" \ @@ -155,8 +160,7 @@ $(RUST_ARTIFACTS_DIR)/%.elf: $(RUST_PROGRAMS_DIR)/%/Cargo.toml | prepare-sysroot cp $(SHARED_TARGET_DIR)/riscv64im-lambda-vm-elf/release/$* $@ # Compile rust benches (64-bit) -$(BENCH_ARTIFACTS_DIR)/%.elf: $(BENCH_PROGRAMS_DIR)/%/Cargo.toml | prepare-sysroot - @mkdir -p $(BENCH_ARTIFACTS_DIR) +$(BENCH_ARTIFACTS_DIR)/%.elf: $(BENCH_PROGRAMS_DIR)/%/Cargo.toml | prepare-sysroot $(BENCH_ARTIFACTS_DIR) cd $(BENCH_PROGRAMS_DIR)/$* && \ CARGO_TARGET_DIR=$(abspath $(SHARED_TARGET_DIR)) \ CFLAGS_riscv64im_lambda_vm_elf="$(SYSROOT_CFLAGS)" \