Skip to content

Commit

Permalink
Introduce component dependencies for EE standalones.
Browse files Browse the repository at this point in the history
When not set, defaults to the CE dependencies.

(cherry picked from commit 84e86b2)
  • Loading branch information
ansalond committed Jun 3, 2023
1 parent 538dd6e commit 5b55cd7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
8 changes: 6 additions & 2 deletions sdk/mx.sdk/mx_sdk_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,24 @@ def direct_dependencies(self):

class GraalVmTruffleComponent(GraalVmComponent):
def __init__(self, suite, name, short_name, license_files, third_party_license_files, truffle_jars,
include_in_polyglot=None, standalone_dir_name=None, standalone_dependencies=None, **kwargs):
include_in_polyglot=None, standalone_dir_name=None, standalone_dependencies=None,
standalone_dependencies_enterprise=None, **kwargs):
"""
:param list[str] truffle_jars: JAR distributions that should be on the classpath for the language implementation.
:param bool include_in_polyglot: whether this component is included in `--language:all` or `--tool:all` and should be part of polyglot images (deprecated).
:param str standalone_dir_name: name for the standalone archive and directory inside
:param dict[str, (str, list[str])] standalone_dependencies: dict of dependent components to include in the standalone in the form {component name: (relative path, excluded_paths)}.
:param dict[str, (str, list[str])] standalone_dependencies: dict of dependent components to include in the CE standalone in the form {component name: (relative path, excluded_paths)}.
:param dict[str, (str, list[str])] standalone_dependencies_enterprise: like `standalone_dependencies`, but for the EE standalone. Defaults to `standalone_dependencies` if not set.
"""
super(GraalVmTruffleComponent, self).__init__(suite, name, short_name, license_files, third_party_license_files,
jar_distributions=truffle_jars, **kwargs)
if include_in_polyglot is not None:
mx.warn('"include_in_polyglot" is deprecated. Please drop all uses.')
self.standalone_dir_name = standalone_dir_name or '{}-<version>-<graalvm_os>-<arch>'.format(self.dir_name)
self.standalone_dependencies = standalone_dependencies or {}
self.standalone_dependencies_enterprise = standalone_dependencies_enterprise or self.standalone_dependencies
assert isinstance(self.standalone_dependencies, dict)
assert isinstance(self.standalone_dependencies_enterprise, dict)


class GraalVmLanguage(GraalVmTruffleComponent):
Expand Down
37 changes: 22 additions & 15 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,16 +1131,22 @@ def remove_lib_prefix_suffix(libname, require_suffix_prefix=True):
class SvmSupport(object):
def __init__(self):
self._svm_supported = has_component('svm', stage1=True)
self._svm_ee_supported = self._svm_supported and has_component('svmee', stage1=True)
self._debug_supported = self._svm_supported and (mx.is_linux() or mx.is_windows() or (mx.is_darwin() and has_component('svmee', stage1=True)))
self._separate_debuginfo_ext = {
'linux': '.debug',
'windows': '.pdb',
}.get(mx.get_os(), None)
self._pgo_supported = self._svm_supported and has_component('svmee', stage1=True)

def is_supported(self):
return self._svm_supported

def is_ee_supported(self):
return self._svm_ee_supported

def is_pgo_supported(self):
return self.is_ee_supported()

def native_image(self, build_args, output_file, allow_server=False, nonZeroIsFatal=True, out=None, err=None):
assert self._svm_supported
stage1 = get_stage1_graalvm_distribution()
Expand All @@ -1165,9 +1171,6 @@ def generate_separate_debug_info(self, image_config):
def separate_debuginfo_ext(self):
return self._separate_debuginfo_ext

def is_pgo_supported(self):
return self._pgo_supported

def get_debug_flags(self, image_config):
assert self.is_debug_supported()
flags = ['-g']
Expand Down Expand Up @@ -2645,12 +2648,14 @@ def require_svm(components):
"""
return any(_get_launcher_configs(comp) or _get_library_configs(comp) for comp in components)

svm_support = _get_svm_support()
other_comp_names = []
self.involved_components = [component] + [get_component(dep) for dep in component.standalone_dependencies]
if _get_svm_support().is_supported() and require_svm(self.involved_components):
if 'svm' in [c.short_name for c in registered_graalvm_components(stage1=True)]:
dependencies = component.standalone_dependencies_enterprise if svm_support.is_ee_supported() else component.standalone_dependencies
self.involved_components = [component] + [get_component(dep) for dep in dependencies]
if require_svm(self.involved_components):
if svm_support.is_supported():
other_comp_names.append('svm')
if 'svmee' in [c.short_name for c in registered_graalvm_components(stage1=True)]:
if svm_support.is_ee_supported():
other_comp_names.append('svmee')
for _component in self.involved_components:
other_comp_names += _component.extra_installable_qualifiers
Expand All @@ -2666,7 +2671,7 @@ def require_svm(components):

# Compute paths from standalone component launchers to other homes
home_paths = {}
for dependency_name, details in component.standalone_dependencies.items():
for dependency_name, details in dependencies.items():
dependency_path = details[0]
comp = get_component(dependency_name, fatalIfMissing=True)
home_paths[comp.installable_id] = base_dir + dependency_path
Expand Down Expand Up @@ -2753,7 +2758,7 @@ def add_files_from_component(comp, path_prefix, excluded_paths):
metadata = BaseGraalVmLayoutDistribution._get_metadata(sorted_suites)
layout.setdefault(base_dir + 'release', []).append('string:' + metadata)

for dependency_name, details in component.standalone_dependencies.items():
for dependency_name, details in dependencies.items():
dependency_path = details[0]
excluded_paths = details[1] if len(details) > 1 else []
dependency = get_component(dependency_name, fatalIfMissing=True)
Expand Down Expand Up @@ -3120,15 +3125,17 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
# Create standalones
for components in installables.values():
main_component = _get_main_component(components)
svm_support = _get_svm_support()
if main_component.standalone and isinstance(main_component, mx_sdk.GraalVmTruffleComponent):
only_native_launchers = not main_component.launcher_configs or has_svm_launcher(main_component)
only_native_libraries = not main_component.library_configs or (_get_svm_support().is_supported() and not _has_skipped_libraries(main_component))
only_native_libraries = not main_component.library_configs or (svm_support.is_supported() and not _has_skipped_libraries(main_component))
if only_native_launchers and only_native_libraries:
dependencies = main_component.standalone_dependencies.keys()
missing_dependencies = [dep for dep in dependencies if not has_component(dep) or _has_skipped_libraries(get_component(dep)) or (get_component(dep).library_configs and not _get_svm_support().is_supported())]
if missing_dependencies:
dependencies = main_component.standalone_dependencies_enterprise if svm_support.is_ee_supported() else main_component.standalone_dependencies
dependency_names = dependencies.keys()
missing_dependency_names = [dep for dep in dependency_names if not has_component(dep) or _has_skipped_libraries(get_component(dep)) or (get_component(dep).library_configs and not svm_support.is_supported())]
if missing_dependency_names:
if mx.get_opts().verbose:
mx.warn("Skipping standalone {} because the components {} are excluded".format(main_component.name, missing_dependencies))
mx.warn("Skipping standalone {} because the components {} are excluded".format(main_component.name, missing_dependency_names))
else:
standalone = GraalVmStandaloneComponent(get_component(main_component.name, fatalIfMissing=True), _final_graalvm_distribution)
register_distribution(standalone)
Expand Down

0 comments on commit 5b55cd7

Please sign in to comment.