Skip to content

Commit 2f1aaeb

Browse files
committed
[GR-63253] [GR-62947] Prepare for Unchained Ruby Standalone
PullRequest: truffleruby/4503
2 parents 957a840 + 2291566 commit 2f1aaeb

File tree

6 files changed

+24
-84
lines changed

6 files changed

+24
-84
lines changed

ci.jsonnet

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,15 @@ local composition_environment = utils.add_inclusion_tracking(part_definitions, "
554554
"ruby-test-compiler-ee-stable": $.platform.linux + $.jdk.stable + $.env.jvm_ee + gate + $.use.truffleruby + $.run.test_compiler,
555555
"ruby-test-compiler-ee-latest": $.platform.linux + $.jdk.latest + $.env.jvm_ee + gate + $.use.truffleruby + $.run.test_compiler,
556556

557-
"ruby-test-svm-ce-linux-amd64-stable": $.platform.linux + $.jdk.stable + $.env.native + $.env.gdb_svm + gate + native_tests + $.env.host_inlining_log,
558-
"ruby-test-svm-ce-linux-amd64-latest": $.platform.linux + $.jdk.latest + $.env.native + $.env.gdb_svm + gate + native_tests,
559-
"ruby-test-svm-ce-darwin-amd64-stable": $.platform.darwin_amd64 + $.jdk.stable + $.env.native + $.env.gdb_svm + gate + native_tests,
560-
"ruby-test-svm-ce-darwin-amd64-latest": $.platform.darwin_amd64 + $.jdk.latest + $.env.native + $.env.gdb_svm + gate + native_tests,
561-
"ruby-test-svm-ce-darwin-aarch64-stable": $.platform.darwin_aarch64 + $.jdk.stable + $.env.native + gate + native_tests,
562-
"ruby-test-svm-ce-darwin-aarch64-latest": $.platform.darwin_aarch64 + $.jdk.latest + $.env.native + gate + native_tests,
563-
"ruby-test-svm-ee-linux-amd64": $.platform.linux + $.jdk.latest + $.env.native_ee + $.env.gdb_svm + gate + native_tests + $.env.host_inlining_log + { timelimit: "01:30:00" },
564-
"ruby-test-svm-ee-darwin-aarch64": $.platform.darwin_aarch64 + $.jdk.latest + $.env.native_ee + gate + native_tests,
565-
"ruby-test-svm-ee-aux-linux-amd64": $.platform.linux + $.jdk.latest + $.env.native_ee_aux + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
557+
"ruby-test-svm-ce-linux-amd64": $.platform.linux + $.jdk.latest + $.env.native + $.env.gdb_svm + gate + native_tests + $.env.host_inlining_log,
558+
"ruby-test-svm-ce-darwin-aarch64": $.platform.darwin_aarch64 + $.jdk.latest + $.env.native + gate + native_tests,
559+
"ruby-test-svm-ee-linux-amd64-stable": $.platform.linux + $.jdk.stable + $.env.native_ee + $.env.gdb_svm + gate + native_tests + $.env.host_inlining_log + { timelimit: "01:30:00" },
560+
"ruby-test-svm-ee-linux-amd64-latest": $.platform.linux + $.jdk.latest + $.env.native_ee + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
561+
"ruby-test-svm-ee-darwin-amd64-stable": $.platform.darwin_amd64 + $.jdk.stable + $.env.native_ee + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
562+
"ruby-test-svm-ee-darwin-amd64-latest": $.platform.darwin_amd64 + $.jdk.latest + $.env.native_ee + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
563+
"ruby-test-svm-ee-darwin-aarch64-stable": $.platform.darwin_aarch64 + $.jdk.stable + $.env.native_ee + gate + native_tests + { timelimit: "01:30:00" },
564+
"ruby-test-svm-ee-darwin-aarch64-latest": $.platform.darwin_aarch64 + $.jdk.latest + $.env.native_ee + gate + native_tests + { timelimit: "01:30:00" },
565+
"ruby-test-svm-ee-aux-linux-amd64": $.platform.linux + $.jdk.latest + $.env.native_ee_aux + $.env.gdb_svm + gate + native_tests + { timelimit: "01:30:00" },
566566
},
567567

