
Bruce, Joseph R (Joe) wrote:
When I run 'ghc -v ...', the linking is done via gcc->ld with a large list of -u flags passed in. I'm hoping to find a way to link my object files without those flags, but first I need to understand what they are doing. Can someone explain it to me? Or point me to documentation that explains it?
My ultimate goal is to build a static Haskell library and make it available to c programmers ignorant of Haskell. The undefines described above are a major obstacle. Does anyone know a way around them?
The -u flags arise because there is a circular dependency between the RTS (libHSrts.a) and the base package (libHSbase.a). The RTS refers to a few datatypes and functions in the base package, for instance the constructors for True and False, I#, C# and so on, and some exceptions that the RTS automatically raises for certain events (e.g. stack overflow, non-termination). One way to avoid needing the -u flags would be to link the base package twice, but that would slow down linking, and twice might not be enough. With shared libraries there's no problem, because we always just link the whole library, this is only an issue with static libraries. So for building a static Haskell library, can't you just link the RTS and base package together in a single .a file? Cheers, Simon