Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-60173] Register custom module-info compilation participant for JDK builds without JMODs #10161

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion 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": "7.34.1",
"mx_version": "7.35.1",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
Expand Down
40 changes: 40 additions & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,19 @@ def mx_post_parse_cmd_line(opts):
for dist in suite.dists:
if dist.isJARDistribution():
dist.set_archiveparticipant(GraalArchiveParticipant(dist, isTest=dist.name.endswith('_TEST')))
# Compilation of module-info.java classes need upgrade-module path arguments to
# when javac is invoked. This is in particular needed when the base JDK includes no
# JMODs.
if opts.no_jlinking:
all_jar_dists = set()
for p in suite.projects_recursive():
if p.isJavaProject():
jd = p.get_declaring_module_distribution()
if jd:
all_jar_dists.add(jd)
for d in all_jar_dists:
d.add_module_info_compilation_participant(NoJlinkModuleInfoCompilationParticipant(d, "jdk.graal.compiler").__process__)


def native_image_context_run(func, func_args=None, config=None, build_if_missing=False):
func_args = [] if func_args is None else func_args
Expand Down Expand Up @@ -1877,6 +1890,33 @@ def checkLine(line, marker, init_kind, msg, wrongly_initialized_lines):

native_image_context_run(build_and_test_clinittest_image, args)

class NoJlinkModuleInfoCompilationParticipant:

def __init__(self, dist, module_name):
self.dist = dist
self.module_name = module_name

# Upgrade module path for compilation of module-info.java files when not using jmods from the JDK
def __process__(self, module_desc):
"""
:param module_desc: The JavaModuleDescriptor for this distribution
:rtype: list of strings with extra javac arguments
"""
def safe_path_arg(p):
r"""
Return `p` with all `\` characters replaced with `\\`, all spaces replaced
with `\ ` and the result enclosed in double quotes.
"""
return '"' + p.replace('\\', '\\\\').replace(' ', '\\ ') + '"'
graal_mod = None
for m in module_desc.modulepath:
if m.name == self.module_name:
graal_mod = m
break
if graal_mod:
return [ '--upgrade-module-path=' + safe_path_arg(graal_mod.jarpath) ]
return []


class SubstrateJvmFuncsFallbacksBuilder(mx.Project):
def __init__(self, suite, name, deps, workingSets, theLicense, **kwArgs):
Expand Down
2 changes: 1 addition & 1 deletion substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pylint: disable=line-too-long
suite = {
"mxversion": "7.33.1",
"mxversion": "7.35.1",
"name": "substratevm",
"version" : "24.2.0",
"release" : False,
Expand Down