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 authored and zakkak committed Apr 12, 2021
1 parent 1bc84bc commit 36ec894
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 @@ -42,8 +42,8 @@ public GraalVM.Version getGraalVMVersion() {
public void setup(boolean processInheritIODisabled) {
}

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 @@ -65,10 +65,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 @@ -80,10 +80,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 @@ -150,7 +150,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 @@ -183,8 +184,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 @@ -238,7 +239,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 @@ -253,7 +254,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 36ec894

Please sign in to comment.