diff --git a/ruby.c b/ruby.c index f400a3d531..5a78a7c764 100644 --- a/ruby.c +++ b/ruby.c @@ -2354,7 +2354,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) if (!FEATURE_USED_P(opt->features, yjit) && env_var_truthy("RUBY_YJIT_ENABLE")) { FEATURE_SET(opt->features, FEATURE_BIT(yjit)); } -#elif USE_ZJIT +#endif +#if USE_ZJIT if (!FEATURE_USED_P(opt->features, zjit) && env_var_truthy("RUBY_ZJIT_ENABLE")) { FEATURE_SET(opt->features, FEATURE_BIT(zjit)); } diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 58fc9ba639..e3880a2828 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -18,6 +18,14 @@ class TestZJIT < Test::Unit::TestCase RUBY end + def test_enable_through_env + child_env = {'RUBY_YJIT_ENABLE' => nil, 'RUBY_ZJIT_ENABLE' => '1'} + assert_in_out_err([child_env, '-v'], '') do |stdout, stderr| + assert_includes(stdout.first, '+ZJIT') + assert_equal([], stderr) + end + end + def test_call_itself assert_compiles '42', <<~RUBY, call_threshold: 2 def test = 42.itself