Let ZJIT and YJIT disable each other

This commit is contained in:
Takashi Kokubun 2025-02-12 17:23:58 -08:00
parent b0739cd1c1
commit bc443eef7a
Notes: git 2025-04-18 13:48:47 +00:00

View File

@ -3859,40 +3859,40 @@ AC_SUBST(INSTALL_STATIC_LIBRARY)
[begin]_group "JIT section" && {
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix
dnl check if rustc is recent enough to build YJIT (rustc >= 1.58.0)
YJIT_RUSTC_OK=no
dnl check if rustc is recent enough to build YJIT/ZJIT (rustc >= 1.58.0)
JIT_RUSTC_OK=no
AS_IF([test "$RUSTC" != "no"],
AC_MSG_CHECKING([whether ${RUSTC} works for YJIT])
YJIT_TARGET_ARCH=
AC_MSG_CHECKING([whether ${RUSTC} works for YJIT/ZJIT])
JIT_TARGET_ARCH=
AS_CASE(["$target_cpu"],
[arm64|aarch64], [YJIT_TARGET_ARCH=aarch64],
[x86_64], [YJIT_TARGET_ARCH=x86_64],
[arm64|aarch64], [JIT_TARGET_ARCH=aarch64],
[x86_64], [JIT_TARGET_ARCH=x86_64],
)
dnl Fails in case rustc target doesn't match ruby target.
dnl Can happen on Rosetta, for example.
AS_IF([echo "#[cfg(target_arch = \"$YJIT_TARGET_ARCH\")] fn main() { let x = 1; format!(\"{x}\"); }" |
AS_IF([echo "#[cfg(target_arch = \"$JIT_TARGET_ARCH\")] fn main() { let x = 1; format!(\"{x}\"); }" |
$RUSTC - --emit asm=/dev/null 2>/dev/null],
[YJIT_RUSTC_OK=yes]
[JIT_RUSTC_OK=yes]
)
AC_MSG_RESULT($YJIT_RUSTC_OK)
AC_MSG_RESULT($JIT_RUSTC_OK)
)
dnl check if we can build YJIT on this target platform
dnl check if we can build YJIT/ZJIT on this target platform
dnl we can't easily cross-compile with rustc so we don't support that
YJIT_TARGET_OK=no
JIT_TARGET_OK=no
AS_IF([test "$cross_compiling" = no],
AS_CASE(["$target_cpu-$target_os"],
[*android*], [
YJIT_TARGET_OK=no
JIT_TARGET_OK=no
],
[arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [
YJIT_TARGET_OK=yes
JIT_TARGET_OK=yes
],
[arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [
YJIT_TARGET_OK=yes
JIT_TARGET_OK=yes
],
[arm64-*bsd*|aarch64-*bsd*|x86_64-*bsd*], [
YJIT_TARGET_OK=yes
JIT_TARGET_OK=yes
]
)
)
@ -3902,8 +3902,8 @@ AC_ARG_ENABLE(yjit,
AS_HELP_STRING([--enable-yjit],
[enable in-process JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.58.0+ is available]),
[YJIT_SUPPORT=$enableval],
[AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"],
[yes:yes], [
[AS_CASE(["$JIT_TARGET_OK:$JIT_RUSTC_OK:$ZJIT_SUPPORT"],
[yes:yes:no], [
YJIT_SUPPORT=yes
],
[YJIT_SUPPORT=no]
@ -3915,8 +3915,8 @@ AC_ARG_ENABLE(zjit,
AS_HELP_STRING([--enable-zjit],
[enable in-process JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.58.0+ is available]),
[ZJIT_SUPPORT=$enableval],
[AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"],
[yes:yes], [
[AS_CASE(["$JIT_TARGET_OK:$JIT_RUSTC_OK:$YJIT_SUPPORT"],
[yes:yes:no], [
ZJIT_SUPPORT=yes
],
[ZJIT_SUPPORT=no]
@ -3931,6 +3931,9 @@ AS_CASE(["${YJIT_SUPPORT}"],
AS_IF([test x"$RUSTC" = "xno"],
AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install])
)
AS_IF([test x"$ZJIT_SUPPORT" != "xno"],
AC_MSG_ERROR([YJIT cannot be enabled when ZJIT is enabled])
)
AS_CASE(["${YJIT_SUPPORT}"],
[yes], [
@ -3979,6 +3982,9 @@ AS_CASE(["${ZJIT_SUPPORT}"],
AS_IF([test x"$RUSTC" = "xno"],
AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install])
)
AS_IF([test x"$YJIT_SUPPORT" != "xno"],
AC_MSG_ERROR([ZJIT cannot be enabled when YJIT is enabled])
)
AS_CASE(["${ZJIT_SUPPORT}"],
[yes], [