Missing debug symbols in statically linked binary

Viewed 763

I'm building statically linked binary using stack and I try to add debug symbols to it (following: https://downloads.haskell.org/~ghc/master/users-guide/debug-info.html). However GDB reports: no debugging symbols found.

What am I missing?

I've added to the ghc-options in the .cabal file: -g -rtsopts and to the ld-options: -static. I am building using stack with the following command:

stack install \
    --install-ghc \
    --split-objs \
    --ghc-options="-fPIC -fllvm -pgmlo opt -pgmlc llc"

GDB is invoked as follows: gdb --args nodebug-exe +RTS -V0

GHC 8.2.1

Whole source code is here: https://github.com/carbolymer/haskell-missing-debug-symbols

1 Answers

--no-strip prevents debugging information being removed in the stack build.

From the documentation:

stack now supports debugging and profiling with DWARF information, using the --no-strip, --no-library-stripping, and --no-executable-stripping flags to disable the default behavior of removing such information from compiled libraries and executables.

Related