Skip to content

Commit

Permalink
[GR-48237] Backport for 23.1 PRs #3991 and #3993
Browse files Browse the repository at this point in the history
PullRequest: truffleruby/3996
  • Loading branch information
andrykonchin committed Sep 11, 2023
2 parents bf1b40d + 40a4c69 commit 4188b26
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 17 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
New features:

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

Bug fixes:

Expand Down Expand Up @@ -53,7 +53,8 @@ Performance:

Changes:

* 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.
* `gu install $LANGUAGE` is replaced by `truffleruby-polyglot-get $LANGUAGE`, available in the TruffleRuby JVM standalone (@eregon).
* 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).

Memory Footprint:

Expand Down
6 changes: 5 additions & 1 deletion ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ local part_definitions = {
test_gems: { run+: jt(["test", "gems"]) },
test_compiler: { run+: jt(["test", "compiler"]) },
test_ecosystem: {
run+: [["node", "--version"]] + jt(["test", "ecosystem"]),
packages+: {
maven: "==3.3.9",
},
run+: [["node", "--version"]] +
jt(["test", "ecosystem"]),
},

test_cexts: {
Expand Down
14 changes: 7 additions & 7 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "6.45.0",
"mx_version": "6.46.1",

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

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

"oraclejdk22": {"name": "jpg-jdk", "version": "22", "build_id": "2", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]}
},
Expand Down
10 changes: 8 additions & 2 deletions mx.truffleruby/mx_truffleruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import mx
import mx_gate
import mx_sdk
import mx_sdk_vm
import mx_subst
import mx_spotbugs
Expand Down Expand Up @@ -221,6 +222,10 @@ def verify_ci(args):
"""Verify CI configuration"""
mx.verify_ci(args, mx.suite('truffle'), _suite, ['common.json', 'ci/common.jsonnet'])

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

mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVmLanguage(
suite=_suite,
Expand Down Expand Up @@ -294,8 +299,8 @@ def verify_ci(args):
library_configs=[
mx_sdk_vm.LanguageLibraryConfig(
destination='lib/<lib:rubyvm>',
launchers=['bin/<exe:ruby>', 'bin/<exe:truffleruby>'],
jar_distributions=['truffleruby:TRUFFLERUBY-LAUNCHER'],
launchers=['bin/<exe:ruby>', 'bin/<exe:truffleruby>', 'bin/<exe:truffleruby-polyglot-get>'],
jar_distributions=['truffleruby:TRUFFLERUBY-LAUNCHER', 'sdk:MAVEN_DOWNLOADER'],
main_class='org.truffleruby.launcher.RubyLauncher',
build_args=[
'-H:+DetectUserDirectoriesInImageHeap',
Expand Down Expand Up @@ -329,4 +334,5 @@ def verify_ci(args):
'ruby_spotbugs': [ruby_spotbugs, ''],
'verify-ci': [verify_ci, '[options]'],
'ruby_jacoco_args': [ruby_jacoco_args, ''],
'ruby_maven_deploy_public': [ruby_maven_deploy_public, ''],
})
8 changes: 5 additions & 3 deletions mx.truffleruby/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
"name": "regex",
"subdir": True,
"version": "621ba026a108b8320e5cdadf6150c2fa30b1339a",
"version": "39e46e0bc2bd49cb52f3c98944253d59d76a21b0",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand All @@ -29,7 +29,7 @@
{
"name": "sulong",
"subdir": True,
"version": "621ba026a108b8320e5cdadf6150c2fa30b1339a",
"version": "39e46e0bc2bd49cb52f3c98944253d59d76a21b0",
"urls": [
{"url": "https://github.com/oracle/graal.git", "kind": "git"},
{"url": "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind": "binary"},
Expand Down Expand Up @@ -307,12 +307,13 @@
"org.truffleruby.launcher": {
"dir": "src/launcher",
"sourceDirs": ["java"],
"requires": ["java.logging"],
"requires": ["java.logging", "java.xml"],
"dependencies": [
"truffleruby:TRUFFLERUBY-ANNOTATIONS",
"truffleruby:TRUFFLERUBY-SHARED",
"sdk:POLYGLOT",
"sdk:LAUNCHER_COMMON",
"sdk:MAVEN_DOWNLOADER",
],
"jacoco": "include",
"javaCompliance": "17+",
Expand Down Expand Up @@ -566,6 +567,7 @@
"truffleruby:TRUFFLERUBY-SHARED",
"sdk:POLYGLOT",
"sdk:LAUNCHER_COMMON",
"sdk:MAVEN_DOWNLOADER",
],
"description": "TruffleRuby Launcher",
"license": ["EPL-2.0"],
Expand Down
2 changes: 1 addition & 1 deletion spec/truffle/launcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def check_status_or_print(stdout_and_stderr)
it "all launchers are in @launchers" do
known = @launchers.keys.map(&:to_s).sort
actual = Dir.children(File.dirname(RbConfig.ruby)).sort
actual.delete('truffleruby.sh')
actual.delete('truffleruby-polyglot-get')
actual.should == known
end

Expand Down
40 changes: 40 additions & 0 deletions src/launcher/java/org/truffleruby/launcher/RubyLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.ProcessBuilder.Redirect;

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

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

private static void trufflerubyPolyglotGet(List<String> originalArgs) {
String rubyHome = getPropertyOrFail("org.graalvm.language.ruby.home");
String outputDir = rubyHome + "/modules";
List<String> args = new ArrayList<>();
args.add("-o");
args.add(outputDir);
args.add("-v");
args.add(getPropertyOrFail("org.graalvm.version"));
if (originalArgs.size() == 1 && !originalArgs.get(0).startsWith("-")) {
args.add("-a");
}
args.addAll(originalArgs);
try {
Main.main(args.toArray(CommandLineOptions.EMPTY_STRING_ARRAY));
} catch (Exception e) {
throw new Error(e);
}
System.exit(0);
}

private static String getPropertyOrFail(String property) {
String value = System.getProperty(property);
if (value == null) {
throw new UnsupportedOperationException("Expected system property " + property + " to be set");
}
return value;
}

@Override
protected String getLanguageId() {
return TruffleRuby.LANGUAGE_ID;
Expand All @@ -65,6 +96,15 @@ protected void printVersion() {

@Override
protected List<String> preprocessArguments(List<String> args, Map<String, String> polyglotOptions) {
String launcherName = System.getProperty("org.graalvm.launcher.executablename", "miniruby");
if (launcherName.endsWith("truffleruby-polyglot-get")) {
if (isAOT()) {
throw abort("truffleruby-polyglot-get is not available for the native standalone");
} else {
trufflerubyPolyglotGet(args);
}
}

// Set default options for the launcher which don't match the OptionKey's default.
// These options can still be overridden if set explicitly.
polyglotOptions.put(OptionsCatalog.EMBEDDED.getName(), "false");
Expand Down
27 changes: 27 additions & 0 deletions test/truffle/ecosystem/truffleruby-polyglot-get-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

source test/truffle/common.sh.inc

# Clone Graal.js repository
jt mx --dy /vm,/graal-js sversions

jt mx --env jvm-js ruby_maven_deploy_public
maven_repo="$(dirname "$(pwd)")/graal/sdk/mxbuild/jdk21/mx.sdk/public-maven-repo"
if [ ! -d "$maven_repo" ]; then
echo "Maven repo not at $maven_repo ?"
exit 2
fi

jt build --env jvm-ce

standalone=$(jt -q mx --quiet --env jvm-ce standalone-home --type=jvm ruby)

export PATH="$standalone/bin:$PATH"

env org.graalvm.maven.downloader.repository="file://$maven_repo" truffleruby-polyglot-get js-community

out=$(ruby --polyglot -e 'p Polyglot.eval("js", "1/2")')
if [ "$out" != "0.5" ]; then
echo "Wrong output: >>$out<<"
exit 1
fi
3 changes: 2 additions & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,8 @@ def test(*args)
when 'unit', 'unittest' then test_unit(*rest)
when 'tck'
puts bold 'NOTE: You need `jt mx build` before running `jt test tck` to build the relevant test distributions'
mx 'tck', *rest
# GR-48568 for why DisableClassPathIsolation is needed
mx 'tck', '-Dpolyglotimpl.DisableClassPathIsolation=true', *rest
else
if File.expand_path(path, TRUFFLERUBY_DIR).start_with?("#{TRUFFLERUBY_DIR}/test")
test_mri(*args)
Expand Down

0 comments on commit 4188b26

Please sign in to comment.