ZJIT: Fix assert failure on JIT combo build

Previously, when `./configure --enable-yjit=dev --enable-zjit` JIT_DESCRIPTION was
defined to be "ZJIT", but when running with `--yjit`, ruby_set_yjit_description()
calls `define_ruby_description("+YJIT dev")`, which is longer than the
following assertion expects:

    RUBY_ASSERT(n <= ruby_description_opt_point + (int)rb_strlen_lit(JIT_DESCRIPTION));

Use the concatenation of the two strings -- the contents of the string
is never used. Minimize the scope of the macro, too.
This commit is contained in:
Alan Wu 2025-08-12 19:01:59 -04:00
parent fdb831fdfc
commit b080fcd3cd

View file

@ -72,11 +72,6 @@ const int ruby_api_version[] = {
#else #else
#define ZJIT_DESCRIPTION " +ZJIT" #define ZJIT_DESCRIPTION " +ZJIT"
#endif #endif
#if USE_ZJIT
#define JIT_DESCRIPTION ZJIT_DESCRIPTION
#else
#define JIT_DESCRIPTION YJIT_DESCRIPTION
#endif
#if USE_MODULAR_GC #if USE_MODULAR_GC
#define GC_DESCRIPTION " +GC" #define GC_DESCRIPTION " +GC"
#else #else
@ -207,6 +202,8 @@ rb_ruby_default_parser_set(ruby_default_parser_enum parser)
static void static void
define_ruby_description(const char *const jit_opt) define_ruby_description(const char *const jit_opt)
{ {
#define JIT_DESCRIPTION YJIT_DESCRIPTION ZJIT_DESCRIPTION
static char desc[ static char desc[
sizeof(ruby_description) sizeof(ruby_description)
+ rb_strlen_lit(JIT_DESCRIPTION) + rb_strlen_lit(JIT_DESCRIPTION)
@ -248,6 +245,7 @@ define_ruby_description(const char *const jit_opt)
* The full ruby version string, like <tt>ruby -v</tt> prints * The full ruby version string, like <tt>ruby -v</tt> prints
*/ */
rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description); rb_define_const(mRuby, "DESCRIPTION", /* MKSTR(description) */ description);
#undef JIT_DESCRIPTION
} }
void void