summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2025-07-15 17:16:57 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2025-07-16 14:10:22 -0400
commit5ee3937a9c8f75d07f4919f64decd0b850abefe0 (patch)
tree4c440f0781d32bb95480c0f45f55f6396d7864ad
parentea81e7b8b747ca2a7b19aabfa3711b4d33c133b1 (diff)
ZJIT: Have `make zjit-test` use the same Cargo features as miniruby
This is so that e.g. building with `--enable-zjit=dev` will test with the disassembly feature. It makes more sense, saves on build time and reveals that `backend::arm64::tests::sp_movements_are_single_instruction` was in fact failing with the `disasm` feature.
-rw-r--r--Cargo.toml2
-rw-r--r--configure.ac6
-rw-r--r--template/Makefile.in1
-rw-r--r--zjit/Cargo.toml1
-rw-r--r--zjit/zjit.mk18
5 files changed, 20 insertions, 8 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 6ab7e3a45f..3f373fdace 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ path = "jit.rs"
[features]
disasm = ["yjit?/disasm", "zjit?/disasm"]
-runtime_checks = []
+runtime_checks = ["yjit?/runtime_checks", "zjit?/runtime_checks"]
yjit = [ "dep:yjit" ]
zjit = [ "dep:zjit" ]
diff --git a/configure.ac b/configure.ac
index 4766b8813c..8e08b91edb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4014,10 +4014,16 @@ AS_IF([test x"$JIT_CARGO_SUPPORT" != "xno" -o \( x"$YJIT_SUPPORT" != "xno" -a x"
YJIT_LIBS=
ZJIT_LIBS=
+ # There's more processing below to get the feature set for the
+ # top-level crate, so capture at this point for feature set of
+ # just the zjit crate.
+ ZJIT_TEST_FEATURES="${rb_cargo_features}"
+
AS_IF([test x"${YJIT_SUPPORT}" != x"no"], [
rb_cargo_features="$rb_cargo_features,yjit"
])
AS_IF([test x"${ZJIT_SUPPORT}" != x"no"], [
+ AC_SUBST(ZJIT_TEST_FEATURES)
rb_cargo_features="$rb_cargo_features,zjit"
])
# if YJIT and ZJIT release mode
diff --git a/template/Makefile.in b/template/Makefile.in
index 96c8d8031b..1e6d55c435 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -113,6 +113,7 @@ ZJIT_OBJ=@ZJIT_OBJ@
JIT_CARGO_SUPPORT=@JIT_CARGO_SUPPORT@
CARGO_TARGET_DIR=@abs_top_builddir@/target
CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@
+ZJIT_TEST_FEATURES=@ZJIT_TEST_FEATURES@
RUST_LIB=@RUST_LIB@
RUST_LIBOBJ = $(RUST_LIB:.a=.@OBJEXT@)
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
diff --git a/zjit/Cargo.toml b/zjit/Cargo.toml
index a86117d6e2..a1da8e7cc0 100644
--- a/zjit/Cargo.toml
+++ b/zjit/Cargo.toml
@@ -18,3 +18,4 @@ expect-test = "1.5.1"
[features]
# Support --yjit-dump-disasm and RubyVM::YJIT.disasm using libcapstone.
disasm = ["capstone"]
+runtime_checks = []
diff --git a/zjit/zjit.mk b/zjit/zjit.mk
index 34eccebdab..047f4ab3a3 100644
--- a/zjit/zjit.mk
+++ b/zjit/zjit.mk
@@ -68,6 +68,12 @@ zjit-bindgen: zjit.$(OBJEXT)
ZJIT_SRC_ROOT_PATH='$(top_srcdir)' BINDGEN_JIT_NAME=zjit $(CARGO) run --manifest-path '$(top_srcdir)/zjit/bindgen/Cargo.toml' -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS)
$(Q) if [ 'x$(HAVE_GIT)' = xyes ]; then $(GIT) -C "$(top_srcdir)" diff $(ZJIT_BINDGEN_DIFF_OPTS) zjit/src/cruby_bindings.inc.rs; fi
+# Build env should roughly match what's used for miniruby to help with caching.
+ZJIT_NEXTEST_ENV := RUBY_BUILD_DIR='$(TOP_BUILD_DIR)' \
+ RUBY_LD_FLAGS='$(LDFLAGS) $(XLDFLAGS) $(MAINLIBS)' \
+ MACOSX_DEPLOYMENT_TARGET=11.0 \
+ CARGO_TARGET_DIR='$(CARGO_TARGET_DIR)'
+
# We need `cargo nextest` for its one-process-per execution execution model
# since we can only boot the VM once per process. Normal `cargo test`
# runs tests in threads and can't handle this.
@@ -75,10 +81,10 @@ zjit-bindgen: zjit.$(OBJEXT)
# On darwin, it's available through `brew install cargo-nextest`. See
# https://nexte.st/docs/installation/pre-built-binaries/ otherwise.
zjit-test: libminiruby.a
- RUBY_BUILD_DIR='$(TOP_BUILD_DIR)' \
- RUBY_LD_FLAGS='$(LDFLAGS) $(XLDFLAGS) $(MAINLIBS)' \
- CARGO_TARGET_DIR='$(CARGO_TARGET_DIR)' \
- $(CARGO) nextest run --manifest-path '$(top_srcdir)/zjit/Cargo.toml' $(ZJIT_TESTS)
+ $(ZJIT_NEXTEST_ENV) $(CARGO) nextest run \
+ --manifest-path '$(top_srcdir)/zjit/Cargo.toml' \
+ '--features=$(ZJIT_TEST_FEATURES)' \
+ $(ZJIT_TESTS)
# Run a ZJIT test written with Rust #[test] under LLDB
zjit-test-lldb: libminiruby.a
@@ -88,9 +94,7 @@ zjit-test-lldb: libminiruby.a
echo "Many tests only work when it's the only test in the process."; \
exit 1; \
fi; \
- exe_path=`RUBY_BUILD_DIR='$(TOP_BUILD_DIR)' \
- RUBY_LD_FLAGS='$(LDFLAGS) $(XLDFLAGS) $(MAINLIBS)' \
- CARGO_TARGET_DIR='$(CARGO_TARGET_DIR)' \
+ exe_path=`$(ZJIT_NEXTEST_ENV) \
$(CARGO) nextest list --manifest-path '$(top_srcdir)/zjit/Cargo.toml' --message-format json --list-type=binaries-only | \
$(BASERUBY) -rjson -e 'puts JSON.load(STDIN.read).dig("rust-binaries", "zjit", "binary-path")'`; \
exec lldb $$exe_path -- --test-threads=1 $(ZJIT_TESTS)