@@ -3926,46 +3926,33 @@ AC_ARG_ENABLE(yjit,
39263926CARGO=
39273927CARGO_BUILD_ARGS=
39283928YJIT_LIBS=
3929+ JIT_CARGO_SUPPORT=no
39293930AS_CASE ( [ "${YJIT_SUPPORT}"] ,
39303931[ yes|dev|stats|dev_nodebug] , [
39313932 AS_IF ( [ test x"$RUSTC" = "xno"] ,
39323933 AC_MSG_ERROR ( [ rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install] )
39333934 )
3934- AS_IF ( [ test x"$ZJIT_SUPPORT" != "xno"] ,
3935- AC_MSG_ERROR ( [ YJIT cannot be enabled when ZJIT is enabled] )
3936- )
39373935
39383936 AS_CASE ( [ "${YJIT_SUPPORT}"] ,
39393937 [ yes] , [
3940- rb_rust_target_subdir=release
39413938 ] ,
39423939 [ dev] , [
3943- rb_rust_target_subdir=debug
3944- CARGO_BUILD_ARGS='--features disasm,runtime_checks'
3940+ rb_cargo_features='disasm,runtime_checks'
3941+ JIT_CARGO_SUPPORT=dev
39453942 AC_DEFINE ( RUBY_DEBUG , 1 )
39463943 ] ,
39473944 [ dev_nodebug] , [
3948- rb_rust_target_subdir=dev_nodebug
3949- CARGO_BUILD_ARGS='--profile dev_nodebug --features disasm'
3945+ rb_cargo_features='disasm'
3946+ JIT_CARGO_SUPPORT=dev_nodebug
39503947 AC_DEFINE ( YJIT_STATS , 1 )
39513948 ] ,
39523949 [ stats] , [
3953- rb_rust_target_subdir=stats
3954- CARGO_BUILD_ARGS='--profile stats'
3950+ JIT_CARGO_SUPPORT=stats
39553951 AC_DEFINE ( YJIT_STATS , 1 )
39563952 ] )
39573953
3958- AS_IF ( [ test -n "${CARGO_BUILD_ARGS}"] , [
3959- AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
3960- AS_IF ( [ test x"$CARGO" = "xno"] ,
3961- AC_MSG_ERROR ( [ cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install] )
3962- ]) )
3963-
3964- YJIT_LIBS="yjit/target/${rb_rust_target_subdir}/libyjit.a"
3965- AS_CASE ( [ "$target_os"] ,[ openbsd*] ,[
3966- # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
3967- LDFLAGS="$LDFLAGS -lpthread -lc++abi"
3968- ] )
3954+ YJIT_LIBS="target/release/libyjit.a"
3955+ RUST_LIB='$(YJIT_LIBS)'
39693956 YJIT_OBJ='yjit.$(OBJEXT)'
39703957 JIT_OBJ='jit.$(OBJEXT)'
39713958 AS_IF ( [ test x"$YJIT_SUPPORT" != "xyes" ] , [
@@ -3976,38 +3963,23 @@ AS_CASE(["${YJIT_SUPPORT}"],
39763963 AC_DEFINE ( USE_YJIT , 0 )
39773964] )
39783965
3979- ZJIT_CARGO_BUILD_ARGS=
39803966ZJIT_LIBS=
39813967AS_CASE ( [ "${ZJIT_SUPPORT}"] ,
39823968[ yes|dev] , [
39833969 AS_IF ( [ test x"$RUSTC" = "xno"] ,
39843970 AC_MSG_ERROR ( [ rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install] )
39853971 )
3986- AS_IF ( [ test x"$YJIT_SUPPORT" != "xno"] ,
3987- AC_MSG_ERROR ( [ ZJIT cannot be enabled when YJIT is enabled] )
3988- )
39893972
39903973 AS_CASE ( [ "${ZJIT_SUPPORT}"] ,
39913974 [ yes] , [
3992- rb_rust_target_subdir=release
39933975 ] ,
39943976 [ dev] , [
3995- rb_rust_target_subdir=debug
3996- ZJIT_CARGO_BUILD_ARGS='--profile dev --features disasm'
3977+ JIT_CARGO_SUPPORT=dev
39973978 AC_DEFINE ( RUBY_DEBUG , 1 )
39983979 ] )
39993980
4000- AS_IF ( [ test -n "${ZJIT_CARGO_BUILD_ARGS}"] , [
4001- AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
4002- AS_IF ( [ test x"$CARGO" = "xno"] ,
4003- AC_MSG_ERROR ( [ cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install] )
4004- ]) )
4005-
4006- ZJIT_LIBS="zjit/target/${rb_rust_target_subdir}/libzjit.a"
4007- AS_CASE ( [ "$target_os"] ,[ openbsd*] ,[
4008- # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
4009- LDFLAGS="$LDFLAGS -lpthread -lc++abi"
4010- ] )
3981+ ZJIT_LIBS="target/release/libzjit.a"
3982+ RUST_LIB='$(ZJIT_LIBS)'
40113983 ZJIT_OBJ='zjit.$(OBJEXT)'
40123984 JIT_OBJ='jit.$(OBJEXT)'
40133985 AS_IF ( [ test x"$ZJIT_SUPPORT" != "xyes" ] , [
@@ -4018,18 +3990,57 @@ AS_CASE(["${ZJIT_SUPPORT}"],
40183990 AC_DEFINE ( USE_ZJIT , 0 )
40193991] )
40203992
3993+ # if YJIT+ZJIT release build, or any build that requires Cargo
3994+ AS_IF ( [ test x"$JIT_CARGO_SUPPORT" != "xno" -o \( x"$YJIT_SUPPORT" != "xno" -a x"$ZJIT_SUPPORT" != "xno" \)] , [
3995+ AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
3996+ AS_IF ( [ test x"$CARGO" = "xno"] ,
3997+ AC_MSG_ERROR ( [ cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install] ) )
3998+
3999+ YJIT_LIBS=
4000+ ZJIT_LIBS=
4001+
4002+ AS_IF ( [ test x"${YJIT_SUPPORT}" != x"no"] , [
4003+ rb_cargo_features="$rb_cargo_features,yjit"
4004+ ] )
4005+ AS_IF ( [ test x"${ZJIT_SUPPORT}" != x"no"] , [
4006+ rb_cargo_features="$rb_cargo_features,zjit"
4007+ ] )
4008+ # if YJIT and ZJIT release mode
4009+ AS_IF ( [ test "${YJIT_SUPPORT}:${ZJIT_SUPPORT}" = "yes:yes"] , [
4010+ JIT_CARGO_SUPPORT=release
4011+ ] )
4012+ CARGO_BUILD_ARGS="--profile ${JIT_CARGO_SUPPORT} --features ${rb_cargo_features}"
4013+ AS_IF ( [ test "${JIT_CARGO_SUPPORT}" = "dev"] , [
4014+ RUST_LIB="target/debug/libjit.a"
4015+ ] , [
4016+ RUST_LIB="target/${JIT_CARGO_SUPPORT}/libjit.a"
4017+ ] )
4018+ ] )
4019+
4020+ # In case either we're linking rust code
4021+ AS_IF ( [ test -n "$RUST_LIB"] , [
4022+ AS_CASE ( [ "$target_os"] ,[ openbsd*] ,[
4023+ # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by rust stdlib
4024+ LDFLAGS="$LDFLAGS -lpthread -lc++abi"
4025+ ] )
4026+
4027+ # absolute path to stop the "target" dir in src dir from interfering through VPATH
4028+ RUST_LIB="$(pwd)/${RUST_LIB}"
4029+ ] )
4030+
40214031dnl These variables end up in ::RbConfig::CONFIG
4022- AC_SUBST ( YJIT_SUPPORT ) dnl what flavor of YJIT the Ruby build includes
40234032AC_SUBST ( RUSTC ) dnl Rust compiler command
40244033AC_SUBST ( CARGO ) dnl Cargo command for Rust builds
40254034AC_SUBST ( CARGO_BUILD_ARGS ) dnl for selecting Rust build profiles
4026- AC_SUBST ( ZJIT_CARGO_BUILD_ARGS ) dnl for selecting Rust build profiles
4027- AC_SUBST ( YJIT_LIBS ) dnl for optionally building the Rust parts of YJIT
4035+ AC_SUBST ( YJIT_SUPPORT ) dnl what flavor of YJIT the Ruby build includes
4036+ AC_SUBST ( YJIT_LIBS ) dnl the .a library of YJIT
40284037AC_SUBST ( YJIT_OBJ ) dnl for optionally building the C parts of YJIT
40294038AC_SUBST ( ZJIT_SUPPORT ) dnl what flavor of ZJIT the Ruby build includes
4030- AC_SUBST ( ZJIT_LIBS ) dnl for optionally building the Rust parts of ZJIT
4039+ AC_SUBST ( ZJIT_LIBS ) dnl path to the .a library of ZJIT
40314040AC_SUBST ( ZJIT_OBJ ) dnl for optionally building the C parts of ZJIT
40324041AC_SUBST ( JIT_OBJ ) dnl for optionally building C glue code for Rust FFI
4042+ AC_SUBST ( RUST_LIB ) dnl path to the rust .a library that contains either or both JITs
4043+ AC_SUBST ( JIT_CARGO_SUPPORT ) dnl "no" or the cargo profile of the rust code
40334044}
40344045
40354046[ begin] _group "build section" && {
0 commit comments