Opened 3 years ago

Last modified 2 years ago

#9074 new bug

GHC 7.8.2's ghci does not track missing symbols when loading non-Haskell object files

Reported by: massysett Owned by:
Priority: normal Milestone:
Component: Compiler (Linking) Version: 7.8.2
Keywords: Cc: choener@…, tulcod, crockeea
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I have a package that bundles in C library sources. I never had a problem with this when using GHC 7.6.

In GHC 7.8, the order of the c-sources in the cabal file now matters. Sources must be listed earlier if they have symbols that subsequently loaded object files will need. If the c-sources are in the wrong order, when running "cabal repl" I get

Loading object (static) dist/build/decnumber/src/decQuad.o ... ghc: panic! (the 'impossible' happened)

(GHC version 7.8.2 for x86_64-unknown-linux):

Loading temp shared object failed: /tmp/ghc14294_0/ undefined symbol: DECSTICKYTAB

Please report this as a GHC bug:

When using the same code and cabal file with GHC 7.6, "cabal repl" works fine: GHCi loads each static object (regardless of ordering in the cabal file), links up the necessary symbols, and launches successfully.

Haskell Cafe discussion here:

Change History (6)

comment:1 Changed 3 years ago by choenerzs

Cc: choener@… added

comment:2 Changed 3 years ago by tulcod

Cc: tulcod added

I have a similar issue. In particular, my cabal project defines a C source file which in turn calls a C function from a library (outside of my project). But since cabal repl tries to load the in-project .o file first, it encounters undefined symbols (in particular, it errors on a struct which is declared "extern" by the library).

This is not influenced by the order of the "c-sources" and "extra-libraries" in my .cabal file.

PS: overview of symbols: My C source file (in-project): function myfunc, which calls the C function libfunc Library C header file (outside project): declares somestruct as "extern"; defines libfunc "static inline", which uses a pointer to somestruct as an argument to libfunc_internal; declares libfunc_internal Library .so code: defines libfunc_internal, defines somestruct

So "cabal repl" errors on "undefined symbol: somestruct"

comment:3 Changed 3 years ago by mietek

tulcod, I opened #9277 to track an issue which appears similar to yours.

comment:4 Changed 3 years ago by crockeea

I'm also experiencing this problem. The problem affects GHC 7.8.2 and GHCi. I'm loading files using:

: ghci[i] Foo Objects/*.o

which fails:

ghc: panic! (the 'impossible' happened)

(GHC version 7.8.2 for x86_64-unknown-linux):

Loading temp shared object failed: /tmp/ghc20682_0/ undefined symbol: foo

If I explicitly list out each object file in the "correct" order, I can get GHC to compile.

comment:5 Changed 3 years ago by crockeea

Cc: crockeea added

comment:6 Changed 2 years ago by thomie

Component: CompilerCompiler (Linking)
Note: See TracTickets for help on using tickets.