Skip to content

Commit

Permalink
Fix confusion between native image name and executable name
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Apr 1, 2021
1 parent 49cc307 commit 57328b0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void setup(boolean processInheritIODisabled) {
public void cleanupServer(File outputDir) throws InterruptedException, IOException {
}

public int build(List<String> args, String nativeImageName, Path outputDir, boolean debugEnabled,
boolean processInheritIODisabled)
public int build(List<String> args, String nativeImageName, String resultingExecutableName, Path outputDir,
boolean debugEnabled, boolean processInheritIODisabled)
throws InterruptedException, IOException {
preBuild(args);
try {
Expand All @@ -69,10 +69,10 @@ public int build(List<String> 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.");
Expand All @@ -84,10 +84,10 @@ public int build(List<String> 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<String> args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -175,8 +176,8 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, NativeImageSourceJa

List<String> 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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 57328b0

Please sign in to comment.