Helping ld link libxul more quickly

I used to do most of my development in a Linux virtual machine with 1.5GB of RAM. There, –enable-libxul builds were … painful: linking libxul itself took about 2 minutes and 30 seconds. Ideally, ld or gold would know how to re-link incrementally, and the problem would vanish. But until then, you can help ld out by adding a flag in your mozconfig

...
export LDFLAGS="-Wl,--no-keep-memory"

This tells ld to optimize for memory usage rather than speed. On my 1.5GB VM, this made a big difference because it kept ld from hitting swap as much; the link time went from ~2:30 to ~1:30. Also see https://bugzilla.mozilla.org/show_bug.cgi?id=494068.

CAVEAT EMPTOR: if you have a machine with “lots of RAM”, this flag might actually hurt link times. Also, it’s worth pointing out that the best way to speed up libxul link times is to add more RAM to your build machine, if possible. (My bright shiny new build machine can link libxul in about 5 seconds, so I don’t use –no-keep-memory anymore.)