#4417: Quasiquoting without bloating
---------------------------------+------------------------------------------
Reporter: rrnewton | Owner:
Type: feature request | Status: new
Priority: high | Milestone:
Component: Compiler | Version: 6.13
Keywords: executable size | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by batterseapower):
#4387 suggests using the GCC module initialisation mechanism to initialise
Haskell modules. This would prevent us from dragging in massive transitive
module dependencies caused by just module initialisation.
I looked into this and made some discoveries:
* How initialisers are discovered is platform dependent :(
* Looking at the collect2 source code, on some platforms, it seems to
happen by collect2 scanning the binary for certain well-known name
prefixes (notably __GLOBAL__I_). These are assembled into a constructor
list which is walked and initialised by crtbegin.o (generated from GCC's
crtstuff.c).
* On OS X, another mechanism seems to be used: initialisation function
pointers are put into a MachO section of type mod_init_func_pointers with
BFD name __DATA.__mod_init_func. I presume that the MachO ld then knows to
collect all the od_init_func_pointers and generate some code to invoke
these guys. On this platform, collect2 does not seem to invoke ld with
crtbegin.o and crtend.o added to the link line.
There is some other information here:
http://www.emerson.emory.edu/services/gcc/html/Initialization.html
The most portable thing to do would be to just generate a C file with a
function marked with the GCC-specific __attribute__((constructor)) that
deals with initialisation. I think that in order to ensure that this is
called before any of the symbols exported by the module proper, this
function and the other symbols have to be in the same *object file*, so we
need to do some extra work there.
The LLVM backend can skip all this and just set the @llvm.global_ctors
list in the output code to contain the module initialisation function. See
http://llvm.org/docs/FAQ.html#iosinit
We can then link everything together with collect2 and win.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4417#comment:4>
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