nvptx64-nvidia-cuda target does not support self-referential statics
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
When compiling this code for the nvptx64-nvidia-cuda target, an LLVM error will be thrown:
#![no_std]
struct Bar(&'static Bar);
static FOO: Bar = Bar(&FOO);
rustc-LLVM ERROR: Circular dependency found in global variable set
Compiler returned: 101
This appears to be a fundamental limitation of PTX(self-referential globals are not allowed). This issue seems to be present in all versions of rust which support this target(from the newest nightly back to at least 1.45.2).
I am opening this issue mostly to document this limitation, and I have no idea how it could get fixed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the no_std self-referential-static reproducer for the nvptx64-nvidia-cuda target and compare its behavior using the linked Godbolt example. Investigate the reported LLVM circular-dependency error and the target's documented limitations; done means recording a confirmed limitation or identifying a tested path to resolve it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100