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

Introduce --link-at-build-time flag for GraalVM 22.1 and later #24213

Merged
merged 1 commit into from
Mar 10, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

/**
* If any build item of this type is produced, the native-image build tool
* will run with {@literal --allow-incomplete-classpath} set.
* will run with {@literal --allow-incomplete-classpath} set for versions prior to 22.1 or
* without {@literal --link-at-build-time} set for versions later than 22.0.
* <p>
* This should be strongly discouraged as it makes diagnostics of any issue
* much more complex, and we have it seen affect error message of code
* much more complex, and we have seen it affect error messages of code
* seemingly unrelated to the code which is having the broken classpath.
* <p>
* Use of this build item will trigger a warning during build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,11 @@ public NativeImageInvokerInfo build() {
nativeImageArgs.add("-H:FallbackThreshold=0");
}

if (classpathIsBroken) {
// 22.1 removes --allow-incomplete-classpath and makes it the default. --link-at-build-time is now
// needed to bring back the old behavior (which requires all classes to be resolvable at build time).
if (graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && !classpathIsBroken) {
nativeImageArgs.add("--link-at-build-time");
} else if (!graalVMVersion.isNewerThan(GraalVM.Version.VERSION_22_0_0_2) && classpathIsBroken) {
nativeImageArgs.add("--allow-incomplete-classpath");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ NativeImageAllowIncompleteClasspathAggregateBuildItem aggregateIndividualItems(
final String extensionsRequiringBrokenClasspath = list.stream()
.map(NativeImageAllowIncompleteClasspathBuildItem::getExtensionName)
.collect(Collectors.joining(","));
log.warn("The following extensions have required the '--allow-incomplete-classpath' flag to be set: {"
log.warn("The following extensions have required native-image to allow run-time resolution of classes: {"
+ extensionsRequiringBrokenClasspath
+ "}. This is a global flag which might have unexpected effects on other extensions as well, and is a hint of the library "
+ "}. This is a global requirement which might have unexpected effects on other extensions as well, and is a hint of the library "
+
"needing some additional refactoring to better support GraalVM native-image. In the case of 3rd party dependencies and/or"
+
Expand Down