I have a large (~200MB) C++ shared library that links in a very reasonable 15
CPU sec. using older versions of ld (such as "126.96.36.199.2" from Red Hat
Enterprise 4, or "188.8.131.52.1.1" from SuSE Enterprise 9), but with "184.108.40.206.5"
from SuSE Enterprise 10 and also a stock 2.17, takes more than 10 CPU minutes.
The vast majority of the time is being spent on the following call chain:
elf_link_input_bfd (bfd/elflink.c: 7155)
_bfd_elf_check_kept_section (bfd/elflink.c: 6802)
match_group_member (bfd/elflink.c: 6778)
bfd_elf_match_symbols_in_sections (bfd/elf.c: 8629)
qsort and callees
I tried #if-ing out the statement in `elf_link_input_bfd' beginning with `if
(action & PRETEND)', and the link time is back down to ~25 CPU sec. The comment
above that statement suggests that it may not be necessary with a recent GCC
anyway. I built the whole application this way and it seems to work fine, so
this seems to be an adequate temporary workaround.
As far as a real fix, I'm thinking maybe to add a member `checked_kept_section'
to `struct bfd_section' that `_bfd_elf_check_kept_section' could cache its
result in. Haven't tried this, though.
*** This bug has been marked as a duplicate of 3111 ***