I was testing YJIT in a Rails app with RUBYOPT="--yjit --yjit-exec-mem-size=32". I saw some weird issues around Rails view caching, so I attempted to temporarily disable YJIT by removing --yjit and leaving the tuning options in place (RUBYOPT="--yjit-exec-mem-size=32"). However, YJIT remained enabled until I also removed --yjit-exec-mem-size=32.
From the code, this appears to be intentional. setup_yjit_options returns true if any of the --yjit-* options are provided:
elseif(strcmp("yjit",s)==0||setup_yjit_options(s,&opt->yjit)){#if USE_MJIT
FEATURE_SET(opt->features,FEATURE_BIT(yjit));#else
rb_warn("Ruby was built without JIT support");#endif
}
I think only enabling on explicit --jit/--yjit/--mjit is better because it's more intuitive.
If e.g. --yjit-exec-mem-size=32 is in RUBYOPT it seems unexpected that it would enable YJIT without any --yjit anywhere.
For what it's worth, I would expect --yjit-* options not to turn on YJIT. I agree that it's surprising, I would expect only --yjit or RUBY_YJIT_ENABLE=1 to actually enable it.