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

Don't pass '--enable-monitoring=heapdump' unconditionally on windows #43896

Merged
merged 2 commits into from
Oct 17, 2024
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 @@ -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
Loading