#3252: having to call hs_add_root(__stginit_Foo) is a bit of a pain
---------------------------------+------------------------------------------
Reporter: duncan | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 6.14.1
Component: Compiler (FFI) | Version: 6.10.2
Keywords: | Difficulty: Unknown
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by lodi):
I recently ran into this issue when building a shared library with a
c-interface. A hand-built library (module CInterface, no package) would
link fine. A cabal-built library (package test-0.0) would fail with:
{{{
./libHStest-0.0-ghc6.12.1.so: undefined reference to
`__stginit_CInterface'
}}}
After some help from duncan:
{{{
> nm libHStest-0.0-ghc6.12.1.so | grep stginit
...
00004570 T __stginit_testzm0zi0_CInterface
00004500 T __stginit_testzm0zi0_CInterface_dyn
...
}}}
So it turns out that the package name ''and version'' are embedded into
the symbol. This necessitates manually updating the c source files
whenever the package version is incremented. The error is additionally
confusing since the manual states that ghc will automatically export
{{{__stginit_Foo}}}, and also since it isn't even reported until the
consuming application is linked.
Some way to have ghc take care of this automatically would be much
appreciated!
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3252#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs