Ticket #5240 (closed feature request: fixed)
help GNU ld to use less memory when linking libraries compiled with -split-objs.
| Reported by: | int-e | Owned by: | igloo |
|---|---|---|---|
| Priority: | high | Milestone: | 7.4.1 |
| Component: | Compiler | Version: | 7.0.3 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
This is a well-known problem, but I didn't find a previous report here, probably because it is mainly a GNU ld issue. The problem is that with -split-objs, linking, say, ghc, takes a trememndous amount of memory.
Part of this problem will be fixed in ld:
In this bug report, Nick Clifton suggests to use '--hash-size=31' and possibly '--reduce-memory-overhead' when invoking ld. Since ghc is invoking gcc for linking, that would mean passing '-Xlinker --hash-size=31' and perhaps '-Xlinker --reduce-memory-overhead' to gcc.
Can we do that? Care needs to be taken if people use the -pgmL option, and we should make sure that gcc is actually using GNU ld.
In my experiments (linking ghc), --hash-size=31 helps, reducing memory usage by about a factor of 1/2; --reduce-memory-overhead without --hash-size=31 also helps (saving about 1/3), but has no noticable effect in connection with --hash-size=31. Based on that I'd suggest to only use --hash-size=31.

