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" && { [begin]_group "JIT section" && {
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix 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) dnl check if rustc is recent enough to build YJIT/ZJIT (rustc >= 1.58.0)
YJIT_RUSTC_OK=no JIT_RUSTC_OK=no
AS_IF([test "$RUSTC" != "no"], AS_IF([test "$RUSTC" != "no"],
AC_MSG_CHECKING([whether ${RUSTC} works for YJIT]) AC_MSG_CHECKING([whether ${RUSTC} works for YJIT/ZJIT])
YJIT_TARGET_ARCH= JIT_TARGET_ARCH=
AS_CASE(["$target_cpu"], AS_CASE(["$target_cpu"],
[arm64|aarch64], [YJIT_TARGET_ARCH=aarch64], [arm64|aarch64], [JIT_TARGET_ARCH=aarch64],
[x86_64], [YJIT_TARGET_ARCH=x86_64], [x86_64], [JIT_TARGET_ARCH=x86_64],
) )
dnl Fails in case rustc target doesn't match ruby target. dnl Fails in case rustc target doesn't match ruby target.
dnl Can happen on Rosetta, for example. 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], $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 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_IF([test "$cross_compiling" = no],
AS_CASE(["$target_cpu-$target_os"], AS_CASE(["$target_cpu-$target_os"],
[*android*], [ [*android*], [
YJIT_TARGET_OK=no JIT_TARGET_OK=no
], ],
[arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [ [arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [
YJIT_TARGET_OK=yes JIT_TARGET_OK=yes
], ],
[arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [ [arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [
YJIT_TARGET_OK=yes JIT_TARGET_OK=yes
], ],
[arm64-*bsd*|aarch64-*bsd*|x86_64-*bsd*], [ [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], 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]), [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], [YJIT_SUPPORT=$enableval],
[AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"], [AS_CASE(["$JIT_TARGET_OK:$JIT_RUSTC_OK:$ZJIT_SUPPORT"],
[yes:yes], [ [yes:yes:no], [
YJIT_SUPPORT=yes YJIT_SUPPORT=yes
], ],
[YJIT_SUPPORT=no] [YJIT_SUPPORT=no]
@ -3915,8 +3915,8 @@ AC_ARG_ENABLE(zjit,
AS_HELP_STRING([--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]), [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], [ZJIT_SUPPORT=$enableval],
[AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"], [AS_CASE(["$JIT_TARGET_OK:$JIT_RUSTC_OK:$YJIT_SUPPORT"],
[yes:yes], [ [yes:yes:no], [
ZJIT_SUPPORT=yes ZJIT_SUPPORT=yes
], ],
[ZJIT_SUPPORT=no] [ZJIT_SUPPORT=no]
@ -3931,6 +3931,9 @@ AS_CASE(["${YJIT_SUPPORT}"],
AS_IF([test x"$RUSTC" = "xno"], AS_IF([test x"$RUSTC" = "xno"],
AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install]) 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}"], AS_CASE(["${YJIT_SUPPORT}"],
[yes], [ [yes], [
@ -3979,6 +3982,9 @@ AS_CASE(["${ZJIT_SUPPORT}"],
AS_IF([test x"$RUSTC" = "xno"], AS_IF([test x"$RUSTC" = "xno"],
AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install]) 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}"], AS_CASE(["${ZJIT_SUPPORT}"],
[yes], [ [yes], [