This is an archive of the discontinued LLVM Phabricator instance.

[clang] Pass more flags to ld64.lld
ClosedPublic

Authored by thakis on Feb 11 2022, 7:17 PM.

Details

Reviewers
int3
Group Reviewers
Restricted Project
Commits
rG383ed82dd1f8: [clang] Pass more flags to ld64.lld
Summary
  • ld64.lld now completely supports -export_dynamic (D119372), so map -rdynamic to -export_dynamic like already done for ld64
  • ld64.lld has been supporting -object_path_lto for well over a year (D92537), so pass it like already done for ld64

Diff Detail

Unit TestsFailed

Event Timeline

thakis created this revision.Feb 11 2022, 7:17 PM
thakis requested review of this revision.Feb 11 2022, 7:17 PM
thakis added inline comments.
clang/lib/Driver/ToolChains/Darwin.cpp
242

lgrey: Do you think this should interact with 134275d994d5fb38edfeb587ba45c8f495c8bf66 in any way, or should have any other interesting side effects?

From what I understand, it tells the linker to put temporary files created for LTO in the given directory, but then the clang driver cleans up that directory when it exits (potentially after running dsymutil). But most people run dsymutil later, separately, so I think there should be no interactions there.

lgrey added inline comments.Feb 14 2022, 6:58 AM
clang/lib/Driver/ToolChains/Darwin.cpp
242

IIUC this is orthogonal to the cache's temp files. Something's actually not adding up here for me (why was it looking at the LTO cache files in the first place?), but this change shouldn't affect the cache thing.

ormris removed a subscriber: ormris.Feb 14 2022, 9:24 AM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Darwin.cpp
272

lld runs --icf=none (i.e. -no_deduplicate) by default.

clang/test/Driver/darwin-ld-dedup.c
4

If you are going to change the command line, prefer the canonical --target= to the legacy -target .

thakis added inline comments.Feb 16 2022, 7:23 AM
clang/lib/Driver/ToolChains/Darwin.cpp
272

Hm, good point. Should we pass --icf=safe for lld if !shouldLinkerNotDedup here then?

clang/test/Driver/darwin-ld-dedup.c
4

"legacy" really has no semantic meaning here other than "I like that other spelling more". It's not like we're ever going to remove -target, it's way too actively used (see e.g. D119446 :P).

It seems like a change unrelated to what this patch is doing. If we want to change it, we can do it in a separate patch.

thakis updated this revision to Diff 409243.Feb 16 2022, 7:31 AM

undo no_deduplicate bit again for now

thakis edited the summary of this revision. (Show Details)Feb 16 2022, 7:31 AM
thakis updated this revision to Diff 409254.Feb 16 2022, 7:43 AM

Pass -B with -fuse-ld=lld since the latter flag only has an effect if ld64.lld exists on disk, and clang/test doesn't depend on lld (and shouldn't).

Also move object_path_lto to its own file since it can run fine on non-darwin hosts.

lld-macho folks, any concerns with this?

int3 accepted this revision.Feb 17 2022, 10:41 AM
int3 added a subscriber: int3.

lgtm!

clang/lib/Driver/ToolChains/Darwin.cpp
272

I think our dedup pass is both a lot more effective and a lot more expensive link-time-wise than ld64's so maybe we shouldn't do it by default...

This revision is now accepted and ready to land.Feb 17 2022, 10:41 AM
MaskRay added inline comments.Feb 17 2022, 10:46 AM
clang/lib/Driver/ToolChains/Darwin.cpp
272

FIXME: lld doesn't dedup by default.

I agree that we should not do icf by default. It can easily take more than 10% time IIRC.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2022, 1:46 PM