summaryrefslogtreecommitdiff
path: root/version.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-10-07 18:05:10 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:43 -0400
commitefed45966b3aac728bbbe2cfc7ec937b7712c146 (patch)
treefc6066abd18d13146e5c848f49127699b7f476da /version.c
parent13261f00fbe844261f364d51fc97318758d87c2b (diff)
downloadruby-efed45966b3aac728bbbe2cfc7ec937b7712c146.tar.gz
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.
Diffstat (limited to 'version.c')
-rw-r--r--version.c10
1 files changed, 7 insertions, 3 deletions
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