Skip to content

Commit

Permalink
Only use objcopy in Linux environments quarkusio#13856
Browse files Browse the repository at this point in the history
* `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.
  • Loading branch information
galderz committed Sep 21, 2021
1 parent 7fbc27f commit d682129
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions docs/src/main/asciidoc/building-native-image.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -713,17 +713,14 @@ 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]
----
# dnf (rpm-based)
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.
Expand Down

0 comments on commit d682129

Please sign in to comment.