#3704: Linking shared libraries broken due to name mismatch
---------------------------------+------------------------------------------
    Reporter:  asuffield         |       Owner:              
        Type:  bug               |      Status:  new         
    Priority:  normal            |   Component:  Compiler    
     Version:                    |    Keywords:              
          Os:  Unknown/Multiple  |    Testcase:              
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown
---------------------------------+------------------------------------------
 When trying to link with ghc -shared

 {{{
 $ ghc -v -fPIC -shared -o TestF.so TestF.hs
 }}}

 it adds a bunch of arguments of the form -lHSbase-4.2.0.0 to the linker
 command line

 {{{
 *** Linker:
 /usr/bin/gcc -v -o TestF.so TestF.o -shared -Wl,-Bsymbolic
 -Wl,-soname,TestF.so
  -L/usr/lib/ghc-6.12.0.20091126/base-4.2.0.0
 -L/usr/lib/ghc-6.12.0.20091126/integer-gmp-0.2.0.0
  -L/usr/lib/ghc-6.12.0.20091126/ghc-prim-0.2.0.0
 -L/usr/lib/ghc-6.12.0.20091126 -lHSbase-4.2.0.0
  -lHSinteger-gmp-0.2.0.0 -lgmp -lHSghc-prim-0.2.0.0 -lHSffi
 }}}

 Unfortunately:

 {{{
 
/usr/lib/ghc-6.12.0.20091126/base-4.2.0.0/libHSbase-4.2.0.0-ghc6.12.0.20091126.so
 /usr/lib/ghc-6.12.0.20091126/base-4.2.0.0/libHSbase-4.2.0.0.a
 /usr/lib/ghc-6.12.0.20091126/base-4.2.0.0/libHSbase-4.2.0.0_p.a
 }}}

 The name of the .so has been mangled to include the compiler version -
 presumably for ABI reasons. Obviously the bug is that name on the linker
 command line has not been suitably mangled to match, so the linker goes
 ahead and tries to use the .a library, which doesn't work at all.

 {{{
 /usr/bin/ld:
 /usr/lib/ghc-6.12.0.20091126/base-4.2.0.0/libHSbase-4.2.0.0.a(Base__76.o):
 relocation R_X86_64_32S against `.text' can not be used when making a
 shared object; recompile
 with -fPIC
 }}}

 Tested on linux/amd64, with HEAD and stable snapshot. It may work on
 linux/i386 due to compatibility hacks in glibc, I haven't checked; it
 shouldn't work on anything else.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3704>
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

Reply via email to