From afbc7c839d19ff9243a52082fa25c4125dcdf02a Mon Sep 17 00:00:00 2001 From: rrt Date: Wed, 22 Aug 2001 15:59:35 +0000 Subject: [PATCH] [project @ 2001-08-22 15:59:35 by rrt] Say a bit about the horrors of linking. --- ghc/docs/comm/the-beast/driver.html | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/ghc/docs/comm/the-beast/driver.html b/ghc/docs/comm/the-beast/driver.html index 2c56182..c7770ed 100644 --- a/ghc/docs/comm/the-beast/driver.html +++ b/ghc/docs/comm/the-beast/driver.html @@ -13,14 +13,49 @@ Evil Driver (ED), which was a Perl script that served the same purpose and was in use until version 4.08.1 of GHC. Simon Marlow eventually slayed the ED and instated the GD. +

The GD has been substantially extended for GHCi, i.e., the interactive variant of GHC that integrates the compiler with a (meta-circular) interpreter since version 5.00. +

+

Linking the RTS and libHSstd

+

+ Since the RTS and HSstd refer to each other, there is a Cunning + Hack to avoid putting them each on the command-line twice or + thrice (aside: try asking for `plaice and chips thrice' in a + fish and chip shop; bet you only get two lots), namely to add + the symbols that the RTS needs from libHSstd, such as + PrelWeak_runFinalizzerBatch_closure and + __init_Prelude to the link line with the + -u flag. The standard library appears before the + RTS on the link line (why? might it be better the other way + around? [SPJ]), and these options cause the corresponding + symbols to be picked up even if they haven't been already, so + that when the RTS is also scanned, they are resolved. This + avoids the linker having to read the standard library and RTS + multiple times. +

+

+ This does, however, lead to a complication. Normal Haskell + programs do not have a main function, so this is + supplied by the RTS. It calls startupHaskell, which + itself calls __init_PrelMain, which is therefore, + since it occurs in the standard library, one of the symbols + passed to the linker. However, when the main + function is provided by the programmer (e.g. when there is no + main module, but a C module instead), + __init_PrelMain had better not be linked in, + because it tries to call __init_Main, which won't + exist. This case is coped with by the -no-hs-main + flag, although in some versions of the compiler (e.g. 5.00.2) it + didn't work. +

+

-Last modified: Wed Aug 8 19:22:14 EST 2001 +Last modified: Wed Aug 22 17:01:33 GMT Daylight Time 2001 -- 1.7.10.4