This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Instruct lld to go through all archives
ClosedPublic

Authored by scchan on Jun 5 2023, 4:00 PM.

Details

Summary

Add the --whole-archive flag when linking HIP programs to instruct lld
to go through every archive library to link in all the kernel functions
(entry pointers to the GPU program); otherwise, lld may skip some
library files if there are no more symbols that need to be resolved.

Change-Id: Ic7ea61ec3e6925f80a63d04654ac72177ffb27c8

Diff Detail

Event Timeline

scchan created this revision.Jun 5 2023, 4:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 4:00 PM
Herald added a subscriber: yaxunl. · View Herald Transcript
scchan requested review of this revision.Jun 5 2023, 4:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 4:00 PM
yaxunl added inline comments.Jun 6 2023, 8:05 AM
clang/lib/Driver/ToolChains/HIPAMD.cpp
168

Better move this before line 155 to allow users to override this option.

Please add a comment that the device linker will not try to resolve a device variable or kernel that is referenced by a host object in the archive which in turn is referenced by a host object not in the archive, therefore --whole-archive is needed.

scchan updated this revision to Diff 529060.Jun 6 2023, 3:32 PM

Updated patch to address review feedback

scchan marked an inline comment as done.Jun 6 2023, 3:33 PM
scchan updated this revision to Diff 529061.Jun 6 2023, 3:35 PM

remove ws

yaxunl accepted this revision.Jun 7 2023, 5:48 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Jun 7 2023, 5:48 AM
scchan updated this revision to Diff 529311.Jun 7 2023, 8:13 AM

fix some formatting issue

MaskRay added inline comments.Jun 7 2023, 8:14 AM
clang/lib/Driver/ToolChains/HIPAMD.cpp
165

Though not strictly required, it's usually better to end --whole-archive with a pairing --no-whole-archive.

scchan updated this revision to Diff 529366.Jun 7 2023, 10:54 AM

added a matching --no-whole-archive

scchan marked an inline comment as done.Jun 7 2023, 10:54 AM
MaskRay added inline comments.Jun 7 2023, 11:41 AM
clang/lib/Driver/ToolChains/HIPAMD.cpp
175

For complete sentences in comments, capitalize and add a full stop.

Actually, this statement is self-explanatory and I don't think a comment is useful.

scchan updated this revision to Diff 529400.Jun 7 2023, 12:25 PM

Removed redundant comment.

scchan marked an inline comment as done.Jun 7 2023, 12:26 PM
This revision was landed with ongoing or failed builds.Jun 9 2023, 5:51 AM
This revision was automatically updated to reflect the committed changes.