This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add special handling for CUDA PTX features
ClosedPublic

Authored by jhuber6 on Apr 17 2023, 7:22 AM.

Details

Summary

The NVIDIA compilation path requires some special options. This is
mostly because compilation is dependent on having a valid CUDA
toolchain. We don't actually need the CUDA toolchain to create the
exported libcgpu.a library because it's pure LLVM-IR. However, for
some language features we need the PTX version to be set. This is
normally set by checking the CUDA version, but without one installed it
will fail to build. We instead choose a minimum set of features on the
desired target, inferred from
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes
and the PTX refernece for functions like nanosleep.

Diff Detail

Event Timeline

jhuber6 created this revision.Apr 17 2023, 7:22 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 17 2023, 7:22 AM
jhuber6 requested review of this revision.Apr 17 2023, 7:22 AM

Nice, thank you! It's great seeing the list of misc flags needed to get freestanding nvptx to run shrink. This works for me.

tianshilei1992 accepted this revision.Apr 17 2023, 7:31 AM

Looks reasonable

This revision is now accepted and ready to land.Apr 17 2023, 7:31 AM
This revision was automatically updated to reflect the committed changes.