Opened 10 months ago

Last modified 8 months 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 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 Revisions:

Description

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/ghc14294_1.so: undefined symbol: DECSTICKYTAB

Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug

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:

http://www.haskell.org/pipermail/haskell-cafe/2014-May/114041.html

Change History (5)

comment:1 Changed 9 months ago by choenerzs

  • Cc choener@… added

comment:2 Changed 8 months 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 8 months ago by mietek

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

comment:4 Changed 8 months 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/ghc20682_3.so: undefined symbol: foo

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

comment:5 Changed 8 months ago by crockeea

  • Cc crockeea added
Note: See TracTickets for help on using tickets.