From efed45966b3aac728bbbe2cfc7ec937b7712c146 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Thu, 7 Oct 2021 18:05:10 -0400 Subject: Show +YJIT in version string and RUBY_DESCRIPTION There might be code out there that expect `ruby -v` to print only one line. Since MJIT shows +JIT in `ruby -v` and RUBY_DESCRIPTION, let's show +YJIT. The crash report doesn't show anything about MJIT, so adjust the test. The "test_ruby_version" test was unaware of RUBY_YJIT_ENABLE and so was failing when the variable is set and inherited into the children processes it spawns. Explicitly unset the variable in the test. --- version.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'version.c') diff --git a/version.c b/version.c index e8bf51d2dc..5bfc663b4e 100644 --- a/version.c +++ b/version.c @@ -43,6 +43,7 @@ const char ruby_platform[] = RUBY_PLATFORM; const int ruby_patchlevel = RUBY_PATCHLEVEL; const char ruby_description[] = RUBY_DESCRIPTION_WITH(""); static const char ruby_description_with_jit[] = RUBY_DESCRIPTION_WITH(" +JIT"); +static const char ruby_description_with_yjit[] = RUBY_DESCRIPTION_WITH(" +YJIT"); const char ruby_copyright[] = RUBY_COPYRIGHT; const char ruby_engine[] = "ruby"; @@ -105,6 +106,9 @@ Init_ruby_description(void) if (MJIT_OPTS_ON) { description = MKSTR(description_with_jit); } + else if (rb_yjit_enabled_p()) { + description = MKSTR(description_with_yjit); + } else { description = MKSTR(description); } @@ -121,13 +125,13 @@ ruby_show_version(void) if (MJIT_OPTS_ON) { PRINT(description_with_jit); } + else if (rb_yjit_enabled_p()) { + PRINT(description_with_yjit); + } else { PRINT(description); } - if (rb_yjit_enabled_p()) { - fputs("YJIT is enabled\n", stdout); - } #ifdef RUBY_LAST_COMMIT_TITLE fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout); #endif -- cgit v1.2.3