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

Pass -H:+UnlockExperimentalVMOptions as necessary with Graalvm 23.1 #35379

Merged
merged 1 commit into from
Aug 20, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ public NativeImageInvokerInfo build() {
nativeImageArgs.add("-H:ImageBuildStatisticsFile=" + nativeImageName + "-timing-stats.json");
}
// For getting the build output stats as a JSON file
nativeImageArgs.add("-H:BuildOutputJSONFile=" + nativeImageName + "-build-output-stats.json");
addExperimentalVMOption(nativeImageArgs,
"-H:BuildOutputJSONFile=" + nativeImageName + "-build-output-stats.json");
}

/*
Expand All @@ -802,7 +803,7 @@ public NativeImageInvokerInfo build() {
*/
handleAdditionalProperties(nativeImageArgs);

nativeImageArgs.add("-H:+AllowFoldMethods");
addExperimentalVMOption(nativeImageArgs, "-H:+AllowFoldMethods");

if (nativeConfig.headless()) {
nativeImageArgs.add("-J-Djava.awt.headless=true");
Expand All @@ -824,7 +825,7 @@ public NativeImageInvokerInfo build() {
nativeImageArgs.add("--report-unsupported-elements-at-runtime");
}
if (nativeConfig.reportExceptionStackTraces()) {
nativeImageArgs.add("-H:+ReportExceptionStackTraces");
addExperimentalVMOption(nativeImageArgs, "-H:+ReportExceptionStackTraces");
}
if (nativeConfig.debug().enabled()) {
nativeImageArgs.add("-g");
Expand Down Expand Up @@ -897,11 +898,11 @@ public NativeImageInvokerInfo build() {
}
}
if (nativeConfig.autoServiceLoaderRegistration()) {
nativeImageArgs.add("-H:+UseServiceLoaderFeature");
addExperimentalVMOption(nativeImageArgs, "-H:+UseServiceLoaderFeature");
//When enabling, at least print what exactly is being added:
nativeImageArgs.add("-H:+TraceServiceLoaderFeature");
} else {
nativeImageArgs.add("-H:-UseServiceLoaderFeature");
addExperimentalVMOption(nativeImageArgs, "-H:-UseServiceLoaderFeature");
}
// This option has no effect on GraalVM 23.1+
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_1_0) < 0) {
Expand Down Expand Up @@ -1012,6 +1013,16 @@ private void handleAdditionalProperties(List<String> command) {
}
}
}

private void addExperimentalVMOption(List<String> nativeImageArgs, String option) {
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_1_0) >= 0) {
nativeImageArgs.add("-H:+UnlockExperimentalVMOptions");
}
nativeImageArgs.add(option);
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_1_0) >= 0) {
nativeImageArgs.add("-H:-UnlockExperimentalVMOptions");
}
Comment on lines +1017 to +1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you're surrounding the experimental option with enabling/disabling unlock? Is it really how it works? Never seen something similar :).

Copy link
Contributor Author

@zakkak zakkak Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this is to limit the scope as suggested in oracle/graal#7105 (comment). Alternatively we could just pass -H:+UnlockExperimentalVMOptions as the first option and allow any experimental option to be passed afterwards. It would make things simpler but would also allow people (both Quarkus users and devs) to use experimental options possibly without noticing.

}
}
}

Expand Down