568568
local other_rubies = {

doc/user/truffleruby-additions.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ TruffleRuby provides these non-standard methods and classes that provide additio
3838

3939
* `TruffleRuby.full_memory_barrier` ensures lack of reordering of loads or stores before the barrier with loads or stores after the barrier.
4040

41-
* `TruffleRuby.graalvm_home` returns the GraalVM home or `nil` if running outside of GraalVM (e.g., Native standalone).
42-
4341
* `TruffleRuby.synchronized(object) { }` will run the block while holding an implicit lock per object instance.
4442

4543
### Atomic References

spec/truffle/launcher_spec.rb

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ def should_print_full_java_command(options, env: {})
341341
out.should include("--jvm")
342342
end
343343

344-
if TruffleRuby.graalvm_home or !TruffleRuby.native?
345-
# These options are only shown in GraalVM, they are not available in a native standalone
344+
unless TruffleRuby.native?
345+
# This is only shown in JVM standalones
346346
out.should include("--polyglot")
347347
end
348348
end
@@ -417,53 +417,4 @@ def should_print_full_java_command(options, env: {})
417417
out.should == 'bar'
418418
end
419419
end
420-
421-
guard -> {
422-
# GraalVM with both --jvm and --native
423-
defined?(::TruffleRuby) and TruffleRuby.graalvm_home and TruffleRuby.native?
424-
} do
425-
describe "runtime configuration flags" do
426-
before :each do
427-
@trufflerubyopt = ENV['TRUFFLERUBYOPT']
428-
# remove --native/--jvm from $TRUFFLERUBYOPT as they can conflict with command line arguments for these specs
429-
ENV['TRUFFLERUBYOPT'] = @trufflerubyopt.to_s.gsub(/--(native|jvm)\b/, '')
430-
end
431-
432-
after :each do
433-
ENV['TRUFFLERUBYOPT'] = @trufflerubyopt
434-
end
435-
436-
['RUBYOPT', 'TRUFFLERUBYOPT'].each do |var|
437-
it "should recognize ruby --vm options in #{var} when switching to JVM" do
438-
env = { var => "--jvm #{@ignore_jvm_thread_warnings} --vm.Dfoo=bar" } # ignoring the original value of RUBYOPT/TRUFFLERUBYOPT on purpose here
439-
out = ruby_exe('puts RUBY_DESCRIPTION; puts Truffle::System.get_java_property("foo")', env: env, args: @redirect)
440-
check_status_and_empty_stderr
441-
out = out.lines.map(&:chomp)
442-
out[0].should =~ /(GraalVM CE|Oracle GraalVM) JVM/
443-
out[1].should == 'bar'
444-
end
445-
end
446-
447-
it "uses --native by default" do
448-
out = ruby_exe(nil, options: "--version", args: @redirect)
449-
check_status_and_empty_stderr
450-
out.should =~ /(GraalVM CE|Oracle GraalVM) Native/
451-
end
452-
453-
it "switches to JVM with --jvm as a Ruby argument" do
454-
out = ruby_exe(nil, options: "--jvm #{@ignore_jvm_thread_warnings} --version", args: @redirect)
455-
check_status_and_empty_stderr
456-
out.should =~ /(GraalVM CE|Oracle GraalVM) JVM/
457-
end
458-
459-
it "keeps --jvm as an application argument if given as an application argument" do
460-
script = fixture(__FILE__, "argv.rb")
461-
out = ruby_exe(nil, options: "-v", args: "#{script} --jvm 1 2 #{@redirect}")
462-
check_status_and_empty_stderr
463-
out = out.lines.map(&:chomp)
464-
out[0].should =~ /(GraalVM CE|Oracle GraalVM) Native/
465-
out.should.include?('["--jvm", "1", "2"]')
466-
end
467-
end
468-
end
469420
end

src/main/java/org/truffleruby/RubyLanguage.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,15 @@ private TruffleFile searchRubyHome(Env env) {
812812
}
813813
}
814814

815-
TruffleFile homeResource;
815+
final TruffleFile homeResource;
816+
TruffleFile homeResourceRelative;
816817
try {
817-
var homeResourceRelative = env.getInternalResource("ruby-home");
818-
homeResource = homeResourceRelative == null ? null : homeResourceRelative.getCanonicalFile();
818+
homeResourceRelative = env.getInternalResource("ruby-home");
819+
if (homeResourceRelative != null && homeResourceRelative.exists()) {
820+
homeResource = homeResourceRelative.getCanonicalFile();
821+
} else {
822+
homeResource = null;
823+
}
819824
} catch (IOException e) {
820825
throw CompilerDirectives.shouldNotReachHere(e);
821826
}
@@ -828,8 +833,8 @@ private TruffleFile searchRubyHome(Env env) {
828833
}
829834

830835
throw new Error("Could not find TruffleRuby's home - not possible to parse Ruby code" + String.format(
831-
" (Truffle-reported home %s and internal resource %s do not look like TruffleRuby's home).",
832-
truffleReported, homeResource));
836+
" (Truffle-reported home %s and internal resource %s (%s) do not look like TruffleRuby's home).",
837+
truffleReported, homeResourceRelative, homeResource));
833838
}
834839

835840
private boolean isRubyHome(TruffleFile path) {

src/main/java/org/truffleruby/extra/TruffleRubyNodes.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.oracle.truffle.api.nodes.Node;
1818
import com.oracle.truffle.api.object.DynamicObjectLibrary;
1919
import com.oracle.truffle.api.profiles.InlinedBranchProfile;
20-
import com.oracle.truffle.api.strings.TruffleString;
2120
import org.truffleruby.Layouts;
2221
import org.truffleruby.RubyContext;
2322
import org.truffleruby.RubyLanguage;
@@ -26,7 +25,6 @@
2625
import org.truffleruby.builtins.CoreMethodArrayArgumentsNode;
2726
import org.truffleruby.builtins.CoreMethodNode;
2827
import org.truffleruby.annotations.CoreModule;
29-
import org.truffleruby.core.encoding.Encodings;
3028
import org.truffleruby.core.mutex.MutexOperations;
3129
import org.truffleruby.core.proc.RubyProc;
3230

@@ -48,21 +46,9 @@ public abstract class TruffleRubyNodes {
4846
public abstract static class GraalvmHomeNode extends CoreMethodArrayArgumentsNode {
4947

5048
@Specialization
51-
Object graalvmHome(
52-
@Cached TruffleString.FromJavaStringNode fromJavaStringNode) {
53-
String value = getProperty("org.graalvm.home");
54-
if (value == null) {
55-
return nil;
56-
} else {
57-
return createString(fromJavaStringNode, value, Encodings.UTF_8);
58-
}
59-
}
60-
61-
@TruffleBoundary
62-
private static String getProperty(String key) {
63-
return System.getProperty(key);
49+
Object graalvmHome() {
50+
return nil;
6451
}
65-
6652
}
6753

6854
@CoreMethod(names = "jit?", onSingleton = true)

tool/jt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ def lint(*args)
31843184
command_format(changed['.java']) if changed['.java']
31853185
shellcheck if changed['.sh'] or changed['.inc']
31863186

3187-
mx 'verify-ci' if changed['.py']
3187+
mx 'verify-ci' if changed['.py'] and !ENV['JT_IMPORTS_DONT_ASK']
31883188

31893189
check_abi(fail: !compare_to)
31903190

0 commit comments

Comments
 (0)