@@ -3896,7 +3896,6 @@ AC_SUBST(INSTALL_STATIC_LIBRARY)
38963896
38973897[ begin] _group "JIT section" && {
38983898AC_CHECK_PROG ( RUSTC , [ rustc] , [ rustc] , [ no] ) dnl no ac_tool_prefix
3899- AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
39003899
39013900dnl check if rustc is recent enough to build YJIT (rustc >= 1.58.0)
39023901JIT_RUSTC_OK=no
@@ -3963,11 +3962,7 @@ AC_ARG_ENABLE(zjit,
39633962 # 1.85.0 is the first stable version that supports the 2024 edition.
39643963 AS_IF ( [ test "$RUSTC" != "no" && echo "#[ cfg(target_arch = \"$JIT_TARGET_ARCH\")] fn main() {}" |
39653964 $RUSTC - --edition=2024 --emit asm=/dev/null 2>/dev/null] ,
3966- AS_IF ( [ test "$gnumake" = "yes" -a \( "$YJIT_SUPPORT" = "no" -o "$CARGO" != "no" \)] , [
3967- # When only building ZJIT, we don't need cargo; it's required for YJIT+ZJIT build.
3968- # Assume that if rustc is new enough, then cargo is also.
3969- # TODO(alan): Get rid of dependency on cargo in YJIT+ZJIT build. Cargo's offline mode
3970- # still too unreliable: https://github.com/rust-lang/cargo/issues/10352
3965+ AS_IF ( [ test "$gnumake" = "yes"] , [
39713966 rb_zjit_build_possible=yes
39723967 ] )
39733968 )
@@ -4053,36 +4048,49 @@ AS_CASE(["${ZJIT_SUPPORT}"],
40534048 AC_DEFINE ( USE_ZJIT , 0 )
40544049] )
40554050
4056- # if YJIT+ZJIT release build, or any build that requires Cargo
4057- AS_IF ( [ test x"$JIT_CARGO_SUPPORT" != "xno" -o \( x"$YJIT_SUPPORT" != "xno" -a x"$ZJIT_SUPPORT" != "xno" \)] , [
4058- AS_IF ( [ test x"$CARGO" = "xno"] ,
4059- AC_MSG_ERROR ( [ this build configuration requires cargo. Installation instructions available at https://www.rust-lang.org/tools/install] ) )
4060-
4061- YJIT_LIBS=
4062- ZJIT_LIBS=
4063-
4064- # There's more processing below to get the feature set for the
4065- # top-level crate, so capture at this point for feature set of
4066- # just the zjit crate.
4067- ZJIT_TEST_FEATURES="${rb_cargo_features}"
4051+ JIT_RUST_FLAGS='--crate-type=staticlib --cfg feature=\"stats_allocator\"'
4052+ RLIB_DIR=
4053+ AS_CASE ( [ "$JIT_CARGO_SUPPORT:$YJIT_SUPPORT:$ZJIT_SUPPORT"] ,
4054+ [ no:yes:yes] , [ # release build of YJIT+ZJIT
4055+ YJIT_LIBS=
4056+ ZJIT_LIBS=
4057+ JIT_RUST_FLAGS="--crate-type=rlib"
4058+ RLIB_DIR="target/release"
4059+ RUST_LIB="target/release/libruby.a"
4060+ ] ,
4061+ [ no:*] , [ ] ,
4062+ [ *] , [ # JIT_CARGO_SUPPORT not "no" -- cargo required.
4063+ AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
4064+ AS_IF ( [ test x"$CARGO" = "xno"] ,
4065+ AC_MSG_ERROR ( [ this build configuration requires cargo. Installation instructions available at https://www.rust-lang.org/tools/install] ) )
4066+
4067+ YJIT_LIBS=
4068+ ZJIT_LIBS=
4069+
4070+ # There's more processing below to get the feature set for the
4071+ # top-level crate, so capture at this point for feature set of
4072+ # just the zjit crate.
4073+ ZJIT_TEST_FEATURES="${rb_cargo_features}"
4074+
4075+ AS_IF ( [ test x"${YJIT_SUPPORT}" != x"no"] , [
4076+ rb_cargo_features="$rb_cargo_features,yjit"
4077+ ] )
4078+ AS_IF ( [ test x"${ZJIT_SUPPORT}" != x"no"] , [
4079+ AC_SUBST ( ZJIT_TEST_FEATURES )
4080+ rb_cargo_features="$rb_cargo_features,zjit"
4081+ ] )
4082+ # if YJIT and ZJIT release mode
4083+ AS_IF ( [ test "${YJIT_SUPPORT}:${ZJIT_SUPPORT}" = "yes:yes"] , [
4084+ JIT_CARGO_SUPPORT=release
4085+ ] )
4086+ CARGO_BUILD_ARGS="--profile ${JIT_CARGO_SUPPORT} --features ${rb_cargo_features}"
4087+ AS_IF ( [ test "${JIT_CARGO_SUPPORT}" = "dev"] , [
4088+ RUST_LIB="target/debug/libruby.a"
4089+ ] , [
4090+ RUST_LIB="target/${JIT_CARGO_SUPPORT}/libruby.a"
4091+ ] )
4092+ ] ,
40684093
4069- AS_IF ( [ test x"${YJIT_SUPPORT}" != x"no"] , [
4070- rb_cargo_features="$rb_cargo_features,yjit"
4071- ] )
4072- AS_IF ( [ test x"${ZJIT_SUPPORT}" != x"no"] , [
4073- AC_SUBST ( ZJIT_TEST_FEATURES )
4074- rb_cargo_features="$rb_cargo_features,zjit"
4075- ] )
4076- # if YJIT and ZJIT release mode
4077- AS_IF ( [ test "${YJIT_SUPPORT}:${ZJIT_SUPPORT}" = "yes:yes"] , [
4078- JIT_CARGO_SUPPORT=release
4079- ] )
4080- CARGO_BUILD_ARGS="--profile ${JIT_CARGO_SUPPORT} --features ${rb_cargo_features}"
4081- AS_IF ( [ test "${JIT_CARGO_SUPPORT}" = "dev"] , [
4082- RUST_LIB="target/debug/libruby.a"
4083- ] , [
4084- RUST_LIB="target/${JIT_CARGO_SUPPORT}/libruby.a"
4085- ] )
40864094])
40874095
40884096# In case either we're linking rust code
@@ -4098,6 +4106,7 @@ AS_IF([test -n "$RUST_LIB"], [
40984106
40994107dnl These variables end up in ::RbConfig::CONFIG
41004108AC_SUBST ( RUSTC ) dnl Rust compiler command
4109+ AC_SUBST ( JIT_RUST_FLAGS ) dnl the common rustc flags for JIT crates such as zjit
41014110AC_SUBST ( CARGO ) dnl Cargo command for Rust builds
41024111AC_SUBST ( CARGO_BUILD_ARGS ) dnl for selecting Rust build profiles
41034112AC_SUBST ( YJIT_SUPPORT ) dnl what flavor of YJIT the Ruby build includes
@@ -4108,6 +4117,7 @@ AC_SUBST(ZJIT_LIBS)dnl path to the .a library of ZJIT
41084117AC_SUBST ( ZJIT_OBJ ) dnl for optionally building the C parts of ZJIT
41094118AC_SUBST ( JIT_OBJ ) dnl for optionally building C glue code for Rust FFI
41104119AC_SUBST ( RUST_LIB ) dnl path to the rust .a library that contains either or both JITs
4120+ AC_SUBST ( RLIB_DIR ) dnl subpath of build directory for .rlib files
41114121AC_SUBST ( JIT_CARGO_SUPPORT ) dnl "no" or the cargo profile of the rust code
41124122}
41134123
0 commit comments