Recently, I had to recompile ghc, in order to get the "-dyn" versions of the standard libraries installed. (The standard Ubuntu 12.10 64-bit Linux distribution doesn't include them in its "haskell-platform" package, and you can't upgrade "base" using the normal "cabal iinstall" approach, from what I understand.)

When I did this, the "-dyn" versions of the standard libraries were, in fact, installed. However, they were given names with a "-ghc7.4.2.so" suffix. And this is causing the build of a previously working project to break, thusly:

ghc -o libami.so -shared -dynamic -package parsec -lHSrts -lm -lffi -lrt AMIParse.o AMIModel.o ami_model.o ExmplUsrModel.o Filter.o

/usr/bin/ld: /usr/lib/ghc-7.4.2/libHSrts.a(RtsAPI.o): relocation R_X86_64_32S against `ghczmprim_GHCziTypes_Czh_con_info' can not be used when making a shared object; recompile with -fPIC

The problem is this: the linker is picking up the "*.a" version of the HSrts library, instead of the "*.so" version, which is what it really needs. And the reason it's doing this is the "*.so" version has been given a "-ghc7.4.2" suffix:

dbanas@dbanas-lap:~/prj/AMI-Tool$ l /usr/lib/ghc-7.4.2/libHSrts*
/usr/lib/ghc-7.4.2/libHSrts.a
{snip}
/usr/lib/ghc-7.4.2/libHSrts-ghc7.4.2.so*
{snip}

So, it seems to me that I need to either:
  1. Tell the linker about the possibility of a "-ghc7.4.2" file name suffix, or
  2. rebuild my "*.so"s without that suffix.
Can anyone tell me:
  • How to accomplish either #1 or #2, above?
  • Which one is the preferred solution to the problem?
  • Am I completely off in the weeds?
  • If so, what should I really be doing, in order to fix this issue?
Thanks!
-db