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

Only build and include svm-foreign when building with JDK > 21 #398

Closed
Closed
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
13 changes: 8 additions & 5 deletions build.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ public static void main(String... args) throws IOException
FileSystem.copy(mandrelRepo.resolve(
Path.of("sdk", "mxbuild", PLATFORM, "native-image.exe.image-bash", "native-image.export-list")), nativeImageExport);
}
logger.debugf("Copy svm-preview...");
final Path svmForeign = mandrelJavaHome.resolve(Path.of("lib", "svm-preview", "builder", "svm-foreign.jar"));
final Path svmForeignSource = PathFinder.getFirstExisting(mandrelRepo.resolve(Path.of("substratevm", "mxbuild")).toString(), "svm-foreign.jar");
FileSystem.copy(svmForeignSource, svmForeign);
if (Runtime.version().feature() > 21)
{
logger.debugf("Copy svm-preview...");
final Path svmForeign = mandrelJavaHome.resolve(Path.of("lib", "svm-preview", "builder", "svm-foreign.jar"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

svm-preview folder is wrong as a target for JDK 22+. See graalvm/mandrel#678 for some details.

final Path svmForeignSource = PathFinder.getFirstExisting(mandrelRepo.resolve(Path.of("substratevm", "mxbuild")).toString(), "svm-foreign.jar");
FileSystem.copy(svmForeignSource, svmForeign);
}
}

if (!options.skipNative)
Expand Down Expand Up @@ -855,7 +858,7 @@ class Mx
Pattern.compile("\"version\"\\s*:\\s*\"([0-9.]*)\"");

static final List<BuildArgs> BUILD_JAVA_STEPS = List.of(
BuildArgs.of("--no-native", "--dependencies", "SVM,SVM_FOREIGN,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT")
jerboaa marked this conversation as resolved.
Show resolved Hide resolved
BuildArgs.of("--no-native", "--dependencies", "SVM,GRAAL_SDK,SVM_DRIVER,SVM_AGENT,SVM_DIAGNOSTICS_AGENT" + (Runtime.version().feature() > 21 ? ",SVM_FOREIGN" : ""))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if it makes sense to conditionalize on this for JDK 21. IIRC, this will only work with JDK 22+ Between JDK 21 and JDK 22 the API changed slightly, so I'd be surprised if this still worked. I think it's also something the GraalVM team is aware of:
oracle/graal#8012 (see the note about "Foreign Function and Memory API support")

We have the 23.1 branch for JDK 21 compatible builds. Not sure if we should fix it in master.

, BuildArgs.of("--only",
build.IS_WINDOWS ?
"native-image.exe.image-bash," +
Expand Down
Loading