6

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

CDspace
  • 2,639
  • 18
  • 30
  • 36
carbolymer
  • 1,439
  • 1
  • 15
  • 30
  • 1
    Maybe add --no-strip? `--no-strip: Disable DWARF debugging symbol stripping in libraries, executables, etc. for all expressions` – Zpalmtree Nov 17 '17 at 21:27
  • @Zpalmtree, That's right. I should've looked into `stack install --help`... You can add it as an answer. – carbolymer Nov 17 '17 at 21:41

1 Answers1

7

--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.

Zpalmtree
  • 1,339
  • 8
  • 14