Skip to content

Commit

Permalink
Converted language permission gates to use unchained build.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzezula committed Mar 21, 2024
1 parent 4cc4329 commit 808748c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ JavaArgs = --add-exports org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UN
--add-exports org.graalvm.nativeimage.builder/com.oracle.svm.hosted.config=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.debug=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.graph=ALL-UNNAMED \
--add-exports=jdk.graal.compiler/jdk.graal.compiler.graph.iterators=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.nodes=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.nodes.java=ALL-UNNAMED \
--add-exports=jdk.graal.compiler/jdk.graal.compiler.nodes.spi=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.options=ALL-UNNAMED \
--add-exports org.graalvm.truffle.runtime/com.oracle.truffle.runtime=ALL-UNNAMED \
--add-exports jdk.graal.compiler/jdk.graal.compiler.util.json=ALL-UNNAMED \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ public boolean getAsBoolean() {
safePackages.add("com.oracle.truffle.host.");
safePackages.add("com.oracle.truffle.nfi.");
safePackages.add("com.oracle.truffle.object.");
safePackages.add("com.oracle.truffle.runtime.");
safePackages.add("com.oracle.truffle.runtime.debug.");
safePackages.add("com.oracle.truffle.runtime.jfr.");
safePackages.add("com.oracle.truffle.runtime.jfr.impl.");
safePackages.add("com.oracle.truffle.runtime.hotspot.");
safePackages.add("com.oracle.truffle.runtime.hotspot.libgraal.");
safePackages.add("com.oracle.truffle.runtime.enterprise.");
safePackages.add("com.oracle.truffle.sandbox.enterprise.");
safePackages.add("com.oracle.truffle.polyglot.enterprise.");
safePackages.add("com.oracle.truffle.object.enterprise.");
safePackages.add("com.oracle.svm.truffle.isolated.");
safePackages.add("com.oracle.svm.enterprise.truffle.");
}

private static final Set<ClassLoader> systemClassLoaders;
Expand Down Expand Up @@ -519,7 +531,7 @@ private int collectViolations(
if (!callers.isEmpty()) {
numReports = collectViolations(report, callers.iterator().next(), maxDepth, maxReports, callGraph, contextFiltersParam, currentPath, visited, depth + 1, numReports);
}
} else if (!isSystemClass(mNode)) {
} else if (!isSystemOrSafeClass(mNode)) {
List<BaseMethodNode> callPath = new ArrayList<>(currentPath);
report.add(callPath);
numReports++;
Expand Down
13 changes: 6 additions & 7 deletions vm/ci/ci_includes/vm-native.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ local vm_common = import '../ci_common/common.jsonnet';
name: self.targets[0] + '-vm-ce-truffle-lts-compatibility-' + mode + '-linux-amd64',
},

