From dc3af76baffc92014ab25020d327888d5480490d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20W=C3=B6gerer?= Date: Wed, 18 Dec 2024 11:42:05 +0100 Subject: [PATCH 1/2] Remove obsolete --force-builder-on-cp option from native-unittest --- .../mx.substratevm/macro-junitcp.properties | 13 --------- substratevm/mx.substratevm/mx_substratevm.py | 28 +++---------------- substratevm/mx.substratevm/suite.py | 9 ------ vm/mx.vm/ce-test | 2 +- vm/mx.vm/mx_vm.py | 4 +-- 5 files changed, 7 insertions(+), 49 deletions(-) delete mode 100644 substratevm/mx.substratevm/macro-junitcp.properties diff --git a/substratevm/mx.substratevm/macro-junitcp.properties b/substratevm/mx.substratevm/macro-junitcp.properties deleted file mode 100644 index 73c91c7c042e..000000000000 --- a/substratevm/mx.substratevm/macro-junitcp.properties +++ /dev/null @@ -1,13 +0,0 @@ -# This file contains support for building a set of junit tests into a native-image - -ImageName = svmjunit - -ImageClasspath = ${.}/junit-support.jar:${.}/junit-tool.jar:${.}/junit.jar:${.}/hamcrest.jar - -Args = --features=com.oracle.svm.junit.JUnitFeature \ - --initialize-at-build-time=org.junit,com.oracle.mxtool.junit \ - --link-at-build-time=@svm-junit.packages \ - -H:Class=com.oracle.svm.junit.SVMJUnitRunner \ - -H:+UnlockExperimentalVMOptions \ - -H:TestFile=${*} \ - -H:-UnlockExperimentalVMOptions diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index eb5afcd249d4..ebcfff6e77e1 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -645,7 +645,7 @@ def batched(iterable, n): yield batch -def _native_junit(native_image, unittest_args, build_args=None, run_args=None, blacklist=None, whitelist=None, preserve_image=False, force_builder_on_cp=False, test_classes_per_run=None): +def _native_junit(native_image, unittest_args, build_args=None, run_args=None, blacklist=None, whitelist=None, preserve_image=False, test_classes_per_run=None): build_args = build_args or [] javaProperties = {} for dist in suite.dists: @@ -675,13 +675,7 @@ def dummy_harness(test_deps, vm_launcher, vm_args): mx.log('Building junit image for matching: ' + ' '.join(test_classes)) extra_image_args = mx.get_runtime_jvm_args(unittest_deps, jdk=mx_compiler.jdk, exclude_names=mx_sdk_vm_impl.NativePropertiesBuildTask.implicit_excludes) macro_junit = '--macro:junit' - if force_builder_on_cp: - macro_junit += 'cp' - custom_env = os.environ.copy() - custom_env['USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM'] = 'false' - else: - custom_env = None - unittest_image = native_image(['-ea', '-esa'] + build_args + extra_image_args + [macro_junit + '=' + unittest_file] + svm_experimental_options(['-H:Path=' + junit_test_dir]), env=custom_env) + unittest_image = native_image(['-ea', '-esa'] + build_args + extra_image_args + [macro_junit + '=' + unittest_file] + svm_experimental_options(['-H:Path=' + junit_test_dir])) image_pattern_replacement = unittest_image + ".exe" if mx.is_windows() else unittest_image run_args = [arg.replace('${unittest.image}', image_pattern_replacement) for arg in run_args] mx.log('Running: ' + ' '.join(map(shlex.quote, [unittest_image] + run_args))) @@ -719,7 +713,7 @@ def unmask(args): def _native_unittest(native_image, cmdline_args): parser = ArgumentParser(prog='mx native-unittest', description='Run unittests as native image.') - all_args = ['--build-args', '--run-args', '--blacklist', '--whitelist', '-p', '--preserve-image', '--force-builder-on-cp', '--test-classes-per-run'] + all_args = ['--build-args', '--run-args', '--blacklist', '--whitelist', '-p', '--preserve-image', '--test-classes-per-run'] cmdline_args = [_mask(arg, all_args) for arg in cmdline_args] parser.add_argument(all_args[0], metavar='ARG', nargs='*', default=[]) parser.add_argument(all_args[1], metavar='ARG', nargs='*', default=[]) @@ -727,7 +721,6 @@ def _native_unittest(native_image, cmdline_args): parser.add_argument('--whitelist', help='run testcases specified in only', metavar='') parser.add_argument('-p', '--preserve-image', help='do not delete the generated native image', action='store_true') parser.add_argument('--test-classes-per-run', help='run N test classes per image run, instead of all tests at once', nargs=1, type=int) - parser.add_argument('--force-builder-on-cp', help='force image builder to run on classpath', action='store_true') parser.add_argument('unittest_args', metavar='TEST_ARG', nargs='*') pargs = parser.parse_args(cmdline_args) @@ -749,7 +742,7 @@ def _native_unittest(native_image, cmdline_args): mx.log('warning: could not read blacklist: ' + blacklist) unittest_args = unmask(pargs.unittest_args) if unmask(pargs.unittest_args) else ['com.oracle.svm.test', 'com.oracle.svm.configure.test'] - _native_junit(native_image, unittest_args, unmask(pargs.build_args), unmask(pargs.run_args), blacklist, whitelist, pargs.preserve_image, pargs.force_builder_on_cp, test_classes_per_run) + _native_junit(native_image, unittest_args, unmask(pargs.build_args), unmask(pargs.run_args), blacklist, whitelist, pargs.preserve_image, test_classes_per_run) def jvm_unittest(args): @@ -1467,19 +1460,6 @@ def _native_image_launcher_extra_jvm_args(): jlink=False, )) -mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVMSvmMacro( - suite=suite, - name='Native Image JUnit with image-builder on classpath', - short_name='njucp', - dir_name='junitcp', - license_files=[], - third_party_license_files=[], - dependencies=['SubstrateVM'], - jar_distributions=['substratevm:JUNIT_SUPPORT', 'mx:JUNIT_TOOL', 'mx:JUNIT', 'mx:HAMCREST'], - support_distributions=['substratevm:NATIVE_IMAGE_JUNITCP_SUPPORT'], - jlink=False, -)) - libgraal_jar_distributions = [ 'sdk:NATIVEBRIDGE', 'sdk:JNIUTILS', diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 427bb744604f..1df121de2fcb 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -2327,15 +2327,6 @@ }, }, - "NATIVE_IMAGE_JUNITCP_SUPPORT" : { - "native" : True, - "description" : "Native-image based junit testing support but with running image-builder on classpath", - "layout" : { - "native-image.properties" : "file:mx.substratevm/macro-junitcp.properties", - "svm-junit.packages" : "file:mx.substratevm/svm-junit.packages", - }, - }, - "SVM_FOREIGN": { "subDir": "src", "description" : "SubstrateVM support for the Foreign API", diff --git a/vm/mx.vm/ce-test b/vm/mx.vm/ce-test index 74664c9d3147..689a28038a5b 100644 --- a/vm/mx.vm/ce-test +++ b/vm/mx.vm/ce-test @@ -1,4 +1,4 @@ DYNAMIC_IMPORTS=/compiler,/graal-js,/regex,/sdk,/substratevm,/tools,/truffle -COMPONENTS=cmp,cov,dap,dis,gvm,icu4j,ins,insight,insightheap,lg,llp,lsp,nfi-libffi,ni,nic,nil,nju,njucp,pro,rgx,sdk,sdkl,tfl,tfla,tflc,tflm,truffle-json +COMPONENTS=cmp,cov,dap,dis,gvm,icu4j,ins,insight,insightheap,lg,llp,lsp,nfi-libffi,ni,nic,nil,nju,pro,rgx,sdk,sdkl,tfl,tfla,tflc,tflm,truffle-json NATIVE_IMAGES=graalvm-native-binutil,graalvm-native-clang,graalvm-native-clang-cl,graalvm-native-clang++,graalvm-native-flang,graalvm-native-ld,lib:jvmcicompiler,lib:native-image-agent,lib:native-image-diagnostics-agent,native-image DISABLE_INSTALLABLES=llp diff --git a/vm/mx.vm/mx_vm.py b/vm/mx.vm/mx_vm.py index c72674b04a53..260041113d24 100644 --- a/vm/mx.vm/mx_vm.py +++ b/vm/mx.vm/mx_vm.py @@ -170,9 +170,9 @@ def local_path_to_url(args): mx_sdk_vm.register_vm_config('ce', llvm_components + ['antlr4', 'sllvmvm', 'bnative-image', 'cmp', 'lg', 'llrc', 'llrl', 'llrlf', 'llrn', 'nfi-libffi', 'nfi', 'ni', 'nil', 'pbm', 'pbi', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file='polybench-sulong-ce') if mx.get_os() == 'windows': - mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) + mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'nic', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) else: - mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'njucp', 'nic', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'svml', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) + mx_sdk_vm.register_vm_config('svm', ['bnative-image', 'bnative-image-configure', 'cmp', 'gvm', 'nfi-libffi', 'nfi', 'ni', 'nil', 'nju', 'nic', 'rgx', 'sdk', 'sdkni', 'sdkc', 'sdkl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'svmt', 'svmnfi', 'svmsl', 'svml', 'tfl', 'tfla', 'tflc', 'tflm'], _suite, env_file=False) # pylint: enable=line-too-long From 42f3bc765cc0eb062cbd362b8070020f1c4f51dd Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Tue, 17 Dec 2024 11:36:31 +0100 Subject: [PATCH 2/2] [GR-60379] Make InternalResourceCache#useInternalResources compilation constant. --- .../truffle/polyglot/InternalResourceCache.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java index b136e2e71a19..43ba1625c6c7 100644 --- a/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java +++ b/truffle/src/com.oracle.truffle.polyglot/src/com/oracle/truffle/polyglot/InternalResourceCache.java @@ -95,10 +95,10 @@ final class InternalResourceCache { /** * Recomputed before the analyses by a substitution in the {@code TruffleBaseFeature} based on - * the {@code CopyLanguageResources} option value. The field must not be declared as - * {@code final} to make the substitution function correctly. + * the {@code CopyLanguageResources} option value. The field must not qualify as a Java language + * constant (as defined in JLS 15.28) to prevent the Java compiler from inlining its value. */ - private static boolean useInternalResources = true; + private static final boolean useInternalResources = Boolean.TRUE.booleanValue(); private static boolean useExternalDirectoryInNativeImage = true; private final String id; @@ -292,8 +292,9 @@ private static String sanitize(String pathElement) { } /** - * Returns true if internal resources are enabled. Internal resources can be disabled in the - * native image using {-H:-CopyLanguageResources} option. + * Returns true if internal resources are enabled. Internal resources are disabled in the native + * image when both the copying and inclusion of language resources are turned off. This can be + * achieved by using the {@code -H:-IncludeLanguageResources} option. */ public static boolean usesInternalResources() { return useInternalResources;