Page MenuHomePhabricator

Use -fuse-init-array if no gcc installation is found.
ClosedPublic

Authored by thakis on Oct 25 2017, 9:17 PM.

Details

Reviewers
pcc
rsmith
Summary

clang currently uses .init_array instead of .ctors on Linux if it detects gcc 4.7+. Make it so that it also uses .init_array if no gcc installation is found at all – if there's no old gcc, there's nothing we need to be compatible with.

icecc for example runs clang in a very small chroot, so before this change clang would use .ctors if run under icecc. And lld currently silently mislinks inputs with .ctors sections, so before this clang + icecc + lld would produce broken binaries.

Diff Detail

Event Timeline

thakis created this revision.Oct 25 2017, 9:17 PM

And lld currently silently mislinks inputs with .ctors sections

Is there a bug for this? I see https://bugs.llvm.org/show_bug.cgi?id=31224, which links to https://reviews.llvm.org/D35509, but neither seems active.

rsmith accepted this revision.Oct 26 2017, 9:57 AM
rsmith added a subscriber: rsmith.

I don't think working around an lld bug is a particularly good justification for this, but I do think it makes sense to switch this from being a "compatibility with GCC 4.7+" thing to being a "compatibility with GCC <= 4.6" thing. Please update the release notes to mention this change.

This revision is now accepted and ready to land.Oct 26 2017, 9:57 AM
thakis closed this revision.Oct 26 2017, 4:27 PM

r316713, thanks!