When YJIT is not built, hide options and use MJIT for --jit

YJIT is now a build-time opt-in so on platforms that YJIT could support
it could still be unavailable due to user discretion. Use MJIT for --jit
and don't display YJIT related command line options in --help when YJIT
is not included in the build.
This commit is contained in:
Alan Wu 2022-06-23 18:12:25 -04:00
parent 1ccdb1a251
commit eb1a84a9c3

12
ruby.c
View File

@ -111,7 +111,7 @@ void rb_warning_category_update(unsigned int mask, unsigned int bits);
enum feature_flag_bits { enum feature_flag_bits {
EACH_FEATURES(DEFINE_FEATURE, COMMA), EACH_FEATURES(DEFINE_FEATURE, COMMA),
feature_debug_flag_first, feature_debug_flag_first,
#if defined(MJIT_FORCE_ENABLE) || !YJIT_SUPPORTED_P #if defined(MJIT_FORCE_ENABLE) || !YJIT_BUILD
DEFINE_FEATURE(jit) = feature_mjit, DEFINE_FEATURE(jit) = feature_mjit,
#else #else
DEFINE_FEATURE(jit) = feature_yjit, DEFINE_FEATURE(jit) = feature_yjit,
@ -247,7 +247,7 @@ usage(const char *name, int help, int highlight, int columns)
#define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc) #define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc)
#if YJIT_SUPPORTED_P #if YJIT_BUILD
# define PLATFORM_JIT_OPTION "--yjit" # define PLATFORM_JIT_OPTION "--yjit"
#else #else
# define PLATFORM_JIT_OPTION "--mjit" # define PLATFORM_JIT_OPTION "--mjit"
@ -277,7 +277,7 @@ usage(const char *name, int help, int highlight, int columns)
#if USE_MJIT #if USE_MJIT
M("--mjit", "", "enable C compiler-based JIT compiler (experimental)"), M("--mjit", "", "enable C compiler-based JIT compiler (experimental)"),
#endif #endif
#if YJIT_SUPPORTED_P #if YJIT_BUILD
M("--yjit", "", "enable in-process JIT compiler (experimental)"), M("--yjit", "", "enable in-process JIT compiler (experimental)"),
#endif #endif
M("-h", "", "show this message, --help for more info"), M("-h", "", "show this message, --help for more info"),
@ -311,7 +311,7 @@ usage(const char *name, int help, int highlight, int columns)
#if USE_MJIT #if USE_MJIT
M("mjit", "", "C compiler-based JIT compiler (default: disabled)"), M("mjit", "", "C compiler-based JIT compiler (default: disabled)"),
#endif #endif
#if YJIT_SUPPORTED_P #if YJIT_BUILD
M("yjit", "", "in-process JIT compiler (default: disabled)"), M("yjit", "", "in-process JIT compiler (default: disabled)"),
#endif #endif
}; };
@ -322,7 +322,7 @@ usage(const char *name, int help, int highlight, int columns)
#if USE_MJIT #if USE_MJIT
extern const struct ruby_opt_message mjit_option_messages[]; extern const struct ruby_opt_message mjit_option_messages[];
#endif #endif
#if YJIT_SUPPORTED_P #if YJIT_BUILD
static const struct ruby_opt_message yjit_options[] = { static const struct ruby_opt_message yjit_options[] = {
#if YJIT_STATS #if YJIT_STATS
M("--yjit-stats", "", "Enable collecting YJIT statistics"), M("--yjit-stats", "", "Enable collecting YJIT statistics"),
@ -364,7 +364,7 @@ usage(const char *name, int help, int highlight, int columns)
for (i = 0; mjit_option_messages[i].str; ++i) for (i = 0; mjit_option_messages[i].str; ++i)
SHOW(mjit_option_messages[i]); SHOW(mjit_option_messages[i]);
#endif #endif
#if YJIT_SUPPORTED_P #if YJIT_BUILD
printf("%s""YJIT options (experimental):%s\n", sb, se); printf("%s""YJIT options (experimental):%s\n", sb, se);
for (i = 0; i < numberof(yjit_options); ++i) for (i = 0; i < numberof(yjit_options); ++i)
SHOW(yjit_options[i]); SHOW(yjit_options[i]);