Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ jobs:
JDK: "labsjdk-ce-11"
GATE: "hellomodule"
PRIMARY: "substratevm"
USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM: true
- env:
JDK: "labsjdk-ce-11"
GATE: "style,fullbuild"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class ModuleSupport {

public static final boolean USE_NI_JPMS = System.getenv().getOrDefault("USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM", "false").toLowerCase().equals("true");
public static final boolean USE_NI_JPMS = Boolean.parseBoolean(System.getenv().get("USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM"));

static Iterable<OptionDescriptors> getOptionsLoader() {
/*
Expand Down
28 changes: 20 additions & 8 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,9 @@ def getBuildTask(self, args):


class NativePropertiesBuildTask(mx.ProjectBuildTask):

implicit_excludes = ['substratevm:LIBRARY_SUPPORT']

def __init__(self, subject, args):
"""
:type subject: GraalVmNativeProperties
Expand All @@ -1204,12 +1207,14 @@ def _get_location_classpath(self):
graalvm_dist = get_final_graalvm_distribution()
image_config = self.subject.image_config
graalvm_location = dirname(graalvm_dist.find_single_source_location('dependency:' + self.subject.name))
self._location_classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_location, image_config, self.subject.component)
self._location_classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_location, image_config, self.subject.component, exclude_implicit=True)
return self._location_classpath

@staticmethod
def get_launcher_classpath(graalvm_dist, start, image_config, component):
location_cp = graalvm_home_relative_classpath(image_config.jar_distributions, start, graal_vm=graalvm_dist)
def get_launcher_classpath(graalvm_dist, start, image_config, component, exclude_implicit=False):
with_substratevm = 'substratevm' in [s.name for s in mx.suites()]
exclude_names = NativePropertiesBuildTask.implicit_excludes if with_substratevm and exclude_implicit else None
location_cp = graalvm_home_relative_classpath(image_config.jar_distributions, start, graal_vm=graalvm_dist, exclude_names=exclude_names)
location_classpath = location_cp.split(os.pathsep) if location_cp else []
if image_config.dir_jars:
if not component:
Expand Down Expand Up @@ -1268,7 +1273,7 @@ def contents(self):

if isinstance(image_config, mx_sdk.LauncherConfig):
if image_config.is_sdk_launcher:
launcher_classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_home, image_config, self.subject.component)
launcher_classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_home, image_config, self.subject.component, exclude_implicit=True)
build_args += [
'-H:-ParseRuntimeOptions',
'-Dorg.graalvm.launcher.classpath=' + os.pathsep.join(launcher_classpath),
Expand Down Expand Up @@ -1825,7 +1830,7 @@ def polyglot_config_contents(self):
assert self.with_polyglot_config()
graalvm_dist = self.subject.get_containing_graalvm()
graalvm_location = dirname(graalvm_dist.find_single_source_location('dependency:{}/polyglot.config'.format(self.subject.name)))
classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_location, image_config, self.subject.component)
classpath = NativePropertiesBuildTask.get_launcher_classpath(graalvm_dist, graalvm_location, image_config, self.subject.component, exclude_implicit=True)
main_class = image_config.main_class
return u"|".join((u":".join(classpath), main_class))
return self._polyglot_config_contents
Expand Down Expand Up @@ -1978,8 +1983,7 @@ def _get_graalvm_archive_path(jdk_path, graal_vm=None):
'JDK_TOOLS',
}


def graalvm_home_relative_classpath(dependencies, start=None, with_boot_jars=False, graal_vm=None):
def graalvm_home_relative_classpath(dependencies, start=None, with_boot_jars=False, graal_vm=None, exclude_names=None):
if graal_vm is None:
graal_vm = get_final_graalvm_distribution()
start = start or _get_graalvm_archive_path('', graal_vm=graal_vm)
Expand All @@ -1993,7 +1997,15 @@ def graalvm_home_relative_classpath(dependencies, start=None, with_boot_jars=Fal
jimage = mx.project('graalvm-jimage', fatalIfMissing=False)
jimage_deps = jimage.deps if jimage else None
mx.logv("Composing classpath for " + str(dependencies) + ". Entries:\n" + '\n'.join(('- {}:{}'.format(d.suite, d.name) for d in mx.classpath_entries(dependencies))))
for _cp_entry in mx.classpath_entries(dependencies):
cp_entries = mx.classpath_entries(dependencies)

# Compute the set-difference of the transitive dependencies of `dependencies` and the transitive dependencies of `exclude_names`
if exclude_names:
for exclude_entry in mx.classpath_entries(names=exclude_names):
if exclude_entry in cp_entries:
cp_entries.remove(exclude_entry)

for _cp_entry in cp_entries:
if jimage_deps and _jlink_libraries() and _cp_entry in jimage_deps:
continue
if _cp_entry.isJdkLibrary() or _cp_entry.isJreLibrary():
Expand Down
3 changes: 0 additions & 3 deletions substratevm/ci_includes/gate.hocon
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ builds += [
}
${labsjdk-ee-11} ${svm-common-linux-gate} ${linux-deploy} {
name: "gate-svm-modules-basic"
environment : {
USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM : "true"
}
run: [
${svm-cmd-gate} ["build,hellomodule,test"]
]
Expand Down
55 changes: 34 additions & 21 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
else:
from io import StringIO

USE_NI_JPMS = os.environ.get('USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM', 'false').lower() == 'true'

suite = mx.suite('substratevm')
svmSuites = [suite]

Expand All @@ -71,13 +69,25 @@ def svm_java_compliance():
def svm_java8():
return svm_java_compliance() <= mx.JavaCompliance('1.8')

def graal_compiler_flags(all_unnamed=True):
def graal_compiler_flags():
version_tag = svm_java_compliance().value
compiler_flags = mx.dependency('substratevm:svm-compiler-flags-builder').compute_graal_compiler_flags_map(all_unnamed=all_unnamed)
compiler_flags = mx.dependency('substratevm:svm-compiler-flags-builder').compute_graal_compiler_flags_map()
if version_tag not in compiler_flags:
missing_flags_message = 'Missing graal-compiler-flags for {0}.\n Did you forget to run "mx build"?'
mx.abort(missing_flags_message.format(version_tag))
return compiler_flags[version_tag]
def adjusted_exports(line):
"""
Turns e.g.
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=jdk.internal.vm.compiler,org.graalvm.nativeimage.builder
into:
--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED
"""
if line.startswith('--add-exports='):
before, sep, _ = line.rpartition('=')
return before + sep + 'ALL-UNNAMED'
else:
return line
return [adjusted_exports(line) for line in compiler_flags[version_tag]]

def svm_unittest_config_participant(config):
vmArgs, mainClass, mainClassArgs = config
Expand Down Expand Up @@ -839,7 +849,7 @@ def _native_image_launcher_extra_jvm_args():
support_distributions=['substratevm:NATIVE_IMAGE_GRAALVM_SUPPORT'],
launcher_configs=[
mx_sdk_vm.LauncherConfig(
use_modules='image' if USE_NI_JPMS else 'launcher' if not svm_java8() else None,
use_modules='image' if not svm_java8() else None,
main_module="org.graalvm.nativeimage.driver",
destination="bin/<exe:native-image>",
jar_distributions=["substratevm:SVM_DRIVER"],
Expand All @@ -850,7 +860,7 @@ def _native_image_launcher_extra_jvm_args():
],
library_configs=[
mx_sdk_vm.LibraryConfig(
use_modules='image' if USE_NI_JPMS else 'launcher' if not svm_java8() else None,
use_modules='image' if not svm_java8() else None,
destination="<lib:native-image-agent>",
jvm_library=True,
jar_distributions=[
Expand All @@ -864,7 +874,7 @@ def _native_image_launcher_extra_jvm_args():
],
),
mx_sdk_vm.LibraryConfig(
use_modules='image' if USE_NI_JPMS else 'launcher' if not svm_java8() else None,
use_modules='image' if not svm_java8() else None,
destination="<lib:native-image-diagnostics-agent>",
jvm_library=True,
jar_distributions=[
Expand Down Expand Up @@ -1017,7 +1027,7 @@ def _native_image_configure_extra_jvm_args():
support_distributions=[],
launcher_configs=[
mx_sdk_vm.LauncherConfig(
use_modules='image' if USE_NI_JPMS else 'launcher' if not svm_java8() else None,
use_modules='image' if not svm_java8() else None,
main_module="org.graalvm.nativeimage.configure",
destination="bin/<exe:native-image-configure>",
jar_distributions=["substratevm:SVM_CONFIGURE"],
Expand Down Expand Up @@ -1088,8 +1098,6 @@ def hellomodule(args):
"""
if svm_java8():
mx.abort('Experimental module support requires Java 11+')
if os.environ.get('USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM', 'false') != 'true':
mx.abort('Experimental module support requires USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=true for "mx build" and "mx hellomodule"')

# Build a helloworld Java module with maven
module_path = []
Expand Down Expand Up @@ -1383,8 +1391,19 @@ def clean(self, forBuild=False):
def __str__(self):
return 'JvmFuncsFallbacksBuildTask {}'.format(self.subject)

def mx_register_dynamic_suite_constituents(register_project, _):
register_project(SubstrateCompilerFlagsBuilder())

class SubstrateCompilerFlagsBuilder(mx.ArchivableProject):

flags_build_dependencies = [
'substratevm:SVM'
]

def __init__(self):
mx.ArchivableProject.__init__(self, suite, 'svm-compiler-flags-builder', [], None, None)
self.buildDependencies = list(SubstrateCompilerFlagsBuilder.flags_build_dependencies)

def config_file(self, ver):
return 'graal-compiler-flags-' + str(ver) + '.config'

Expand Down Expand Up @@ -1440,7 +1459,7 @@ def config_file_update(self, file_path, lines, file_paths):

# If renaming or moving this method, please update the error message in
# com.oracle.svm.driver.NativeImage.BuildConfiguration.getBuilderJavaArgs().
def compute_graal_compiler_flags_map(self, all_unnamed=not USE_NI_JPMS):
def compute_graal_compiler_flags_map(self):
graal_compiler_flags_map = dict()
graal_compiler_flags_map[8] = [
'-d64',
Expand All @@ -1454,18 +1473,12 @@ def compute_graal_compiler_flags_map(self, all_unnamed=not USE_NI_JPMS):
]

# Packages to add-export
distributions_transitive = mx.classpath_entries(self.deps)
distributions_transitive = mx.classpath_entries(self.buildDependencies)
jdk = mx.get_jdk(tag='default')
required_exports = mx_javamodules.requiredExports(distributions_transitive, jdk)
target_module = 'ALL-UNNAMED' if all_unnamed else None
exports_flags = mx_sdk_vm.AbstractNativeImageConfig.get_add_exports_list(required_exports, target_module)
exports_flags = mx_sdk_vm.AbstractNativeImageConfig.get_add_exports_list(required_exports)
graal_compiler_flags_map[11].extend(exports_flags)

# Currently JDK 13, 14, 15 and JDK 11 have the same flags
graal_compiler_flags_map[13] = graal_compiler_flags_map[11]
graal_compiler_flags_map[14] = graal_compiler_flags_map[11]
graal_compiler_flags_map[15] = graal_compiler_flags_map[11]
graal_compiler_flags_map[16] = graal_compiler_flags_map[11]
# Currently JDK 17 and JDK 11 have the same flags
graal_compiler_flags_map[17] = graal_compiler_flags_map[11]
# DO NOT ADD ANY NEW ADD-OPENS OR ADD-EXPORTS HERE!
#
Expand Down
28 changes: 21 additions & 7 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,6 @@
"spotbugs": "false",
},

"svm-compiler-flags-builder": {
"class" : "SubstrateCompilerFlagsBuilder",
"dependencies" : [
"SVM",
],
},

"com.oracle.svm.junit": {
"subDir": "src",
"sourceDirs": ["src"],
Expand Down Expand Up @@ -1174,6 +1167,11 @@
"com.oracle.svm.jvmtiagentbase",
"com.oracle.svm.jvmtiagentbase.jvmti",
],
"requires" : [
"static com.oracle.mxtool.junit",
"static junit",
"static hamcrest",
],
},
},

Expand Down Expand Up @@ -1220,6 +1218,7 @@
"com.oracle.objectfile",
"com.oracle.objectfile.io",
"com.oracle.objectfile.debuginfo",
"com.oracle.objectfile.macho",
],

"requires" : ["jdk.unsupported"],
Expand Down Expand Up @@ -1323,6 +1322,11 @@
"exports" : [
"com.oracle.svm.agent",
],
"requires" : [
"static com.oracle.mxtool.junit",
"static junit",
"static hamcrest",
],
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
"jdk.vm.ci.meta",
Expand All @@ -1347,6 +1351,11 @@
"exports" : [
"com.oracle.svm.diagnosticsagent",
],
"requires" : [
"static com.oracle.mxtool.junit",
"static junit",
"static hamcrest",
],
},
},

Expand All @@ -1367,6 +1376,11 @@
"* to org.graalvm.nativeimage.agent.tracing",
"com.oracle.svm.configure",
],
"requires" : [
"static com.oracle.mxtool.junit",
"static junit",
"static hamcrest",
],
},
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ private void applyEnabled(MacroOption.EnabledOption enabledOption, String argume
boolean explicitImageClasspath = enabledOption.forEachPropertyValue(
config, "ImageClasspath", entry -> nativeImage.addImageClasspath(ClasspathUtils.stringToClasspath(entry)), PATH_SEPARATOR_REGEX);
if (!explicitImageModulePath && !explicitImageClasspath) {
if (NativeImage.USE_NI_JPMS) {
NativeImage.getJars(imageJarsDirectory).forEach(nativeImage::addImageModulePath);
} else {
NativeImage.getJars(imageJarsDirectory).forEach(nativeImage::addImageClasspath);
}
NativeImage.getJars(imageJarsDirectory).forEach(nativeImage::addImageClasspath);
}

String imageName = enabledOption.getProperty(config, "ImageName");
Expand Down
Loading