From ebdc223f0e821814f40dc5a57e5bf86bb1559e36 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 13 May 2024 16:09:10 +0300 Subject: [PATCH] Add an 'march' property to native configuration Follows up on: #34238 --- .../main/java/io/quarkus/deployment/pkg/NativeConfig.java | 8 ++++++++ .../deployment/pkg/steps/NativeImageBuildStep.java | 3 +++ .../java/io/quarkus/deployment/pkg/TestNativeConfig.java | 5 +++++ docs/src/main/asciidoc/native-reference.adoc | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java index badd6a7c63343..310090fd7c1ee 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/NativeConfig.java @@ -219,6 +219,14 @@ public interface NativeConfig { */ Optional pie(); + /** + * Generate instructions for a specific machine type. Defaults to {@code x86-64-v3} on AMD64 and {@code armv8-a} on AArch64. + * Use {@code compatibility} for best compatibility, or {@code native} for best performance if a native executable is + * deployed on the same machine or on a machine with the same CPU features. + * A list of all available machine types is available by executing {@code native-image -march=list} + */ + Optional march(); + /** * If this build is done using a remote docker daemon. */ diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index 5f863d2301c03..bf483fae4621f 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -906,6 +906,9 @@ public NativeImageInvokerInfo build() { if (nativeConfig.enableVmInspection()) { addExperimentalVMOption(nativeImageArgs, "-H:+AllowVMInspection"); } + if (nativeConfig.march().isPresent()) { + nativeImageArgs.add("-march=" + nativeConfig.march().get()); + } List monitoringOptions = new ArrayList<>(); monitoringOptions.add(NativeConfig.MonitoringOption.HEAPDUMP); diff --git a/core/deployment/src/test/java/io/quarkus/deployment/pkg/TestNativeConfig.java b/core/deployment/src/test/java/io/quarkus/deployment/pkg/TestNativeConfig.java index 2cf219198444a..0a0f28227bb26 100644 --- a/core/deployment/src/test/java/io/quarkus/deployment/pkg/TestNativeConfig.java +++ b/core/deployment/src/test/java/io/quarkus/deployment/pkg/TestNativeConfig.java @@ -150,6 +150,11 @@ public Optional pie() { return Optional.empty(); } + @Override + public Optional march() { + return Optional.empty(); + } + @Override public boolean remoteContainerBuild() { return false; diff --git a/docs/src/main/asciidoc/native-reference.adoc b/docs/src/main/asciidoc/native-reference.adoc index 09cc190e96950..8c7d741a5a8b1 100644 --- a/docs/src/main/asciidoc/native-reference.adoc +++ b/docs/src/main/asciidoc/native-reference.adoc @@ -2255,7 +2255,7 @@ To work around that issue, add the following line to the `application.properties [source, properties] ---- -quarkus.native.additional-build-args=-march=compatibility +quarkus.native.march=compatibility ---- Then, rebuild your native executable.