[Haskell-cafe] Name Decoration and Undefined References

SevenThunders mattcbro at earthlink.net
Fri Jun 29 23:45:57 EDT 2007

I have a very complex project that has to play nice with a lot of C code
written by other people.
My own code is half Haskell and half C.  My build process is rather complex
since I generate about 5 different libraries, some of them export Haskell
routines.  A supreme effort was made to try to make Haskell somewhat
invisible, although ultimately it requires a lot of gcc command line work
with a bunch of undefines and a links to Haskell static libraries.  In the
end I'm not sure if it's such a good idea and probably would be better off
completing the final link stage just using ghc.

In the process of doing all this I attempted to link one of my libraries to
some test code written in Haskell and I proceeded to get a few unresolved
links whilst running ghc.  What happened is that I have a Haskell binary,
lets say called foo.o generated from foo.hs that appears in two libraries 
say called libmyh.a and libmyc.a and that contains a Haskell function called
bar.  Library libmyh.a ultimately gets built using cabal and libmyc.a gets
built using gcc directly.

The binary is compiled twice (for complicated reasons) prior to linking to
each library.  However in the library libmyh.a,  the bar symbol is prepended
with an ascii string that contains the library name (say libmyh).  However
the other library shows that the symbol does not have this name decoration
since it was linked directly with gcc.  It appears however when trying to
link against libmyc.a that ghc expects to see the original name decoration
for bar. I presume this is due to some side information, perhaps what's
contained in foo.hi that informs ghc what names to actually link to.

I now ask the question,  how can I control this process?  Build tools such
as CMake and Cabal seem to have their own ideas about what directories to
place binaries.  It seems like I need to somehow make sure that all files
related to the compilation process of a given library are isolated in the
same directory or  something.  Thus it's not enough to specify binaries on
the command line of ghc, it's got to have access to some other files;  I
presume the .hi files.  This makes things a bit confusing I'm afraid.
View this message in context: http://www.nabble.com/Name-Decoration-and-Undefined-References-tf4003458.html#a11370409
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list