Skip to content

Commit 4188b26

Browse files
committed
[GR-48237] Backport for 23.1 PRs #3991 and #3993
PullRequest: truffleruby/3996
2 parents bf1b40d + 40a4c69 commit 4188b26

File tree

9 files changed

+98
-17
lines changed

9 files changed

+98
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
New features:
44

55
* Updated to Ruby 3.2.2 (#3039, @eregon, @andrykonchin).
6-
* TruffleRuby Native on Oracle GraalVM on Linux now uses the G1 garbage collector which is much faster.
6+
* TruffleRuby Native on Oracle GraalVM on Linux now uses the G1 garbage collector which is much faster (@eregon).
77

88
Bug fixes:
99

@@ -53,7 +53,8 @@ Performance:
5353

5454
Changes:
5555

56-
* The TruffleRuby `ScriptEngine` implementation is removed in favor of the generic [ScriptEngine](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md#compatibility-with-jsr-223-scriptengine) in GraalVM docs.
56+
* `gu install $LANGUAGE` is replaced by `truffleruby-polyglot-get $LANGUAGE`, available in the TruffleRuby JVM standalone (@eregon).
57+
* The TruffleRuby `ScriptEngine` implementation is removed in favor of the generic [ScriptEngine](https://github.com/oracle/graal/blob/master/docs/reference-manual/embedding/embed-languages.md#compatibility-with-jsr-223-scriptengine) in GraalVM docs (@eregon).
5758

5859
Memory Footprint:
5960

ci.jsonnet

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ local part_definitions = {
361361
test_gems: { run+: jt(["test", "gems"]) },
362362
test_compiler: { run+: jt(["test", "compiler"]) },
363363
test_ecosystem: {
364-
run+: [["node", "--version"]] + jt(["test", "ecosystem"]),
364+
packages+: {
365+
maven: "==3.3.9",
366+
},
367+
run+: [["node", "--version"]] +
368+
jt(["test", "ecosystem"]),
365369
},
366370

367371
test_cexts: {

common.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
55
],
66

7-
"mx_version": "6.45.0",
7+
"mx_version": "6.46.1",
88

99
"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
1010
"jdks": {
@@ -35,12 +35,12 @@
3535
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },
3636

3737
"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
38-
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14", "platformspecific": true },
39-
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14-debug", "platformspecific": true },
40-
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b14-sulong", "platformspecific": true },
41-
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14", "platformspecific": true },
42-
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14-debug", "platformspecific": true },
43-
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b14-sulong", "platformspecific": true },
38+
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15", "platformspecific": true },
39+
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
40+
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },
41+
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15", "platformspecific": true },
42+
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-debug", "platformspecific": true },
43+
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21+35-jvmci-23.1-b15-sulong", "platformspecific": true },
4444

4545
"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
4646
},

mx.truffleruby/mx_truffleruby.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import mx
1818
import mx_gate
19+
import mx_sdk
1920
import mx_sdk_vm
2021
import mx_subst
2122
import mx_spotbugs
@@ -221,6 +222,10 @@ def verify_ci(args):
221222
"""Verify CI configuration"""
222223
mx.verify_ci(args, mx.suite('truffle'), _suite, ['common.json', 'ci/common.jsonnet'])
223224

225+
def ruby_maven_deploy_public(args):
226+
mx.command_function('build')([])
227+
licenses = ['EPL-2.0', 'PSF-License', 'GPLv2-CPE', 'ICU,GPLv2', 'BSD-simplified', 'BSD-new', 'UPL', 'MIT']
228+
mx_sdk.maven_deploy_public(args, licenses=licenses, deploy_snapshots=False)
224229

225230
mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage(
226231
suite=_suite,
@@ -294,8 +299,8 @@ def verify_ci(args):
294299
library_configs=[
295300
mx_sdk_vm.LanguageLibraryConfig(
296301
destination='lib/<lib:rubyvm>',
297-
launchers=['bin/<exe:ruby>', 'bin/<exe:truffleruby>'],
298-
jar_distributions=['truffleruby:TRUFFLERUBY-LAUNCHER'],
302+
launchers=['bin/<exe:ruby>', 'bin/<exe:truffleruby>', 'bin/<exe:truffleruby-polyglot-get>'],
303+
jar_distributions=['truffleruby:TRUFFLERUBY-LAUNCHER', 'sdk:MAVEN_DOWNLOADER'],
299304
main_class='org.truffleruby.launcher.RubyLauncher',
300305
build_args=[
301306
'-H:+DetectUserDirectoriesInImageHeap',
@@ -329,4 +334,5 @@ def verify_ci(args):
329334
'ruby_spotbugs': [ruby_spotbugs, ''],
330335
'verify-ci': [verify_ci, '[options]'],
331336
'ruby_jacoco_args': [ruby_jacoco_args, ''],
337+
'ruby_maven_deploy_public': [ruby_maven_deploy_public, ''],
332338
})

mx.truffleruby/suite.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
{
2121
"name": "regex",
2222
"subdir": True,
23-
"version": "621ba026a108b8320e5cdadf6150c2fa30b1339a",
23+
"version": "39e46e0bc2bd49cb52f3c98944253d59d76a21b0",
2424
"urls": [
2525
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
2626
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -29,7 +29,7 @@
2929
{
3030
"name": "sulong",
3131
"subdir": True,
32-
"version": "621ba026a108b8320e5cdadf6150c2fa30b1339a",
32+
"version": "39e46e0bc2bd49cb52f3c98944253d59d76a21b0",
3333
"urls": [
3434
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
3535
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
@@ -307,12 +307,13 @@
307307
"org.truffleruby.launcher": {
308308
"dir": "src/launcher",
309309
"sourceDirs": ["java"],
310-
"requires": ["java.logging"],
310+
"requires": ["java.logging", "java.xml"],
311311
"dependencies": [
312312
"truffleruby:TRUFFLERUBY-ANNOTATIONS",
313313
"truffleruby:TRUFFLERUBY-SHARED",
314314
"sdk:POLYGLOT",
315315
"sdk:LAUNCHER_COMMON",
316+
"sdk:MAVEN_DOWNLOADER",
316317
],
317318
"jacoco": "include",
318319
"javaCompliance": "17+",
@@ -566,6 +567,7 @@
566567
"truffleruby:TRUFFLERUBY-SHARED",
567568
"sdk:POLYGLOT",
568569
"sdk:LAUNCHER_COMMON",
570+
"sdk:MAVEN_DOWNLOADER",
569571
],
570572
"description": "TruffleRuby Launcher",
571573
"license": ["EPL-2.0"],

spec/truffle/launcher_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def check_status_or_print(stdout_and_stderr)
8080
it "all launchers are in @launchers" do
8181
known = @launchers.keys.map(&:to_s).sort
8282
actual = Dir.children(File.dirname(RbConfig.ruby)).sort
83-
actual.delete('truffleruby.sh')
83+
actual.delete('truffleruby-polyglot-get')
8484
actual.should == known
8585
end
8686

src/launcher/java/org/truffleruby/launcher/RubyLauncher.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.ProcessBuilder.Redirect;
2222

2323
import org.graalvm.launcher.AbstractLanguageLauncher;
24+
import org.graalvm.maven.downloader.Main;
2425
import org.graalvm.nativeimage.ProcessProperties;
2526
import org.graalvm.options.OptionCategory;
2627
import org.graalvm.polyglot.Context;
@@ -38,10 +39,40 @@ public class RubyLauncher extends AbstractLanguageLauncher {
3839
private String implementationName = null;
3940
private boolean helpOptionUsed = false; // Any --help* option
4041

42+
/** NOTE: not actually used by thin launchers. The first method called with the arguments is
43+
* {@link #preprocessArguments}. */
4144
public static void main(String[] args) {
4245
new RubyLauncher().launch(args);
4346
}
4447

48+
private static void trufflerubyPolyglotGet(List<String> originalArgs) {
49+
String rubyHome = getPropertyOrFail("org.graalvm.language.ruby.home");
50+
String outputDir = rubyHome + "/modules";
51+
List<String> args = new ArrayList<>();
52+
args.add("-o");
53+
args.add(outputDir);
54+
args.add("-v");
55+
args.add(getPropertyOrFail("org.graalvm.version"));
56+
if (originalArgs.size() == 1 && !originalArgs.get(0).startsWith("-")) {
57+
args.add("-a");
58+
}
59+
args.addAll(originalArgs);
60+
try {
61+
Main.main(args.toArray(CommandLineOptions.EMPTY_STRING_ARRAY));
62+
} catch (Exception e) {
63+
throw new Error(e);
64+
}
65+
System.exit(0);
66+
}
67+
68+
private static String getPropertyOrFail(String property) {
69+
String value = System.getProperty(property);
70+
if (value == null) {
71+
throw new UnsupportedOperationException("Expected system property " + property + " to be set");
72+
}
73+
return value;
74+
}
75+
4576
@Override
4677
protected String getLanguageId() {
4778
return TruffleRuby.LANGUAGE_ID;
@@ -65,6 +96,15 @@ protected void printVersion() {
6596

6697
@Override
6798
protected List<String> preprocessArguments(List<String> args, Map<String, String> polyglotOptions) {
99+
String launcherName = System.getProperty("org.graalvm.launcher.executablename", "miniruby");
100+
if (launcherName.endsWith("truffleruby-polyglot-get")) {
101+
if (isAOT()) {
102+
throw abort("truffleruby-polyglot-get is not available for the native standalone");
103+
} else {
104+
trufflerubyPolyglotGet(args);
105+
}
106+
}
107+
68108
// Set default options for the launcher which don't match the OptionKey's default.
69109
// These options can still be overridden if set explicitly.
70110
polyglotOptions.put(OptionsCatalog.EMBEDDED.getName(), "false");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
source test/truffle/common.sh.inc
4+
5+
# Clone Graal.js repository
6+
jt mx --dy /vm,/graal-js sversions
7+
8+
jt mx --env jvm-js ruby_maven_deploy_public
9+
maven_repo="$(dirname "$(pwd)")/graal/sdk/mxbuild/jdk21/mx.sdk/public-maven-repo"
10+
if [ ! -d "$maven_repo" ]; then
11+
echo "Maven repo not at $maven_repo ?"
12+
exit 2
13+
fi
14+
15+
jt build --env jvm-ce
16+
17+
standalone=$(jt -q mx --quiet --env jvm-ce standalone-home --type=jvm ruby)
18+
19+
export PATH="$standalone/bin:$PATH"
20+
21+
env org.graalvm.maven.downloader.repository="file://$maven_repo" truffleruby-polyglot-get js-community
22+
23+
out=$(ruby --polyglot -e 'p Polyglot.eval("js", "1/2")')
24+
if [ "$out" != "0.5" ]; then
25+
echo "Wrong output: >>$out<<"
26+
exit 1
27+
fi

tool/jt.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,8 @@ def test(*args)
11831183
when 'unit', 'unittest' then test_unit(*rest)
11841184
when 'tck'
11851185
puts bold 'NOTE: You need `jt mx build` before running `jt test tck` to build the relevant test distributions'
1186-
mx 'tck', *rest
1186+
# GR-48568 for why DisableClassPathIsolation is needed
1187+
mx 'tck', '-Dpolyglotimpl.DisableClassPathIsolation=true', *rest
11871188
else
11881189
if File.expand_path(path, TRUFFLERUBY_DIR).start_with?("#{TRUFFLERUBY_DIR}/test")
11891190
test_mri(*args)

0 commit comments

Comments
 (0)