From d682129611d72f1d1a64871c58d2781a21c64674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Tue, 21 Sep 2021 12:29:16 +0200 Subject: [PATCH] Only use `objcopy` in Linux environments #13856 * `objcopy` invocations in macOS make the executable crash on startup. * Debug info is only available for Linux, so avoid `objcopy` altogether on macOS, even if present in PATH. * Updated documentation to avoid confusion. --- .../deployment/pkg/steps/NativeImageBuildLocalRunner.java | 6 ++++++ docs/src/main/asciidoc/building-native-image.adoc | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildLocalRunner.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildLocalRunner.java index e693a90b34e553..018c1f4155257e 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildLocalRunner.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildLocalRunner.java @@ -4,6 +4,8 @@ import java.util.List; import java.util.stream.Stream; +import org.apache.commons.lang3.SystemUtils; + public class NativeImageBuildLocalRunner extends NativeImageBuildRunner { private final String nativeImageExecutable; @@ -34,6 +36,10 @@ protected void objcopy(String... args) { @Override protected boolean objcopyExists() { + if (!SystemUtils.IS_OS_LINUX) { + return false; + } + // System path String systemPath = System.getenv("PATH"); if (systemPath != null) { diff --git a/docs/src/main/asciidoc/building-native-image.adoc b/docs/src/main/asciidoc/building-native-image.adoc index dd3a74853200e9..4141c4b59153ae 100644 --- a/docs/src/main/asciidoc/building-native-image.adoc +++ b/docs/src/main/asciidoc/building-native-image.adoc @@ -703,7 +703,7 @@ Depending on what the final desired output of the CI/CD pipeline is, the generat Starting with Oracle GraalVM 20.2 or Mandrel 20.1, debug symbols for native executables can be generated for Linux environments -(Windows support is still under development). +(Windows support is still under development, macOS is not supported). These symbols can be used to debug native executables with tools such as `gdb`. To generate debug symbols, @@ -713,7 +713,7 @@ You will find the debug symbols for the native executable in a `.debug` file nex [NOTE] ==== The generation of the `.debug` file depends on `objcopy`. -On common Linux distributions and macOS you will need to install the `binutils` package: +On common Linux distributions you will need to install the `binutils` package: [source,bash] ---- @@ -721,9 +721,6 @@ On common Linux distributions and macOS you will need to install the `binutils` sudo dnf install binutils # Debian-based distributions sudo apt-get install binutils -# macOS -brew install binutils -export PATH=/usr/local/opt/binutils/bin:$PATH ---- When `objcopy` is not available debug symbols are embedded in the executable.