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.
This commit is contained in:
Alan Wu 2025-07-15 17:16:57 -04:00
parent ea81e7b8b7
commit 5ee3937a9c
5 changed files with 20 additions and 8 deletions

View file

@ -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" ]

View file

@ -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

View file

@ -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@

View file

@ -18,3 +18,4 @@ expect-test = "1.5.1"
[features]
# Support --yjit-dump-disasm and RubyVM::YJIT.disasm using libcapstone.
disasm = ["capstone"]
runtime_checks = []

View file

@ -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)