Changes between Version 2 and Version 3 of DynamicLinking


Ignore:
Timestamp:
May 14, 2009 10:18:33 AM (5 years ago)
Author:
duncan
Comment:

Update build notes and add ELF todos

Legend:

Unmodified
Added
Removed
Modified
  • DynamicLinking

    v2 v3  
    1010= Build System = 
    1111 
    12 There is now minimal support in the build system for building dynamic libraries. It's a hack. 
     12There is now some support in the build system for building dynamic libraries. 
    1313 
    14 I need help, volunteers report at wolfgang.thaller@gmx.net or to the cvs-ghc mailing list. 
    15  
    16 You need to add a few things to your build.mk file: 
     14You need to add a flag when you configure 
    1715 
    1816{{{ 
    19 SplitObjs = NO 
    20 GhcStage2HcOpts=-dynamic 
    21 GhcLibHcOpts=-O -fasm -fPIC -dynamic 
    22 GhcRtsHcOpts=-fPIC -fvia-C -dynamic 
    23 GhcBuildDylibs=YES 
    24 #GHC_CC_OPTS+=-fPIC 
     17./configure --enable-shared 
    2518}}} 
    2619 
    27 Uncomment the last line after compiling libghccompat and stage1 in ghc, but before compiling in libraries. Sorry for the inconvenience, feel free to fix it. For Powerpc64 Linux, you only need the first two lines. 
     20There has been some churn in how dynamic libraries are built since the introduction of the new build system in ghc HEAD (6.11). The only platforms that have been tested with the new system are currently Linux/x86 and Linux/x86-64. The current target is to have GHC itself built statically but to build dynamic libraries such that GHC is capable of linking libraries and programs that use dynamic libraries. 
     21 
     22If anyone would like to help, report to the cvs-ghc mailing list or directly to wolfgang.thaller@gmx.net or duncan@well-typed.com. 
    2823 
    2924= Platform-Specific TODO = 
     
    3126Profiled code isn't yet really position-independent even when `-fPIC` is specified. Building profiled dynamic libraries therefore fails on Mac OS X (Linux silently accepts relocations - it's just slightly bad for performance). 
    3227 
     28== All ELF systems == 
     29 
     30 * Get the "soname" set, probably based on -o file name. (see [http://www.haskell.org/pipermail/cvs-ghc/2009-May/048567.html this message]) 
     31 * Make sure all shared libs properly record their dependencies, including on the rts (to enable soname chasing) 
     32 * Work out a scheme to enable switching the variant of the rts at link time. 
     33 * Switch default dynamic linking mode to "system dependent" 
     34 * Use an external Main.o rather than having main in the rts (see [http://www.haskell.org/pipermail/cvs-ghc/2009-May/048573.html this message]). 
     35 * In a final link, use the minimum set of libraries, only direct dependencies (assume soname chasing). Avoid -u flags (which are only required for linking base and rts as static libs). 
     36 
     37 * Get GHCi working by loading shared libs 
     38 * Check ld.so loading performance, check quality of hashing. 
     39 * Test that for every rts way, the combination of rts.so + base.so has no unresolved symbols. They should stand alone. Eg check bfd and liberty in debug rts way and check pthread in threaded way. 
     40 
    3341== x86 and powerpc32 ELF/Linux TODO == 
    3442 
    35 The NCG works. Support for `-fPIC` in the mangler is buggy on PowerPC and nonexistent on x86. Due to the strange way that dynamic linking is implemented, it will be very hard to generate position-dependent code that correctly links to (Haskell code in) dynamic libraries without the NCG. 
     43Summary: -fPIC -fasm works, -fPIC -fvia-C does not work and is unlikely to ever work. 
    3644 
    37 As the RTS can't currently be compiled with the NCG (a volunteer opportunity!), the RTS has to be compiled as position dependent code. 
     45Support for `-fPIC` in the mangler is buggy on PowerPC and nonexistent on x86. Due to the strange way that dynamic linking is implemented, it will be very hard to generate position-dependent code that correctly links to (Haskell code in) dynamic libraries without the NCG. 
    3846 
    3947== Windows TODO ==