Skip to content

Commit b066a0f

Browse files
authored
Merge pull request #41 from sysprog21/rosetta
Add x86_64-via-Apple-Rosetta translator support
2 parents 72def1a + c12dd42 commit b066a0f

38 files changed

Lines changed: 6054 additions & 382 deletions

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ SRCS := \
2424
core/stack.c \
2525
core/vdso.c \
2626
core/bootstrap.c \
27+
core/rosetta.c \
2728
core/sysroot.c \
2829
runtime/thread.c \
2930
runtime/futex.c \

mk/tests.mk

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
test-static-bins \
55
test-dynamic test-dynamic-coreutils test-glibc-dynamic \
66
test-glibc-coreutils test-perf \
7+
test-rosetta-cli test-rosetta-statics test-rosetta-failure-modes \
8+
test-rosetta-alpine test-rosetta-all bench-rosetta \
79
test-matrix test-matrix-elfuse-aarch64 test-matrix-qemu-aarch64 \
810
test-full test-multi-vcpu test-rwx test-sysroot-rename \
911
test-case-collision test-case-collision-fallback test-sysroot-create-paths \
@@ -20,6 +22,17 @@ test-hello: $(ELFUSE_BIN) $(TEST_HELLO_DEP)
2022
check-syscall-coverage:
2123
@python3 scripts/check-syscall-coverage.py
2224

25+
define RUN_OPTIONAL_SKIP77
26+
@set -e; \
27+
rc=0; \
28+
$(1) || rc=$$?; \
29+
if [ "$$rc" = 77 ]; then \
30+
printf "$(YELLOW)SKIP$(RESET) %s\n" "$(2)"; \
31+
elif [ "$$rc" != 0 ]; then \
32+
exit "$$rc"; \
33+
fi
34+
endef
35+
2336
## Run the unit test suite plus busybox applet validation
2437
check: $(ELFUSE_BIN) $(TEST_DEPS) check-syscall-coverage
2538
@bash tests/driver.sh -e $(ELFUSE_BIN) -d $(TEST_DIR) -v
@@ -35,6 +48,8 @@ check: $(ELFUSE_BIN) $(TEST_DEPS) check-syscall-coverage
3548
@$(MAKE) --no-print-directory test-fuse-alpine
3649
@printf "\n$(BLUE)━━━ timeout=0 validation ━━━$(RESET)\n"
3750
@$(MAKE) --no-print-directory test-timeout-disable
51+
@printf "\n$(BLUE)━━━ rosetta CLI gating ━━━$(RESET)\n"
52+
@$(MAKE) --no-print-directory test-rosetta-cli
3853

3954
test-sysroot-rename: $(ELFUSE_BIN) $(BUILD_DIR)/test-sysroot-rename
4055
@set -e; \
@@ -114,6 +129,40 @@ test-timeout-disable: $(ELFUSE_BIN) $(TEST_HELLO_DEP)
114129
test-gdbstub: $(ELFUSE_BIN) $(TEST_DIR)/test-hello
115130
@bash tests/test-gdbstub.sh -e $(ELFUSE_BIN) -v
116131

132+
## Run Rosetta CLI gating regressions without requiring Rosetta runtime support
133+
test-rosetta-cli: $(ELFUSE_BIN)
134+
@bash tests/test-rosetta-cli.sh $(ELFUSE_BIN)
135+
136+
## Smoke test x86_64 statics through Rosetta. Requires Rosetta-for-Linux
137+
## installed on the host and the Alpine x86_64 fixture tree staged via
138+
## INCLUDE_X86_64=1 bash tests/fetch-fixtures.sh. Skips cleanly otherwise.
139+
test-rosetta-statics: $(ELFUSE_BIN)
140+
$(call RUN_OPTIONAL_SKIP77,bash tests/test-rosetta-statics.sh $(ELFUSE_BIN),test-rosetta-statics)
141+
142+
## Probe known-unsupported scenarios (dynamic x86_64, mid-process execve,
143+
## --gdb on x86_64, --no-rosetta). Verifies the failure path emits a
144+
## stable error rather than crashing or succeeding silently.
145+
test-rosetta-failure-modes: $(ELFUSE_BIN)
146+
@bash tests/test-rosetta-failure-modes.sh $(ELFUSE_BIN)
147+
148+
## Alpine x86_64 file-I/O + text-pipeline coverage. Lifts the matrix's
149+
## busybox-applet style tests against the Alpine staticbin tree but stays
150+
## lightweight enough for the rosetta-all aggregate. Skips cleanly when
151+
## fixtures or Rosetta-for-Linux are missing.
152+
test-rosetta-alpine: $(ELFUSE_BIN)
153+
$(call RUN_OPTIONAL_SKIP77,bash tests/test-rosetta-alpine.sh $(ELFUSE_BIN),test-rosetta-alpine)
154+
155+
## Run every Rosetta-specific test target in sequence.
156+
test-rosetta-all: test-rosetta-cli test-rosetta-failure-modes \
157+
test-rosetta-statics test-rosetta-alpine
158+
159+
## Wall-clock bench harness for x86_64-via-Rosetta workloads. Prints
160+
## best-of-N samples plus the aarch64 reference where available. Set
161+
## BENCH_ITERS=<n> to change sample count (default 5).
162+
BENCH_ITERS ?= 5
163+
bench-rosetta: $(ELFUSE_BIN)
164+
$(call RUN_OPTIONAL_SKIP77,bash tests/bench-rosetta.sh $(ELFUSE_BIN) $(BENCH_ITERS),bench-rosetta)
165+
117166
## Alias for check (backward compat)
118167
test-all: check
119168

@@ -407,6 +456,11 @@ test-matrix-elfuse-aarch64: $(ELFUSE_BIN) $(TEST_DEPS)
407456
test-matrix-qemu-aarch64: $(ELFUSE_BIN) $(TEST_DEPS)
408457
@bash tests/test-matrix.sh qemu-aarch64
409458

459+
## Probe the x86_64-via-Rosetta matrix wiring. Fails closed until the runtime
460+
## and fixture corpus are complete enough to execute real coverage.
461+
test-matrix-elfuse-x86_64: $(ELFUSE_BIN) $(TEST_DEPS)
462+
@bash tests/test-matrix.sh elfuse-x86_64
463+
410464
# Full test suite
411465
## Run the complete test suite (aarch64: unit + busybox + gdbstub + coreutils + static + dynamic)
412466
test-full: $(ELFUSE_BIN)

0 commit comments

Comments
 (0)