Skip to content

Commit

Permalink
Delegate striping of debug symbols to GraalVM/Mandrel when >23.0
Browse files Browse the repository at this point in the history
Starting with GraalVM/Mandrel 23.0, native-image strips debug info in a
separate file by default.

Fixes quarkusio#31258
  • Loading branch information
zakkak committed Feb 21, 2023
1 parent c33da73 commit ad468ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void addShutdownHook(Process buildNativeProcess) {
}

public Result build(List<String> args, String nativeImageName, String resultingExecutableName, Path outputDir,
boolean debugSymbolsEnabled, boolean processInheritIODisabled)
GraalVM.Version graalVMVersion, boolean debugSymbolsEnabled, boolean processInheritIODisabled)
throws InterruptedException, IOException {
preBuild(args);
try {
Expand All @@ -69,16 +69,22 @@ public Result build(List<String> args, String nativeImageName, String resultingE
return new Result(exitCode);
}

if (objcopyExists) {
if (debugSymbolsEnabled) {
splitDebugSymbols(nativeImageName, resultingExecutableName);
if (debugSymbolsEnabled && graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) < 0 && objcopyExists) {
// Need to explicitly split debug symbols prior to GraalVM/Mandrel 23.0
splitDebugSymbols(nativeImageName, resultingExecutableName);
}
if (!(debugSymbolsEnabled && graalVMVersion.compareTo(GraalVM.Version.VERSION_23_0_0) >= 0)) {
// Strip debug symbols even if not generated by GraalVM/Mandrel, because the underlying JDK might
// contain them. Note, however, that starting with GraalVM/Mandrel 23.0 this is done by default when
// generating debug info, so we don't want to do it twice and print twice a warning if objcopy is not
// available.
if (objcopyExists) {
objcopy("--strip-debug", resultingExecutableName);
} else if (SystemUtils.IS_OS_LINUX) {
log.warn(
"objcopy executable not found in PATH. Debug symbols will therefore not be separated from the executable.");
log.warn("That also means that resulting native executable is larger as it embeds the debug symbols.");
}
// Strip debug symbols regardless, because the underlying JDK might contain them
objcopy("--strip-debug", resultingExecutableName);
} else if (SystemUtils.IS_OS_LINUX) {
log.warn(
"objcopy executable not found in PATH. Debug symbols will therefore not be separated from the executable.");
log.warn("That also means that resulting native executable is larger as it embeds the debug symbols.");
}
return new Result(0);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public NativeImageBuildItem build(NativeConfig nativeConfig, LocalesBuildTimeCon

NativeImageBuildRunner.Result buildNativeResult = buildRunner.build(nativeImageArgs, nativeImageName,
resultingExecutableName, outputDir,
nativeConfig.debug.enabled,
graalVMVersion, nativeConfig.debug.enabled,
processInheritIODisabled.isPresent() || processInheritIODisabledBuildItem.isPresent());
if (buildNativeResult.getExitCode() != 0) {
throw imageGenerationFailed(buildNativeResult.getExitCode(), nativeConfig.isContainerBuild());
Expand Down

0 comments on commit ad468ce

Please sign in to comment.