
Hi ! I'm trying to compile shared library. This library will use as part of plugin for some program. If I compile library with option -dynamic my library has links for HS libraries like libHSbase-4.2.0.2-ghc6.12.3.so and so on. But program has crashed constantly. Is it possible to make shared library without -dynamic flag? I want to try to make library without dependencies. According to http://www.well-typed.com/blog/30 theoretically I can do this but I found this impossible - http://hackage.haskell.org/trac/ghc/ticket/3704 My options to compile: ghc -O2 --make -no-hs-main -dynamic -shared -fPIC -optl '-shared' -optc '-DMODULE=MyLib' -o MyLib.so MyLib.hs module_init.c -optl-Wl -lHSrts-ghc6.12.3 If I try compile without -dynamic I get error: /usr/bin/ld: /usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a(Conc__270.o): relocation R_X86_64_32 against `base_GHCziConc_ensureIOManagerIsRunning1_closure' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a: could not read symbols: Bad value collect2: ld returned 1 exit status My system is: Cenos 5.6 ghc6.12.3 gcc-4.2.1 Cheers, Sergiy

On 26 August 2011 13:52, Sergiy Nazarenko
/usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a(Conc__270.o): relocation R_X86_64_32 against `base_GHCziConc_ensureIOManagerIsRunning1_closure' can not be used when making a shared object; recompile with -fPIC
So it looks like you will have to recompile the base libraries with -fPIC (or try this on Windows, where PIC is unnecessary). The way I would do this personally is to recompile all of GHC, and in mk/build.mk set the GhcLibHcOpts to -fPIC. There may be a way to just recompile the base library (and dependents) using Cabal, but I'm less sure about that path. Note that using -fPIC will probably impose a performance penalty on the library code. Max
participants (2)
-
Max Bolingbroke
-
Sergiy Nazarenko