diff --git a/substratevm/CHANGELOG.md b/substratevm/CHANGELOG.md index 602a1b107f47..91615e71923d 100644 --- a/substratevm/CHANGELOG.md +++ b/substratevm/CHANGELOG.md @@ -16,6 +16,7 @@ At runtime, premain runtime options are set along with main class' arguments in * (GR-58383) The length of the printed stack trace when using `-XX:MissingRegistrationReportingMode=Warn` can now be set with `-XX:MissingRegistrationWarnContextLines=` and its default length is now 8. * (GR-58914) `ActiveProcessorCount` must be set at isolate or VM creation time. * (GR-59326) Ensure builder ForkJoin commonPool parallelism always respects NativeImageOptions.NumberOfThreads. +* (GR-60081) Native Image now targets `armv8.1-a` by default on AArch64. Use `-march=compatibility` for best compatibility or `-march=native` for best performance if the native executable is deployed on the same machine or on a machine with the same CPU features. To list all available machine types, use `-march=list`. ## GraalVM for JDK 23 (Internal Version 24.1.0) * (GR-51520) The old class initialization strategy, which was deprecated in GraalVM for JDK 22, is removed. The option `StrictImageHeap` no longer has any effect. diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageOptions.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageOptions.java index ad987a85ab9e..56b1c07019c1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageOptions.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageOptions.java @@ -86,7 +86,7 @@ public class NativeImageOptions { public static final String MICRO_ARCHITECTURE_LIST = "list"; @APIOption(name = "-march")// - @Option(help = "Generate instructions for a specific machine type. Defaults to 'x86-64-v3' on AMD64 and 'armv8-a' on AArch64. " + + @Option(help = "Generate instructions for a specific machine type. Defaults to 'x86-64-v3' on AMD64 and 'armv8.1-a' on AArch64. " + "Use -march=" + MICRO_ARCHITECTURE_COMPATIBILITY + " for best compatibility, or -march=" + MICRO_ARCHITECTURE_NATIVE + " for best performance if the native executable is deployed on the same machine or on a machine with the same CPU features. " + "To list all available machine types, use -march=" + MICRO_ARCHITECTURE_LIST + ".", type = User)// diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUType.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUType.java index 5b9e66fb8ba6..6f3caf17337d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUType.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUType.java @@ -80,7 +80,7 @@ static String getSelectedOrDefaultMArch() { } else if (Platform.includedIn(Platform.AMD64.class)) { return CPUTypeAMD64.getDefaultName(false); } else if (Platform.includedIn(Platform.AARCH64.class)) { - return CPUTypeAArch64.getDefaultName(); + return CPUTypeAArch64.getDefaultName(false); } else if (Platform.includedIn(Platform.RISCV64.class)) { return CPUTypeRISCV64.getDefaultName(); } else { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUTypeAArch64.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUTypeAArch64.java index 23e625f00abb..c04583d92635 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUTypeAArch64.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/CPUTypeAArch64.java @@ -45,6 +45,7 @@ import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.NativeImageOptions; +import com.oracle.svm.util.LogUtils; import com.oracle.svm.util.StringUtil; import jdk.vm.ci.aarch64.AArch64; @@ -113,15 +114,23 @@ public EnumSet getFeatures() { } } - public static String getDefaultName() { - return ARMV8_A.getName(); + public static String getDefaultName(boolean printFallbackWarning) { + if (NATIVE.getFeatures().containsAll(ARMV8_1_A.getFeatures())) { + return ARMV8_1_A.getName(); + } else { + if (printFallbackWarning) { + LogUtils.warning("The host machine does not support all features of '%s'. Falling back to '%s' for best compatibility.", + ARMV8_1_A.getName(), SubstrateOptionsParser.commandArgument(NativeImageOptions.MicroArchitecture, COMPATIBILITY.getName())); + } + return COMPATIBILITY.getName(); + } } @Platforms(Platform.HOSTED_ONLY.class) public static EnumSet getSelectedFeatures() { String value = NativeImageOptions.MicroArchitecture.getValue(); if (value == null) { - value = getDefaultName(); + value = getDefaultName(true); } return getCPUFeaturesForArch(value); }