From 57328b0ed9ccb1c04dc7e6445b930251868d0fc5 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 1 Apr 2021 14:48:56 +0200 Subject: [PATCH] Fix confusion between native image name and executable name --- .../NativeImageBuildRemoteContainerRunner.java | 5 ++++- .../pkg/steps/NativeImageBuildRunner.java | 16 ++++++++-------- .../pkg/steps/NativeImageBuildStep.java | 12 +++++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRemoteContainerRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRemoteContainerRunner.java index 393c6a378ed06..94aa3dc1cc492 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRemoteContainerRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRemoteContainerRunner.java @@ -17,11 +17,14 @@ public class NativeImageBuildRemoteContainerRunner extends NativeImageBuildConta private static final Logger log = Logger.getLogger(NativeImageBuildRemoteContainerRunner.class); private static final String CONTAINER_BUILD_VOLUME_NAME = "quarkus-native-builder-image-project-volume"; + private final String nativeImageName; private final String resultingExecutableName; private String containerId; - public NativeImageBuildRemoteContainerRunner(NativeConfig nativeConfig, Path outputDir, String resultingExecutableName) { + public NativeImageBuildRemoteContainerRunner(NativeConfig nativeConfig, Path outputDir, + String nativeImageName, String resultingExecutableName) { super(nativeConfig, outputDir); + this.nativeImageName = nativeImageName; this.resultingExecutableName = resultingExecutableName; } diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunner.java index 05ef4c0ba9730..4835fec16d7f6 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildRunner.java @@ -46,8 +46,8 @@ public void setup(boolean processInheritIODisabled) { public void cleanupServer(File outputDir) throws InterruptedException, IOException { } - public int build(List args, String nativeImageName, Path outputDir, boolean debugEnabled, - boolean processInheritIODisabled) + public int build(List args, String nativeImageName, String resultingExecutableName, Path outputDir, + boolean debugEnabled, boolean processInheritIODisabled) throws InterruptedException, IOException { preBuild(args); try { @@ -69,10 +69,10 @@ public int build(List args, String nativeImageName, Path outputDir, bool if (objcopyExists()) { if (debugEnabled) { - splitDebugSymbols(nativeImageName); + splitDebugSymbols(nativeImageName, resultingExecutableName); } else { // Strip debug symbols regardless, because the underlying JDK might contain them - objcopy("--strip-debug", nativeImageName); + objcopy("--strip-debug", resultingExecutableName); } } else { log.warn("objcopy executable not found in PATH. Debug symbols will not be separated from executable."); @@ -84,10 +84,10 @@ public int build(List args, String nativeImageName, Path outputDir, bool } } - private void splitDebugSymbols(String executable) { - String symbols = String.format("%s.debug", executable); - objcopy("--only-keep-debug", executable, symbols); - objcopy(String.format("--add-gnu-debuglink=%s", symbols), executable); + private void splitDebugSymbols(String nativeImageName, String resultingExecutableName) { + String symbols = String.format("%s.debug", nativeImageName); + objcopy("--only-keep-debug", resultingExecutableName, symbols); + objcopy(String.format("--add-gnu-debuglink=%s", symbols), resultingExecutableName); } protected abstract String[] getGraalVMVersionCommand(List args); 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 3c57ed966639a..d9cb1ba380810 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 @@ -146,7 +146,8 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa String nativeImageName = getNativeImageName(outputTargetBuildItem, packageConfig); String resultingExecutableName = getResultingExecutableName(nativeImageName, isContainerBuild); - NativeImageBuildRunner buildRunner = getNativeImageBuildRunner(nativeConfig, outputDir, resultingExecutableName); + NativeImageBuildRunner buildRunner = getNativeImageBuildRunner(nativeConfig, outputDir, + nativeImageName, resultingExecutableName); buildRunner.setup(processInheritIODisabled.isPresent()); final GraalVM.Version graalVMVersion = buildRunner.getGraalVMVersion(); @@ -175,8 +176,8 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa List nativeImageArgs = commandAndExecutable.args; - int exitCode = buildRunner.build(nativeImageArgs, nativeImageName, outputDir, nativeConfig.debug.enabled, - processInheritIODisabled.isPresent()); + int exitCode = buildRunner.build(nativeImageArgs, nativeImageName, resultingExecutableName, outputDir, + nativeConfig.debug.enabled, processInheritIODisabled.isPresent()); if (exitCode != 0) { throw imageGenerationFailed(exitCode, nativeImageArgs); } @@ -227,7 +228,7 @@ public static boolean isContainerBuild(NativeConfig nativeConfig) { } private static NativeImageBuildRunner getNativeImageBuildRunner(NativeConfig nativeConfig, Path outputDir, - String resultingExecutableName) { + String nativeImageName, String resultingExecutableName) { if (!isContainerBuild(nativeConfig)) { NativeImageBuildLocalRunner localRunner = getNativeImageBuildLocalRunner(nativeConfig, outputDir.toFile()); if (localRunner != null) { @@ -242,7 +243,8 @@ private static NativeImageBuildRunner getNativeImageBuildRunner(NativeConfig nat log.warn(errorMessage + " Attempting to fall back to container build."); } if (nativeConfig.remoteContainerBuild) { - return new NativeImageBuildRemoteContainerRunner(nativeConfig, outputDir, resultingExecutableName); + return new NativeImageBuildRemoteContainerRunner(nativeConfig, outputDir, + nativeImageName, resultingExecutableName); } return new NativeImageBuildLocalContainerRunner(nativeConfig, outputDir); }