This is an archive of the discontinued LLVM Phabricator instance.

[HIP] link HIP runtime library without --hip-link
ClosedPublic

Authored by yaxunl on Jul 27 2023, 6:16 AM.

Details

Summary

When doing combined compilation/link for HIP source files, clang should link the HIP runtime library automatically without --hip-link.

Diff Detail

Event Timeline

yaxunl created this revision.Jul 27 2023, 6:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 6:16 AM
yaxunl requested review of this revision.Jul 27 2023, 6:16 AM

So this is equivalent to nvcc implicitly calling -lcudart? I've had thoughts about the clang-linker-wrapper adding known runtime flags to the link job if it's not found. E.g. if we find a CUDA image we pass -lcudart.

So this is equivalent to nvcc implicitly calling -lcudart? I've had thoughts about the clang-linker-wrapper adding known runtime flags to the link job if it's not found. E.g. if we find a CUDA image we pass -lcudart.

yes

jhuber6 added inline comments.Jul 27 2023, 6:21 AM
clang/include/clang/Driver/Driver.h
712 ↗(On Diff #544736)

Shouldn't we have access to the compilation? I figured we could check C.getActiveOffloadKinds() or w/e it's called.

yaxunl marked an inline comment as done.Jul 27 2023, 6:46 AM
yaxunl added inline comments.
clang/include/clang/Driver/Driver.h
712 ↗(On Diff #544736)

yes that is a better solution. will do

yaxunl updated this revision to Diff 544750.Jul 27 2023, 6:47 AM
yaxunl marked an inline comment as done.

revised by comments

jhuber6 accepted this revision.Jul 27 2023, 6:47 AM

LG, thanks.

This revision is now accepted and ready to land.Jul 27 2023, 6:47 AM
scchan added inline comments.Jul 27 2023, 8:27 AM
clang/docs/HIPSupport.rst
71

clang++ -xhip --offload-arch=gfx906 sample.o -o sample
would also work?

yaxunl marked an inline comment as done.Jul 27 2023, 9:55 AM
yaxunl added inline comments.
clang/docs/HIPSupport.rst
71

yes. since it will create a HIP toolchain

scchan accepted this revision.Jul 27 2023, 12:49 PM

LGTM thanks

This revision was landed with ongoing or failed builds.Aug 4 2023, 3:30 PM
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 3:30 PM