Skip to content

nvptx64-nvidia-cuda target does not support self-referential statics #146787

@FractalFir

Description

@FractalFir

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-NVPTXTarget: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.htmlT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions