incremental linking?

Simon Marlow simonmar@microsoft.com
Wed, 27 Nov 2002 12:14:51 -0000


> Unfortunately, we're not talking seconds, but coffee-breaks of
> linking times on our Sun (yes, the stuff is in the range of a large
> compiler - we're fortunate enough to be able to build on rather
> substantial third-party packages, think haskell-in-haskell frontend
> distributed over unusually many modules + strategic traversal
> support + our own code).=20
>=20
> And yes, I was worried about NFS-mounting first, especially since
> linking on our Sun takes even longer than on our PCs (long breaks
> instead of short ones;-), but moving .hi and .o to local tmp-space
> didn't speed things up (then again, it's a large machine, and our
> disk setup is likely to be more complex than I know - I'll have to
> check with our admins).

It does sound like it's taking rather too long, I'd investigate further.
=20
> > > Alternative a: use someone else's incremental linker, e.g., Sun's
> > > ild (ghc's -pgml option appears to have its own idea about option
> > > formatting, btw) - this doesn't seem to work - should it?
> >=20
> > You'd probably want to call the incremental linker directly=20
> rather than
> > using GHC - what exactly does it do, BTW?  What files does=20
> it generate?
>=20
> Calling it via GHC seemed the best way to ensure that it gets
> everything it needs (what else would be the purpose of -pgml?).

Ah I see - it's just like a normal linker, except it takes a previous
version of the executable and attempts to just re-link the bits it
needs?

GHC has some built-in assumptions about the linker: it must accept
gcc-style command line options.  This probably isn't true of the
incremental linker, so you could either (a) write a wrapper around it,
or (b) arrange to call the incremental linker through gcc.  I can't
remember if (b) is possible, but a quick scan of the docs suggested that
gcc doesn't have the equivalent of -pgml so (b) might be out.

BTW, -pgml is usually just used to select a different version of gcc (as
with -pgmc).

> > Alternative b: convince ghc to link objects in stages, e.g., on a
> > per-directory basis - gnu's ld seems to support at least this kind
> > of partial linking (-i/-r). Not quite as nice as a fully incremental
> > linker, but would probably save our day..
>=20
> Yes, this works fine.  We use it to build the libraries for GHCi.
>
> Presumably directed via Makefiles?=20
> Could this please be automated for ghc --make?

It's easy:

	$ ld -r -o All.o  A.o B.o C.o ...

Cheers,
	Simon