@@ -3926,6 +3926,7 @@ AC_ARG_ENABLE(yjit,
39263926CARGO=
39273927CARGO_BUILD_ARGS=
39283928YJIT_LIBS=
3929+ RUST_JIT_SUPPORT=no
39293930AS_CASE ( [ "${YJIT_SUPPORT}"] ,
39303931[ yes|dev|stats|dev_nodebug] , [
39313932 AS_IF ( [ test x"$RUSTC" = "xno"] ,
@@ -3934,37 +3935,24 @@ AS_CASE(["${YJIT_SUPPORT}"],
39343935
39353936 AS_CASE ( [ "${YJIT_SUPPORT}"] ,
39363937 [ yes] , [
3937- rb_rust_target_subdir=release
39383938 ] ,
39393939 [ dev] , [
3940- rb_rust_target_subdir=debug
3941- CARGO_BUILD_ARGS='--features disasm,runtime_checks'
3940+ rb_cargo_features='disasm,runtime_checks'
3941+ RUST_JIT_SUPPORT=dev
39423942 AC_DEFINE ( RUBY_DEBUG , 1 )
39433943 ] ,
39443944 [ dev_nodebug] , [
3945- rb_rust_target_subdir=dev_nodebug
3946- CARGO_BUILD_ARGS='--profile dev_nodebug --features disasm'
3945+ rb_cargo_features='disasm'
3946+ RUST_JIT_SUPPORT=dev_nodebug
39473947 AC_DEFINE ( YJIT_STATS , 1 )
39483948 ] ,
39493949 [ stats] , [
3950- rb_rust_target_subdir=stats
3951- CARGO_BUILD_ARGS='--profile stats'
3950+ RUST_JIT_SUPPORT=stats
39523951 AC_DEFINE ( YJIT_STATS , 1 )
39533952 ] )
39543953
3955- AS_IF ( [ test -n "${CARGO_BUILD_ARGS}"] , [
3956- AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
3957- AS_IF ( [ test x"$CARGO" = "xno"] ,
3958- AC_MSG_ERROR ( [ cargo is required. Installation instructions available at https://www.rust-lang.org/tools/install] )
3959- ]) )
3960-
3961- YJIT_LIBS="target/${rb_rust_target_subdir}/libyjit.a"
3954+ YJIT_LIBS="target/release/libyjit.a"
39623955 RUST_LIB='$(YJIT_LIBS)'
3963- RUST_JIT_SUPPORT="yjit"
3964- AS_CASE ( [ "$target_os"] ,[ openbsd*] ,[
3965- # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
3966- LDFLAGS="$LDFLAGS -lpthread -lc++abi"
3967- ] )
39683956 YJIT_OBJ='yjit.$(OBJEXT)'
39693957 JIT_OBJ='jit.$(OBJEXT)'
39703958 AS_IF ( [ test x"$YJIT_SUPPORT" != "xyes" ] , [
@@ -3984,37 +3972,16 @@ AS_CASE(["${ZJIT_SUPPORT}"],
39843972
39853973 AS_CASE ( [ "${ZJIT_SUPPORT}"] ,
39863974 [ yes] , [
3987- rb_rust_target_subdir=release
39883975 ] ,
39893976 [ dev] , [
3990- rb_rust_target_subdir=debug
3991- CARGO_BUILD_ARGS="${CARGO_BUILD_ARGS} --profile dev --features disasm,zjit"
3977+ RUST_JIT_SUPPORT=dev
39923978 AC_DEFINE ( RUBY_DEBUG , 1 )
39933979 ] )
39943980
3995- dnl TODO(alan): for commit message: note that for combo builds, when one is in dev mode everyone is in dev mode.
3996- AS_IF ( [ test -n "${CARGO_BUILD_ARGS}" -o x"$YJIT_SUPPORT" != "xno"] , [ dnl YJIT+ZJIT build
3997- AC_CHECK_TOOL ( CARGO , [ cargo] , [ no] )
3998- AS_IF ( [ test x"$CARGO" = "xno"] ,
3999- AC_MSG_ERROR ( [ failed to find "cargo" for building YJIT and ZJIT together] ) )
4000- YJIT_LIBS=
4001- ZJIT_LIBS=
4002- # default when CARGO_BUILD_ARGS is not set
4003- CARGO_BUILD_ARGS="${CARGO_BUILD_ARGS:---release --features yjit,zjit}"
4004- RUST_LIB="target/${rb_rust_target_subdir}/libjit.a"
4005- RUST_JIT_SUPPORT="$ZJIT_SUPPORT"
4006- ] , [
4007- ZJIT_LIBS="target/${rb_rust_target_subdir}/libzjit.a"
4008- RUST_LIB='$(ZJIT_LIBS)'
4009- RUST_JIT_SUPPORT="zjit"
4010- ] )
4011-
3981+ ZJIT_LIBS="target/release/libzjit.a"
3982+ RUST_LIB='$(ZJIT_LIBS)'
40123983 ZJIT_OBJ='zjit.$(OBJEXT)'
40133984 JIT_OBJ='jit.$(OBJEXT)'
4014- AS_CASE ( [ "$target_os"] ,[ openbsd*] ,[
4015- # Link libc++abi (which requires libpthread) for _Unwind_* functions needed by yjit
4016- LDFLAGS="$LDFLAGS -lpthread -lc++abi"
4017- ] )
40183985 AS_IF ( [ test x"$ZJIT_SUPPORT" != "xyes" ] , [
40193986 AC_DEFINE_UNQUOTED ( ZJIT_SUPPORT , [ $ZJIT_SUPPORT] )
40203987 ] )
@@ -4023,6 +3990,41 @@ dnl TODO(alan): for commit message: note that for combo builds, when one is in d
40233990 AC_DEFINE ( USE_ZJIT , 0 )
40243991] )
40253992
3993+ # if YJIT+ZJIT release build, or any build that requires Cargo
3994+ AS_IF ( [ test x"$RUST_JIT_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+ RUST_JIT_SUPPORT=release
4011+ ] )
4012+ CARGO_BUILD_ARGS="--profile ${RUST_JIT_SUPPORT} --features ${rb_cargo_features}"
4013+ AS_IF ( [ test "${RUST_JIT_SUPPORT}" = "dev"] , [
4014+ RUST_LIB="target/debug/libjit.a"
4015+ ] , [
4016+ RUST_LIB="target/${RUST_JIT_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+
40264028dnl These variables end up in ::RbConfig::CONFIG
40274029AC_SUBST ( RUSTC ) dnl Rust compiler command
40284030AC_SUBST ( CARGO ) dnl Cargo command for Rust builds
0 commit comments