Skip to content

Commit

Permalink
Merge pull request quarkusio#43455 from zakkak/2024-09-24-drop-22.3-s…
Browse files Browse the repository at this point in the history
…upport

Drop GraalVM 22.3 (JDK 17) minimum support
  • Loading branch information
zakkak authored Sep 26, 2024
2 parents e6e4daa + a713d50 commit d9c37eb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public static final class Version implements Comparable<Version> {

static final Version VERSION_21_3 = new Version("GraalVM 21.3", "21.3", Distribution.GRAALVM);
static final Version VERSION_21_3_0 = new Version("GraalVM 21.3.0", "21.3.0", Distribution.GRAALVM);
public static final Version VERSION_22_3_0 = new Version("GraalVM 22.3.0", "22.3.0", "17", Distribution.GRAALVM);
public static final Version VERSION_23_0_0 = new Version("GraalVM 23.0.0", "23.0.0", "17", Distribution.GRAALVM);
public static final Version VERSION_23_1_0 = new Version("GraalVM 23.1.0", "23.1.0", "21", Distribution.GRAALVM);
public static final Version VERSION_24_0_0 = new Version("GraalVM 24.0.0", "24.0.0", "22", Distribution.GRAALVM);
Expand All @@ -198,7 +197,7 @@ public static final class Version implements Comparable<Version> {
* The minimum version of GraalVM supported by Quarkus.
* Versions prior to this are expected to cause major issues.
*/
public static final Version MINIMUM = VERSION_22_3_0;
public static final Version MINIMUM = VERSION_23_0_0;
/**
* The current version of GraalVM supported by Quarkus.
* This version is the one actively being tested and is expected to give the best experience.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ public Result build(List<String> args, String nativeImageName, String resultingE
return new Result(exitCode);
}

if (debugSymbolsEnabled && graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) < 0 && objcopyExists) {
// Need to explicitly split debug symbols prior to GraalVM/Mandrel 23.0
splitDebugSymbols(outputDir, nativeImageName, resultingExecutableName);
}
if (!(debugSymbolsEnabled && graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0)) {
if (!debugSymbolsEnabled) {
// Strip debug symbols even if not generated by GraalVM/Mandrel, because the underlying JDK might
// contain them. Note, however, that starting with GraalVM/Mandrel 23.0 this is done by default when
// generating debug info, so we don't want to do it twice and print twice a warning if objcopy is not
Expand All @@ -98,12 +94,6 @@ public Result build(List<String> args, String nativeImageName, String resultingE
}
}

private void splitDebugSymbols(Path outputDir, String nativeImageName, String resultingExecutableName) {
String symbols = String.format("%s.debug", nativeImageName);
objcopy(outputDir, "--only-keep-debug", resultingExecutableName, symbols);
objcopy(outputDir, String.format("--add-gnu-debuglink=%s", symbols), resultingExecutableName);
}

protected abstract String[] getGraalVMVersionCommand(List<String> args);

protected abstract String[] getBuildCommand(Path outputDir, List<String> args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,21 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon
}
}

if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
// See https://github.com/oracle/graal/issues/4921
try (DirectoryStream<Path> sharedLibs = Files.newDirectoryStream(outputDir, "*.{so,dll}")) {
sharedLibs.forEach(src -> {
Path dst = null;
try {
dst = Path.of(outputTargetBuildItem.getOutputDirectory().toAbsolutePath().toString(),
src.getFileName().toString());
log.debugf("Copying a shared lib from %s to %s.", src, dst);
Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
log.errorf("Could not copy shared lib from %s to %s. Continuing. Error: %s", src, dst, e);
}
});
} catch (IOException e) {
log.errorf("Could not list files in directory %s. Continuing. Error: %s", outputDir, e);
}
// See https://github.com/oracle/graal/issues/4921
try (DirectoryStream<Path> sharedLibs = Files.newDirectoryStream(outputDir, "*.{so,dll}")) {
sharedLibs.forEach(src -> {
Path dst = null;
try {
dst = Path.of(outputTargetBuildItem.getOutputDirectory().toAbsolutePath().toString(),
src.getFileName().toString());
log.debugf("Copying a shared lib from %s to %s.", src, dst);
Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
log.errorf("Could not copy shared lib from %s to %s. Continuing. Error: %s", src, dst, e);
}
});
} catch (IOException e) {
log.errorf("Could not list files in directory %s. Continuing. Error: %s", outputDir, e);
}

System.setProperty("native.image.path", finalExecutablePath.toAbsolutePath().toString());
Expand Down Expand Up @@ -784,7 +782,7 @@ public NativeImageInvokerInfo build() {
}
nativeImageArgs.add("--features=" + String.join(",", featuresList));

if (nativeConfig.debug().enabled() && graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
if (nativeConfig.debug().enabled()) {
/*
* Instruct GraalVM / Mandrel to keep more accurate information about source locations when generating
* debug info for debugging and monitoring tools. This parameter may break compatibility with Truffle.
Expand Down Expand Up @@ -821,23 +819,12 @@ public NativeImageInvokerInfo build() {
addExperimentalVMOption(nativeImageArgs, "-H:PrintAnalysisCallTreeType=CSV");
}

// only available in GraalVM 22.3.0+.
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_22_3_0) >= 0) {
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) < 0) {
// Used to retrieve build time information in 22.3. Starting with 23.0 this info is included in
// the build output json file so there is no need to generate extra files.
nativeImageArgs.add("-H:+CollectImageBuildStatistics");
nativeImageArgs.add("-H:ImageBuildStatisticsFile=" + nativeImageName + "-timing-stats.json");
}
// For getting the build output stats as a JSON file
addExperimentalVMOption(nativeImageArgs,
"-H:BuildOutputJSONFile=" + nativeImageName + "-build-output-stats.json");
}
// For getting the build output stats as a JSON file
addExperimentalVMOption(nativeImageArgs,
"-H:BuildOutputJSONFile=" + nativeImageName + "-build-output-stats.json");

// only available in GraalVM 23.0+, we want a file with the list of built artifacts
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
addExperimentalVMOption(nativeImageArgs, "-H:+GenerateBuildArtifactsFile");
}
// Generate a file with the list of built artifacts
addExperimentalVMOption(nativeImageArgs, "-H:+GenerateBuildArtifactsFile");

// only available in GraalVM 23.1.0+
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_1_0) >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import io.quarkus.deployment.pkg.builditem.NativeImageRunnerBuildItem;
import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem;
import io.quarkus.deployment.pkg.builditem.UpxCompressedBuildItem;
import io.quarkus.deployment.pkg.steps.GraalVM;
import io.quarkus.deployment.pkg.steps.NativeBuild;

/**
Expand Down Expand Up @@ -143,23 +142,19 @@ public void nativeZip(OutputTargetBuildItem target,
}
addZipEntry(zip, nativeImage.getPath(), executableName, 0755);

final GraalVM.Version graalVMVersion = nativeImageRunner.getBuildRunner().getGraalVMVersion();
if (graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
// See https://github.com/oracle/graal/issues/4921
try (DirectoryStream<Path> sharedLibs = Files.newDirectoryStream(nativeImage.getPath().getParent(),
"*.{so,dll}")) {
sharedLibs.forEach(src -> {
try {
// In this use case, we can force all libs to be non-executable.
addZipEntry(zip, src, src.getFileName().toString(), 0644);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
} catch (IOException e) {
log.errorf("Could not list files in directory %s. Continuing. Error: %s", nativeImage.getPath().getParent(),
e);
}
// See https://github.com/oracle/graal/issues/4921
try (DirectoryStream<Path> sharedLibs = Files.newDirectoryStream(nativeImage.getPath().getParent(),
"*.{so,dll}")) {
sharedLibs.forEach(src -> {
try {
// In this use case, we can force all libs to be non-executable.
addZipEntry(zip, src, src.getFileName().toString(), 0644);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
} catch (IOException e) {
log.errorf("Could not list files in directory %s. Continuing. Error: %s", nativeImage.getPath().getParent(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,22 @@ void setupAWTInit(BuildProducer<JniRuntimeAccessBuildItem> jc,
Optional<ProcessInheritIODisabledBuildItem> processInheritIODisabledBuildItem) {
nativeImageRunnerBuildItem.getBuildRunner()
.setup(processInheritIODisabled.isPresent() || processInheritIODisabledBuildItem.isPresent());
final GraalVM.Version v;
if (nativeImageRunnerBuildItem.getBuildRunner() instanceof NoopNativeImageBuildRunner) {
v = CURRENT;
log.warnf("native-image is not installed. " +
"Using the default %s version as a reference to build native-sources step.", v.getVersionAsString());
} else {
v = nativeImageRunnerBuildItem.getBuildRunner().getGraalVMVersion();
}
// Dynamically loading shared objects instead
// of baking in static libs: https://github.com/oracle/graal/issues/4921
if (v.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "load", "java.lang.String"));
jm.produce(
new JniRuntimeAccessMethodBuildItem("java.lang.System", "setProperty", "java.lang.String",
"java.lang.String"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLock"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotify"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotifyAll"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockWait", "long"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtUnlock"));
jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK"));
jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK_COND"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.X11.XErrorHandlerUtil", "init", "long"));
jc.produce(new JniRuntimeAccessBuildItem(false, false, true, "sun.awt.X11.XToolkit"));
jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.Thread", "yield"));
}
jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.System", "load", "java.lang.String"));
jm.produce(
new JniRuntimeAccessMethodBuildItem("java.lang.System", "setProperty", "java.lang.String",
"java.lang.String"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLock"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotify"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockNotifyAll"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtLockWait", "long"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.SunToolkit", "awtUnlock"));
jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK"));
jf.produce(new JniRuntimeAccessFieldBuildItem("sun.awt.SunToolkit", "AWT_LOCK_COND"));
jm.produce(new JniRuntimeAccessMethodBuildItem("sun.awt.X11.XErrorHandlerUtil", "init", "long"));
jc.produce(new JniRuntimeAccessBuildItem(false, false, true, "sun.awt.X11.XToolkit"));
jm.produce(new JniRuntimeAccessMethodBuildItem("java.lang.Thread", "yield"));
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
Expand Down Expand Up @@ -275,15 +265,13 @@ JniRuntimeAccessBuildItem setupJava2DClasses(NativeImageRunnerBuildItem nativeIm

// A new way of dynamically loading shared objects instead
// of baking in static libs: https://github.com/oracle/graal/issues/4921
if (v.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0) {
classes.add("sun.awt.X11FontManager");
if (v.javaVersion.feature() != 19) {
classes.add("java.awt.GraphicsEnvironment");
classes.add("sun.awt.X11GraphicsConfig");
classes.add("sun.awt.X11GraphicsDevice");
classes.add("sun.java2d.SunGraphicsEnvironment");
classes.add("sun.java2d.xr.XRSurfaceData");
}
classes.add("sun.awt.X11FontManager");
if (v.javaVersion.feature() != 19) {
classes.add("java.awt.GraphicsEnvironment");
classes.add("sun.awt.X11GraphicsConfig");
classes.add("sun.awt.X11GraphicsDevice");
classes.add("sun.java2d.SunGraphicsEnvironment");
classes.add("sun.java2d.xr.XRSurfaceData");
}

// Added for JDK 19+ due to: https://github.com/openjdk/jdk20/commit/9bc023220 calling FontUtilities
Expand Down

0 comments on commit d9c37eb

Please sign in to comment.