Skip to content

Commit

Permalink
[GR-49610] Adopt Graal module and package renaming.
Browse files Browse the repository at this point in the history
PullRequest: mx/1693
  • Loading branch information
dougxc committed Oct 23, 2023
2 parents 3e76ddc + 173cf08 commit 0e42632
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 72 deletions.
82 changes: 41 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ for the `compiler` suite, it is `mx.compiler`. The format of `suite.py` is JSON

Java source code is contained in a `project`. Here's an example of two [Graal compiler projects](https://github.com/oracle/graal/blob/b95d8827609d8b28993bb4468f5daa128a614e52/compiler/mx.compiler/suite.py#L129-L147):
```python
"org.graalvm.compiler.serviceprovider" : {
"jdk.graal.compiler.serviceprovider" : {
"subDir" : "src",
"sourceDirs" : ["src"],
"dependencies" : ["JVMCI_SERVICES"],
"checkstyle" : "org.graalvm.compiler.graph",
"checkstyle" : "jdk.graal.compiler.graph",
"javaCompliance" : "8",
"workingSets" : "API,Graal",
},

"org.graalvm.compiler.serviceprovider.jdk9" : {
"jdk.graal.compiler.serviceprovider.jdk9" : {
"subDir" : "src",
"sourceDirs" : ["src"],
"dependencies" : ["org.graalvm.compiler.serviceprovider"],
"uses" : ["org.graalvm.compiler.serviceprovider.GraalServices.JMXService"],
"checkstyle" : "org.graalvm.compiler.graph",
"dependencies" : ["jdk.graal.compiler.serviceprovider"],
"uses" : ["jdk.graal.compiler.serviceprovider.GraalServices.JMXService"],
"checkstyle" : "jdk.graal.compiler.graph",
"javaCompliance" : "9+",
"multiReleaseJarVersion" : "9",
"workingSets" : "API,Graal",
Expand Down Expand Up @@ -138,11 +138,11 @@ Here is an extract from the definition of the `TRUFFLE_API` distribution which p
"static java.desktop"
],
"exports" : [
"com.oracle.truffle.api.nodes to jdk.internal.vm.compiler",
"com.oracle.truffle.api.impl to jdk.internal.vm.compiler, org.graalvm.locator",
"com.oracle.truffle.api to jdk.internal.vm.compiler, org.graalvm.locator, com.oracle.graal.graal_enterprise",
"com.oracle.truffle.api.object to jdk.internal.vm.compiler, com.oracle.graal.graal_enterprise",
"com.oracle.truffle.object to jdk.internal.vm.compiler, com.oracle.graal.graal_enterprise",
"com.oracle.truffle.api.nodes to jdk.graal.compiler",
"com.oracle.truffle.api.impl to jdk.graal.compiler, org.graalvm.locator",
"com.oracle.truffle.api to jdk.graal.compiler, org.graalvm.locator, com.oracle.graal.graal_enterprise",
"com.oracle.truffle.api.object to jdk.graal.compiler, com.oracle.graal.graal_enterprise",
"com.oracle.truffle.object to jdk.graal.compiler, com.oracle.graal.graal_enterprise",
],
"uses" : [
"com.oracle.truffle.api.TruffleRuntimeAccess",
Expand All @@ -167,11 +167,11 @@ module org.graalvm.truffle {
requires java.logging;
requires jdk.unsupported;
requires transitive org.graalvm.sdk;
exports com.oracle.truffle.api to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler, org.graalvm.locator;
exports com.oracle.truffle.api.impl to jdk.internal.vm.compiler, org.graalvm.locator;
exports com.oracle.truffle.api.nodes to jdk.internal.vm.compiler;
exports com.oracle.truffle.api.object to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler;
exports com.oracle.truffle.object to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler;
exports com.oracle.truffle.api to com.oracle.graal.graal_enterprise, jdk.graal.compiler, org.graalvm.locator;
exports com.oracle.truffle.api.impl to jdk.graal.compiler, org.graalvm.locator;
exports com.oracle.truffle.api.nodes to jdk.graal.compiler;
exports com.oracle.truffle.api.object to com.oracle.graal.graal_enterprise, jdk.graal.compiler;
exports com.oracle.truffle.object to com.oracle.graal.graal_enterprise, jdk.graal.compiler;
uses com.oracle.truffle.api.TruffleRuntimeAccess;
uses com.oracle.truffle.api.impl.TruffleLocator;
uses com.oracle.truffle.api.object.LayoutFactory;
Expand Down Expand Up @@ -227,11 +227,11 @@ The GRAAL distribution shows how a single `exports` attribute can be used to spe
```
"GRAAL" : {
"moduleInfo" : {
"name" : "jdk.internal.vm.compiler",
"name" : "jdk.graal.compiler",
"exports" : [
# Qualified exports of all packages in GRAAL to modules built from
# ENTERPRISE_GRAAL and GRAAL_MANAGEMENT distributions
"* to com.oracle.graal.graal_enterprise,jdk.internal.vm.compiler.management",
"* to com.oracle.graal.graal_enterprise,jdk.graal.compiler.management",
],
...
},
Expand All @@ -241,14 +241,14 @@ The GRAAL distribution shows how a single `exports` attribute can be used to spe

This results info a `module-info.java` as that contains qualified exports, a small subset of which are shown below:
```
module jdk.internal.vm.compiler {
module jdk.graal.compiler {
...
exports org.graalvm.compiler.api.directives to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports org.graalvm.compiler.api.replacements to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports org.graalvm.compiler.api.runtime to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports org.graalvm.compiler.asm to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports org.graalvm.compiler.asm.aarch64 to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports org.graalvm.compiler.asm.amd64 to com.oracle.graal.graal_enterprise, jdk.internal.vm.compiler.management;
exports jdk.graal.compiler.api.directives to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
exports jdk.graal.compiler.api.replacements to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
exports jdk.graal.compiler.api.runtime to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
exports jdk.graal.compiler.asm to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
exports jdk.graal.compiler.asm.aarch64 to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
exports jdk.graal.compiler.asm.amd64 to com.oracle.graal.graal_enterprise, jdk.graal.compiler.management;
...
```

Expand All @@ -261,7 +261,7 @@ constituent projects.
If a project with a Java compliance >= 9 uses a package from a module other than `java.base`, it must specify these
additional modules with the `requires` attribute. For example:
```
"org.graalvm.compiler.hotspot.management.jdk11" : {
"jdk.graal.compiler.hotspot.management.jdk11" : {
...
"requires" : [
"jdk.management"
Expand All @@ -276,12 +276,12 @@ The `requires` attribute is used for two purposes:
* To derive a value for the `--limit-modules` javac option
which restricts the modules observable during compilation. This is required to support
separate compilation of projects that are part of a JDK module. For example,
`org.graalvm.compiler.hotspot.amd64` depends on `org.graalvm.compiler.hotspot`
and the classes of both these projects are contained in the `jdk.internal.vm.compiler`
module. When compiling `org.graalvm.compiler.hotspot.amd64`, we must compile against
classes in `org.graalvm.compiler.hotspot` as they might be different (i.e., newer)
than the classes in `jdk.internal.vm.compiler`. The value of `--limit-modules` will
omit `jdk.internal.vm.compiler` in this case to achieve this hiding. In the absence
`jdk.graal.compiler.hotspot.amd64` depends on `jdk.graal.compiler.hotspot`
and the classes of both these projects are contained in the `jdk.graal.compiler`
module. When compiling `jdk.graal.compiler.hotspot.amd64`, we must compile against
classes in `jdk.graal.compiler.hotspot` as they might be different (i.e., newer)
than the classes in `jdk.graal.compiler`. The value of `--limit-modules` will
omit `jdk.graal.compiler` in this case to achieve this hiding. In the absence
of a `requires` attribute, only the `java.base` module is observable when compiling
on JDK 9+.

Expand All @@ -291,7 +291,7 @@ Concealed packages are those defined by a module but not exported by the module.
If a project uses concealed packages, it must specify a `requiresConcealed` attribute
denoting the concealed packages it accesses. For example:
```
"org.graalvm.compiler.lir.aarch64.jdk11" : {
"jdk.graal.compiler.lir.aarch64.jdk11" : {
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
"jdk.vm.ci.aarch64",
Expand All @@ -303,7 +303,7 @@ denoting the concealed packages it accesses. For example:
```
This will result in `--add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED` and
`--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED` being added to the `javac`
command line when the `org.graalvm.compiler.lir.aarch64.jdk11` project is compiled by a
command line when the `jdk.graal.compiler.lir.aarch64.jdk11` project is compiled by a
JDK 9+ `javac`.

Note that the `requires` and `requiresConcealed` attributes only apply to projects with
Expand All @@ -312,30 +312,30 @@ conjunction with `-source 8` (as will be the case for projects with a minimum `j
of 8 or less), all classes in the JDK are observable. However, if an 8 project would need a
`requires` or `requiresConcealed` attribute were it a 9+ project, then these attributes must be
applied to any module containing the project. For example,
`org.graalvm.compiler.serviceprovider` has `"javaCompliance" : "8+"` and contains
code that imports `sun.misc.Unsafe`. Since `org.graalvm.compiler.serviceprovider`
is part of the `jdk.internal.vm.compiler` module defined by the `GRAAL` distribution,
`jdk.graal.compiler.serviceprovider` has `"javaCompliance" : "8+"` and contains
code that imports `sun.misc.Unsafe`. Since `jdk.graal.compiler.serviceprovider`
is part of the `jdk.graal.compiler` module defined by the `GRAAL` distribution,
`GRAAL` must include a `requires` attribute in its `moduleInfo` attribute:
```
"GRAAL" : {
"moduleInfo" : {
"name" : "jdk.internal.vm.compiler",
"name" : "jdk.graal.compiler",
"requires" : ["jdk.unsupported"],
...
}
}
```

Modules can be removed from the JDK. For example, [JDK-8255616](https://bugs.openjdk.java.net/browse/JDK-8255616)
removed the `jdk.aot`, `jdk.internal.vm.compile` and `jdk.internal.vm.compile.management` modules from standard JDK binaries
removed the `jdk.aot`, `jdk.internal.vm.compiler` and `jdk.internal.vm.compiler.management` modules from standard JDK binaries
as of JDK 16. Any `requiresConcealed` attributes targeting these modules must use a Java compliance qualifier so that
the relevant sources can still be built on JDK 16:
```
"com.oracle.svm.enterprise.jdk11.test": {
...
"requiresConcealed": {
"jdk.internal.vm.compiler@11..15": [
"org.graalvm.compiler.serviceprovider"
"jdk.graal.compiler@11..15": [
"jdk.graal.compiler.serviceprovider"
],
...
}
Expand Down
19 changes: 15 additions & 4 deletions ci/common.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local common_json = import "../common.json";
local variants(name) = [name, name + "Debug", name + "-llvm"],
# gets the JDK major version from a labsjdk version string (e.g., "ce-21+35-jvmci-23.1-b15" -> 21)
local parse_labsjdk_version(jdk) =
if jdk.name == "jpg-jdk" then jdk.version else
if jdk.name == "jpg-jdk" then std.parseInt(jdk.version) else
local version = jdk.version;
assert std.startsWith(version, "ce-") || std.startsWith(version, "ee-") : "Unsupported labsjdk version: " + version;
local number_prefix(str) =
Expand Down Expand Up @@ -107,7 +107,8 @@ local common_json = import "../common.json";
"windows-jdk19": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk20": { packages+: { "devkit:VS2022-17.1.0+1": "==0" }},
"windows-jdk21": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdkLatest": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdk-latest": { packages+: { "devkit:VS2022-17.1.0+1": "==1" }},
"windows-jdkLatest": self["windows-jdk-latest"],
"linux-jdk17": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
"linux-jdk19": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
"linux-jdk20": { packages+: { "devkit:gcc11.2.0-OL6.4+1": "==0" }},
Expand Down Expand Up @@ -149,6 +150,16 @@ local common_json = import "../common.json";
} else {},
},

local code_tools = {
downloads+: if 'jdk_version' in self && self.jdk_version > 21 then {
TOOLS_JAVA_HOME: jdks_data['oraclejdk21'],
} else {},
},
# GR-46676: ProGuard does not yet run on JDK 22
proguard: code_tools,
# GR-49566: SpotBugs does not yet run on JDK 22
spotbugs: code_tools,

sulong:: {
packages+: {
cmake: "==3.22.2",
Expand Down Expand Up @@ -259,9 +270,9 @@ local common_json = import "../common.json";

local common = mx + {
catch_files+: [
# Keep in sync with jdk.compiler.graal.debug.StandardPathUtilitiesProvider#DIAGNOSTIC_OUTPUT_DIRECTORY_MESSAGE_REGEXP
# Keep in sync with jdk.graal.compiler.debug.StandardPathUtilitiesProvider#DIAGNOSTIC_OUTPUT_DIRECTORY_MESSAGE_REGEXP
"Graal diagnostic output saved in '(?P<filename>[^']+)'",
# Keep in sync with jdk.compiler.graal.debug.DebugContext#DUMP_FILE_MESSAGE_REGEXP
# Keep in sync with jdk.graal.compiler.debug.DebugContext#DUMP_FILE_MESSAGE_REGEXP
"Dumping debug output to '(?P<filename>[^']+)'",
# Keep in sync with com.oracle.svm.hosted.NativeImageOptions#DEFAULT_ERROR_FILE_NAME
" (?P<filename>.+/svm_err_b_\\d+T\\d+\\.\\d+_pid\\d+\\.md)",
Expand Down
26 changes: 13 additions & 13 deletions 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": "6.51.4",
"mx_version": "6.52.0",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
Expand Down Expand Up @@ -35,20 +35,20 @@
"labsjdk-ee-20-llvm": {"name": "labsjdk", "version": "ee-20.0.2+2-jvmci-23.1-b02-sulong", "platformspecific": true },

"oraclejdk21": {"name": "jpg-jdk", "version": "21", "build_id": "33", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b21", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b21-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21+35-jvmci-23.1-b21-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b21", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b21-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b21-sulong", "platformspecific": true },
"labsjdk-ce-21": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22", "platformspecific": true },
"labsjdk-ce-21Debug": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22-debug", "platformspecific": true },
"labsjdk-ce-21-llvm": {"name": "labsjdk", "version": "ce-21.0.1+12-jvmci-23.1-b22-sulong", "platformspecific": true },
"labsjdk-ee-21": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22", "platformspecific": true },
"labsjdk-ee-21Debug": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-debug", "platformspecific": true },
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.1+11-jvmci-23.1-b22-sulong", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "22", "build_id": "18", "release": true, "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+18-jvmci-b02", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+18-jvmci-b02-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+18-jvmci-b02-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+18-jvmci-b02", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+18-jvmci-b02-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+18-jvmci-b02-sulong", "platformspecific": true }
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-22+18-jvmci-b03-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-22+18-jvmci-b03-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class MxJUnitWrapper {
// add --add-exports and --add-opens as necessary to the JVM command line.
//
// Known usages:
// org.graalvm.compiler.test.SubprocessUtil.getPackageOpeningOptions()
// jdk.graal.compiler.test.SubprocessUtil.getPackageOpeningOptions()
public static final String OPENED_PACKAGES_PROPERTY_NAME = "com.oracle.mxtool.junit.opens";
public static final String EXPORTED_PACKAGES_PROPERTY_NAME = "com.oracle.mxtool.junit.exports";

Expand Down
8 changes: 5 additions & 3 deletions mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -8062,7 +8062,8 @@ def addExportArgs(dep, exports=None, prefix='', jdk=None, observable_modules=Non
jmodsDir = join(self.jdk.home, 'jmods')

# If Graal is in the JDK we need to remove it to avoid conflicts with build artefacts
jmodsToRemove = ('jdk.internal.vm.compiler.jmod', 'jdk.internal.vm.compiler.management.jmod')
jmodsToRemove = ('jdk.internal.vm.compiler.jmod', 'jdk.internal.vm.compiler.management.jmod',
'jdk.graal.compiler.jmod', 'jdk.graal.compiler.management.jmod')
if any(exists(join(jmodsDir, jmod)) for jmod in jmodsToRemove):
# Use version and sha1 of source JDK's JAVA_HOME to ensure jmods copy is unique to source JDK
d = hashlib.sha1()
Expand Down Expand Up @@ -16832,7 +16833,8 @@ def is_visible(folder, names):

def _get_javadoc_module_args(projects, jdk):
additional_javadoc_args = []
jdk_excluded_modules = {'jdk.internal.vm.compiler', 'jdk.internal.vm.compiler.management'}
jdk_excluded_modules = {'jdk.internal.vm.compiler', 'jdk.internal.vm.compiler.management'
'jdk.graal.compiler', 'jdk.graal.compiler.management'}
additional_javadoc_args = [
'--limit-modules',
','.join([module.name for module in jdk.get_modules() if not module.name in jdk_excluded_modules])
Expand Down Expand Up @@ -18905,7 +18907,7 @@ def alarm_handler(signum, frame):
abort(1, killsig=signal.SIGINT)

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("6.52.0") # --tools-java-home
version = VersionSpec("6.53.0") # GR-49610 - Graal module and package renaming

_mx_start_datetime = datetime.utcnow()
_last_timestamp = _mx_start_datetime
Expand Down
2 changes: 1 addition & 1 deletion mx_ide_eclipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def processDep(dep, edge):
out.element('attribute', {'name' : 'module', 'value' : 'true'})
moduleDeps = p.get_concealed_imported_packages(jdk=jdk)
if len(moduleDeps) != 0:
# Ignore modules (such as jdk.internal.vm.compiler) that define packages
# Ignore modules (such as jdk.graal.compiler) that define packages
# that are also defined by project deps as the latter will have the most
# recent API.
exports = sorted([(module, pkgs) for module, pkgs in moduleDeps.items() if allProjectPackages.isdisjoint(pkgs)])
Expand Down
Loading

0 comments on commit 0e42632

Please sign in to comment.