local svm_truffle_tck = vm_common.svm_common + {
local truffle_native_tck = vm_common.svm_common + {
run+: [
['export', 'SVM_SUITE=' + vm.svm_suite],
['mx', '--dynamicimports', '$SVM_SUITE,/tools', '--disable-polyglot', '--skip-libraries=true', '--force-bash-launchers=gu,native-image-configure,polybench', 'gate', '--no-warning-as-error', '--tags', 'build,svm_tck_test,svm_sl_tck'],
['mx', '--env', 'ce', '--dynamicimports', '/tools', '--native-images=lib:jvmcicompiler', 'gate', '--tags', 'build,truffle-native-tck,truffle-native-tck-sl'],
],
notify_emails: ["christian.humer@oracle.com", "jakub.chaloupka@oracle.com"],
notify_emails: ["christian.humer@oracle.com", "jakub.chaloupka@oracle.com", "tomas.zezula@gmail.com"],
timelimit: '35:00',
name: self.targets[0] + '-vm-svm-truffle-tck-labs' + self.jdk_name + '-linux-amd64',
name: self.targets[0] + '-vm-truffle-native-tck-labs' + self.jdk_name + '-linux-amd64',
},

local truffle_maven_downloader = vm_common.svm_common + vm_common.sulong + {
Expand Down Expand Up @@ -81,8 +80,8 @@ local vm_common = import '../ci_common/common.jsonnet';
vm.vm_java_Latest + vm_common.vm_base('linux', 'amd64', 'gate') + {
gate_tag_suffix: '-quickbuild',
} + truffle_native,
vm.vm_java_21 + vm_common.vm_base('linux', 'amd64', 'daily') + svm_truffle_tck,
vm.vm_java_Latest + vm_common.vm_base('linux', 'amd64', 'gate') + svm_truffle_tck,
vm.vm_java_21 + vm_common.vm_base('linux', 'amd64', 'daily') + truffle_native_tck,
vm.vm_java_Latest + vm_common.vm_base('linux', 'amd64', 'gate') + truffle_native_tck,
vm.vm_java_21 + vm_common.vm_base('linux', 'amd64', 'daily') + truffle_jvm,
vm.vm_java_Latest + vm_common.vm_base('linux', 'amd64', 'gate') + truffle_jvm,
vm.vm_java_21 + vm_common.vm_base('linux', 'amd64', 'daily') + truffle_maven_downloader,
Expand Down
87 changes: 39 additions & 48 deletions vm/mx.vm/mx_vm_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import atexit
from mx_gate import Task

from os import environ, listdir, remove, linesep, pathsep
from os import environ, listdir, remove, linesep
from os.path import join, exists, dirname, isdir, isfile, getsize, abspath
from tempfile import NamedTemporaryFile, mkdtemp
from contextlib import contextmanager
Expand All @@ -68,10 +68,10 @@ class VmGateTasks:
integration = 'integration'
tools = 'tools'
libgraal = 'libgraal'
svm_tck_test = 'svm_tck_test'
svm_sl_tck = 'svm_sl_tck'
svm_truffle_tck_js = 'svm-truffle-tck-js'
svm_truffle_tck_python = 'svm-truffle-tck-python'
truffle_native_tck = 'truffle-native-tck'
truffle_native_tck_sl = 'truffle-native-tck-sl'
truffle_native_tck_js = 'truffle-native-tck-js'
truffle_native_tck_python = 'truffle-native-tck-python'
truffle_jvm = 'truffle-jvm'
truffle_native = 'truffle-native'
truffle_native_quickbuild = 'truffle-native-quickbuild'
Expand Down Expand Up @@ -553,10 +553,10 @@ def gate_body(args, tasks):

gate_sulong(tasks)
gate_python(tasks)
gate_svm_truffle_tck_smoke_test(tasks)
gate_svm_sl_tck(tasks)
gate_svm_truffle_tck_js(tasks)
gate_svm_truffle_tck_python(tasks)
gate_truffle_native_tck_smoke_test(tasks)
gate_truffle_native_tck_sl(tasks)
gate_truffle_native_tck_js(tasks)
gate_truffle_native_tck_python(tasks)
gate_truffle_jvm(tasks)
gate_truffle_native(tasks)
gate_truffle_native(tasks, quickbuild=True)
Expand Down Expand Up @@ -635,11 +635,13 @@ def gate_python(tasks):
python_suite = mx.suite("graalpython")
python_suite.extensions.run_python_unittests(python_svm_image_path)

def _svm_truffle_tck(native_image, svm_suite, language_suite, language_id, language_distribution=None, fail_on_error=True):
assert not language_distribution if language_suite else language_distribution, 'Either language_suite or language_distribution must be given'
dists = [d for d in svm_suite.dists if d.name == 'SVM_TRUFFLE_TCK']
if not dists:
mx.abort("Cannot resolve: SVM_TRUFFLE_TCK distribution.")

def _svm_truffle_tck(native_image, language_id, language_distribution=None, fail_on_error=True):
assert language_distribution, 'Language_distribution must be given'
dists = [
mx.distribution('substratevm:SVM_TRUFFLE_TCK'),
language_distribution
] + mx_truffle.resolve_truffle_dist_names()

def _collect_excludes(suite, suite_import, excludes):
excludes_dir = join(suite.mxDir, 'truffle.tck.permissions')
Expand All @@ -650,28 +652,19 @@ def _collect_excludes(suite, suite_import, excludes):
imported_suite.visit_imports(_collect_excludes, excludes=excludes)

excludes = []
if language_suite:
language_suite.visit_imports(_collect_excludes, excludes=excludes)
macro_options = [f'--language:{language_id}']
else:
macro_options = ['--macro:truffle']
dists = dists + [language_distribution]
cp = pathsep.join([d.classpath_repr() for d in dists])
language_distribution.suite.visit_imports(_collect_excludes, excludes=excludes)
svmbuild = mkdtemp()
try:
report_file = join(svmbuild, "language_permissions.log")
options = macro_options + [
options = mx.get_runtime_jvm_args(dists, exclude_names=['substratevm:SVM']) + [
'--features=com.oracle.svm.truffle.tck.PermissionsFeature',
] + mx_sdk_vm_impl.svm_experimental_options([
'-H:ClassInitialization=:build_time',
'-H:+EnforceMaxRuntimeCompileMethods',
'--add-exports=jdk.graal.compiler/jdk.graal.compiler.graph.iterators=ALL-UNNAMED',
'--add-exports=jdk.graal.compiler/jdk.graal.compiler.nodes.spi=ALL-UNNAMED',
'-cp',
cp,
'-H:-FoldSecurityManagerGetter',
f'-H:TruffleTCKPermissionsReportFile={report_file}',
f'-H:Path={svmbuild}',
'--add-exports=org.graalvm.truffle.runtime/com.oracle.truffle.runtime=ALL-UNNAMED'
]) + [
'com.oracle.svm.truffle.tck.MockMain'
]
Expand All @@ -691,14 +684,15 @@ def _collect_excludes(suite, suite_import, excludes):
mx.rmtree(svmbuild)
return None

def gate_svm_truffle_tck_smoke_test(tasks):
with Task('SVM Truffle TCK Smoke Test', tasks, tags=[VmGateTasks.svm_tck_test]) as t:

def gate_truffle_native_tck_smoke_test(tasks):
with Task('Truffle Native TCK Smoke Test', tasks, tags=[VmGateTasks.truffle_native_tck]) as t:
if t:
truffle_suite = mx.suite('truffle')
test_language_dist = [d for d in truffle_suite.dists if d.name == 'TRUFFLE_TCK_TESTS_LANGUAGE'][0]
native_image_context, svm = graalvm_svm()
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
result = _svm_truffle_tck(native_image, svm.suite, None, 'TCKSmokeTestLanguage', test_language_dist, False)
result = _svm_truffle_tck(native_image, 'TCKSmokeTestLanguage', test_language_dist, False)
if not 'Failed: Language TCKSmokeTestLanguage performs following privileged calls' in result:
mx.abort("Expected failure, log:\n" + result)
if not 'UnsafeCallNode.doUnsafeAccess' in result:
Expand All @@ -713,27 +707,26 @@ def gate_svm_truffle_tck_smoke_test(tasks):
mx.abort("Missing PrivilegedCallNode.doInterrupt call in the log, log:\n" + result)


def gate_svm_truffle_tck_js(tasks):
with Task('JavaScript SVM Truffle TCK', tasks, tags=[VmGateTasks.svm_truffle_tck_js]) as t:
def gate_truffle_native_tck_js(tasks):
with Task('JavaScript Truffle Native TCK', tasks, tags=[VmGateTasks.truffle_native_tck_js]) as t:
if t:
js_suite = mx.suite('graal-js')
if not js_suite:
mx.abort("Cannot resolve graal-js suite.")
js_language = mx.distribution('graal-js:GRAALJS', fatalIfMissing=False)
if not js_language:
mx.abort("Cannot resolve the `graal-js::GRAALJS` language distribution. To resolve this, import the graal-js suite using `--dynamicimports /graal-js`.")
native_image_context, svm = graalvm_svm()
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
_svm_truffle_tck(native_image, svm.suite, js_suite, 'js')

_svm_truffle_tck(native_image, 'js', js_language)


def gate_svm_truffle_tck_python(tasks):
with Task('Python SVM Truffle TCK', tasks, tags=[VmGateTasks.svm_truffle_tck_python]) as t:
def gate_truffle_native_tck_python(tasks):
with Task('Python Truffle Native TCK', tasks, tags=[VmGateTasks.truffle_native_tck_python]) as t:
if t:
py_suite = mx.suite('graalpython')
if not py_suite:
mx.abort("Cannot resolve graalpython suite.")
py_language = mx.distribution('graalpython:GRAALPYTHON', fatalIfMissing=False)
if not py_language:
mx.abort("Cannot resolve the `graalpython:GRAALPYTHON` language distribution. To resolve this, import the graalpython suite using `--dynamicimports /graalpython`.")
native_image_context, svm = graalvm_svm()
with native_image_context(svm.IMAGE_ASSERTION_FLAGS) as native_image:
_svm_truffle_tck(native_image, svm.suite, py_suite, 'python')
_svm_truffle_tck(native_image, 'python', py_language)

def gate_truffle_jvm(tasks):
truffle_suite = mx.suite('truffle')
Expand Down Expand Up @@ -842,17 +835,15 @@ def build_tests_image(image_dir, options, unit_tests=None, additional_deps=None,
mx.logv(f'Test image path: {tests_image_path}')
return tests_image_path, unittests_file

def gate_svm_sl_tck(tasks):
with Task('SVM Truffle TCK', tasks, tags=[VmGateTasks.svm_sl_tck]) as t:
def gate_truffle_native_tck_sl(tasks):
with Task('SL Truffle Native TCK', tasks, tags=[VmGateTasks.truffle_native_tck_sl]) as t:
if t:
tools_suite = mx.suite('tools')
tools_suite = mx.suite('tools', fatalIfMissing=False)
if not tools_suite:
mx.abort("Cannot resolve tools suite.")
mx.abort("Cannot resolve tools suite. To resolve this, import the tools suite using `--dynamicimports /tools`.")
svmbuild = mkdtemp()
try:
options = [
'--macro:truffle',
'--tool:all',
'-H:Class=org.junit.runner.JUnitCore',
] + mx_sdk_vm_impl.svm_experimental_options([
f'-H:Path={svmbuild}',
Expand Down

0 comments on commit 808748c

Please sign in to comment.