Skip to content

Commit

Permalink
Merge pull request #43896 from zakkak/2024-10-16-fix-43895
Browse files Browse the repository at this point in the history
Don't pass '--enable-monitoring=heapdump' unconditionally on windows
  • Loading branch information
zakkak authored Oct 17, 2024
2 parents 13d48dd + 26c2c48 commit 1c1de90
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.lang3.SystemUtils;
import org.jboss.logging.Logger;

import io.quarkus.bootstrap.util.IoUtils;
Expand Down Expand Up @@ -53,6 +52,7 @@
import io.quarkus.runtime.graal.DisableLoggingFeature;
import io.quarkus.sbom.ApplicationComponent;
import io.quarkus.sbom.ApplicationManifestConfig;
import io.smallrye.common.os.OS;

public class NativeImageBuildStep {

Expand Down Expand Up @@ -210,7 +210,7 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon
String pie = "";

boolean isContainerBuild = nativeImageRunner.isContainerBuild();
if (!isContainerBuild && SystemUtils.IS_OS_LINUX) {
if (!isContainerBuild && OS.LINUX.isCurrent()) {
if (nativeConfig.pie().isPresent() && nativeConfig.pie().get()) {
pie = detectPIE();
} else {
Expand Down Expand Up @@ -332,7 +332,7 @@ private String getNativeImageName(OutputTargetBuildItem outputTargetBuildItem, P

private String getResultingExecutableName(String nativeImageName, boolean isContainerBuild) {
String resultingExecutableName = nativeImageName;
if (SystemUtils.IS_OS_WINDOWS && !isContainerBuild) {
if (OS.WINDOWS.isCurrent() && !isContainerBuild) {
//once image is generated it gets added .exe on Windows
resultingExecutableName = resultingExecutableName + ".exe";
}
Expand All @@ -354,7 +354,7 @@ public NativeImageRunnerBuildItem resolveNativeImageBuildRunner(NativeConfig nat
String executableName = getNativeImageExecutableName();
String errorMessage = "Cannot find the `" + executableName
+ "` in the GRAALVM_HOME, JAVA_HOME and System PATH.";
if (!SystemUtils.IS_OS_LINUX) {
if (!OS.LINUX.isCurrent()) {
// Delay the error: if we're just building native sources, we may not need the build runner at all.
return new NativeImageRunnerBuildItem(new NativeImageBuildRunnerError(errorMessage));
}
Expand Down Expand Up @@ -474,7 +474,7 @@ private static void copySourcesToSourceCache(OutputTargetBuildItem outputTargetB

private RuntimeException imageGenerationFailed(int exitValue, boolean isContainerBuild) {
if (exitValue == OOM_ERROR_VALUE) {
if (isContainerBuild && !SystemUtils.IS_OS_LINUX) {
if (isContainerBuild && !OS.LINUX.isCurrent()) {
return new ImageGenerationFailureException("Image generation failed. Exit code was " + exitValue
+ " which indicates an out of memory error. The most likely cause is Docker not being given enough memory. Also consider increasing the Xmx value for native image generation by setting the \""
+ QUARKUS_XMX_PROPERTY + "\" property");
Expand Down Expand Up @@ -554,7 +554,7 @@ private static NativeImageBuildLocalRunner getNativeImageBuildLocalRunner(Native
}

private static String getNativeImageExecutableName() {
return SystemUtils.IS_OS_WINDOWS ? "native-image.cmd" : "native-image";
return OS.WINDOWS.isCurrent() ? "native-image.cmd" : "native-image";
}

private static String detectNoPIE() {
Expand Down Expand Up @@ -932,13 +932,18 @@ public NativeImageInvokerInfo build() {
}

List<NativeConfig.MonitoringOption> monitoringOptions = new ArrayList<>();
monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP);
if (!OS.WINDOWS.isCurrent() || containerBuild) {
// --enable-monitoring=heapdump is not supported on Windows
monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP);
}
if (nativeConfig.monitoring().isPresent()) {
monitoringOptions.addAll(nativeConfig.monitoring().get());
}
nativeImageArgs.add("--enable-monitoring=" + monitoringOptions.stream()
.distinct()
.map(o -> o.name().toLowerCase(Locale.ROOT)).collect(Collectors.joining(",")));
if (!monitoringOptions.isEmpty()) {
nativeImageArgs.add("--enable-monitoring=" + monitoringOptions.stream()
.distinct()
.map(o -> o.name().toLowerCase(Locale.ROOT)).collect(Collectors.joining(",")));
}

if (nativeConfig.autoServiceLoaderRegistration()) {
addExperimentalVMOption(nativeImageArgs, "-H:+UseServiceLoaderFeature");
Expand Down

0 comments on commit 1c1de90

Please sign in to comment.