diff --git a/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json b/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json index 98149aaca8ba..7b24fd106192 100644 --- a/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json +++ b/docs/reference-manual/native-image/assets/build-output-schema-v0.9.3.json @@ -30,7 +30,7 @@ "name": { "type": "string", "default": "", - "title": "The name of the native executable" + "title": "The file name of the native executable (including file extension if any)" }, "graalvm_version": { "type": "string", diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java index 3632ffe75569..e67e4a8d6f99 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureImpl.java @@ -744,6 +744,10 @@ public AbstractImage getImage() { return image; } + public String getOutputFilename() { + return image.getImageKind().getOutputFilename(imageName); + } + public RuntimeConfiguration getRuntimeConfiguration() { return runtimeConfig; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java index 8a06dbf129b3..77a4a1be503a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java @@ -208,10 +208,11 @@ public void setForeignFunctionsInfo(int numDowncallStubs, int numUpcallStubs) { public void printStart(String imageName, NativeImageKind imageKind) { l().printHeadlineSeparator(); - recordJsonMetric(GeneralInfo.IMAGE_NAME, imageName); + String outputFilename = imageKind.getOutputFilename(imageName); + recordJsonMetric(GeneralInfo.NAME, outputFilename); String imageKindName = imageKind.name().toLowerCase(Locale.ROOT).replace('_', ' '); l().blueBold().link("GraalVM Native Image", "https://www.graalvm.org/native-image/").reset() - .a(": Generating '").bold().a(imageName).reset().a("' (").doclink(imageKindName, "#glossary-imagekind").a(")...").println(); + .a(": Generating '").bold().a(outputFilename).reset().a("' (").doclink(imageKindName, "#glossary-imagekind").a(")...").println(); l().printHeadlineSeparator(); if (!linkStrategy.isTerminalSupported()) { l().a("For detailed information and explanations on the build output, visit:").println(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java index ba3b991571cd..cac196262eaa 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java @@ -216,7 +216,7 @@ public void record(ProgressReporterJsonHelper helper, Object value) { } public enum GeneralInfo implements JsonMetric { - IMAGE_NAME("name", null), + NAME("name", null), JAVA_VERSION("java_version", null), VENDOR_VERSION("vendor_version", null), GRAALVM_VERSION("graalvm_version", null), diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java index 0ab223ad6b1f..ca9f54ac3e4a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/AbstractImage.java @@ -53,13 +53,13 @@ public enum NativeImageKind { /* IMAGE_LAYER mimics a SHARED_LIBRARY. */ IMAGE_LAYER(false, true) { @Override - public String getFilenameSuffix() { + protected String getFilenameSuffix() { return ".so"; } }, SHARED_LIBRARY(false) { @Override - public String getFilenameSuffix() { + protected String getFilenameSuffix() { return switch (ObjectFile.getNativeFormat()) { case ELF -> ".so"; case MACH_O -> ".dylib"; @@ -85,7 +85,11 @@ public String getFilenameSuffix() { mainEntryPointName = executable ? "main" : "run_main"; } - public String getFilenameSuffix() { + public final String getOutputFilename(String imageName) { + return imageName + getFilenameSuffix(); + } + + protected String getFilenameSuffix() { return ObjectFile.getNativeFormat() == ObjectFile.Format.PECOFF ? ".exe" : ""; } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java index e9ffffeb0a53..691b9baf20ba 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/CCLinkerInvocation.java @@ -591,7 +591,7 @@ static LinkerInvocation getLinkerInvocation(AbstractImage.NativeImageKind imageK break; } - Path outputFile = outputDirectory.resolve(imageName + imageKind.getFilenameSuffix()); + Path outputFile = outputDirectory.resolve(imageKind.getOutputFilename(imageName)); UserError.guarantee(!Files.isDirectory(outputFile), "Cannot write image to %s. Path exists as directory (use '-o /path/to/image').", outputFile); inv.setOutputFile(outputFile); inv.setTempDirectory(tempDirectory); diff --git a/substratevm/src/com.oracle.svm.interpreter/src/com/oracle/svm/interpreter/DebuggerFeature.java b/substratevm/src/com.oracle.svm.interpreter/src/com/oracle/svm/interpreter/DebuggerFeature.java index 6db823fffc92..9e2431b24719 100644 --- a/substratevm/src/com.oracle.svm.interpreter/src/com/oracle/svm/interpreter/DebuggerFeature.java +++ b/substratevm/src/com.oracle.svm.interpreter/src/com/oracle/svm/interpreter/DebuggerFeature.java @@ -24,12 +24,12 @@ */ package com.oracle.svm.interpreter; +import static com.oracle.svm.hosted.pltgot.GOTEntryAllocator.GOT_NO_ENTRY; import static com.oracle.svm.interpreter.metadata.Bytecodes.INVOKEDYNAMIC; import static com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaMethod.EST_NO_ENTRY; import static com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaMethod.VTBL_NO_ENTRY; import static com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaMethod.VTBL_ONE_IMPL; import static com.oracle.svm.interpreter.metadata.InterpreterUniverseImpl.toHexString; -import static com.oracle.svm.hosted.pltgot.GOTEntryAllocator.GOT_NO_ENTRY; import java.io.IOException; import java.lang.reflect.Constructor; @@ -73,18 +73,6 @@ import com.oracle.svm.core.meta.MethodPointer; import com.oracle.svm.core.option.HostedOptionValues; import com.oracle.svm.core.util.VMError; -import com.oracle.svm.interpreter.classfile.ClassFile; -import com.oracle.svm.interpreter.metadata.BytecodeStream; -import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaField; -import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaMethod; -import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaType; -import com.oracle.svm.interpreter.metadata.InterpreterResolvedObjectType; -import com.oracle.svm.interpreter.metadata.InterpreterUniverse; -import com.oracle.svm.interpreter.metadata.InterpreterUniverseImpl; -import com.oracle.svm.interpreter.metadata.MetadataUtil; -import com.oracle.svm.interpreter.metadata.ReferenceConstant; -import com.oracle.svm.interpreter.metadata.serialization.SerializationContext; -import com.oracle.svm.interpreter.metadata.serialization.Serializers; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.NativeImageGenerator; import com.oracle.svm.hosted.code.CompileQueue; @@ -101,6 +89,18 @@ import com.oracle.svm.hosted.pltgot.PLTGOTOptions; import com.oracle.svm.hosted.snippets.SubstrateGraphBuilderPlugins; import com.oracle.svm.hosted.substitute.SubstitutionMethod; +import com.oracle.svm.interpreter.classfile.ClassFile; +import com.oracle.svm.interpreter.metadata.BytecodeStream; +import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaField; +import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaMethod; +import com.oracle.svm.interpreter.metadata.InterpreterResolvedJavaType; +import com.oracle.svm.interpreter.metadata.InterpreterResolvedObjectType; +import com.oracle.svm.interpreter.metadata.InterpreterUniverse; +import com.oracle.svm.interpreter.metadata.InterpreterUniverseImpl; +import com.oracle.svm.interpreter.metadata.MetadataUtil; +import com.oracle.svm.interpreter.metadata.ReferenceConstant; +import com.oracle.svm.interpreter.metadata.serialization.SerializationContext; +import com.oracle.svm.interpreter.metadata.serialization.Serializers; import com.oracle.svm.util.ModuleSupport; import jdk.graal.compiler.api.replacements.SnippetReflectionProvider; @@ -697,13 +697,7 @@ public void beforeImageWrite(BeforeImageWriteAccess access) { // Be explicit here: .metadata file is derived from - String imageFileName = accessImpl.getImageName(); - String extension = accessImpl.getImage().getImageKind().getFilenameSuffix(); - if (!imageFileName.endsWith(extension)) { - imageFileName += extension; - } - - String metadataFileName = MetadataUtil.metadataFileName(imageFileName); + String metadataFileName = MetadataUtil.metadataFileName(accessImpl.getOutputFilename()); Path metadataPath = destDir.resolve(metadataFileName); int crc32;