Skip to content

Upgrade modern backend to LLVM 21.1.8 and CUDA 13.3 - #408

Merged
LegNeato merged 1 commit into
Rust-GPU:mainfrom
brandonros:experiment/cuda13.3-llvm21
Sep 22, 2026
Merged

LegNeato merged 1 commit into
Rust-GPU:mainfrom
brandonros:experiment/cuda13.3-llvm21

Conversation

@brandonros

@brandonros brandonros commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Replace the modern LLVM 19 backend feature with LLVM 21 while retaining LLVM 7 for the legacy path. Update feature forwarding, LLVM tool discovery, the vector-add example, and documentation together. The modern Nix shell uses LLVM 21.1.8 and CUDA 13.3; CUDA 13 Docker definitions use CUDA 13.3.1 bases. Update the Windows CUDA installer action to support CUDA 13.3.1.

LLVM 21 compatibility fixes included here:

  • rustc_llvm_wrapper: guard the llvm/Transforms/Instrumentation.h include to LLVM < 19 (the header is gone in LLVM 21; only the legacy pass registry uses it) and update the wrapper to the LLVM 21 APIs. tests/llvm-wrapper/ adds a small C++ check of the attribute/capture semantics the wrapper relies on.
  • nvvm: restore kernel annotations after the LLVM 21 bitcode upgrade.
  • cust: handle CUDA 13.3's new CU_GRAPH_NODE_TYPE_RESERVED_16 graph node type, which made an existing match non-exhaustive.

Extend the existing Linux CI matrix with LLVM 21 vector-add host/PTX compilation on x86_64 and aarch64, using CUDA 13.3.1 and LLVM 21.1.8 prebuilts. The six existing LLVM 7 configurations retain their workspace checks. There is no separate experiment workflow.

LLVM 21 prebuilts

The backend's default LLVM 21 download URL is the upstream Rust-GPU/rustc_codegen_nvvm-llvm llvm-21.1.8 release, which does not exist yet, so default downloads fail until it is published. That needs Rust-GPU/rustc_codegen_nvvm-llvm#4 merged and a release with linux-x86_64.tar.xz, linux-aarch64.tar.xz, and windows-x86_64.tar.xz.

Until then, the archive directory is overridable through PREBUILT_LLVM_URL (environment variable for the backend, repository Actions variable for CI; documented in the guide). The CI LLVM 21 jobs currently default to the same three archives published at https://github.com/brandonros/rustc_codegen_nvvm-llvm/releases/tag/llvm-21.1.8. Before merge, that default and the guide example should point at the upstream release.

Status

All LLVM 7 Linux jobs, both Windows jobs, and all container image builds pass, including the new Ubuntu-24.04/CUDA-13.3.1/LLVM-21.1.8 image.

The two LLVM 21 jobs compiled the wrapper and rustc_codegen_nvvm, then failed linking librustc_codegen_nvvm.so with unable to find library -lzstd: the prebuilts are built with zstd support, so llvm-config --system-libs emits -lzstd, and the job's container did not install libzstd-dev. The fix is to install libzstd-dev in that job.

Not ready to merge: pending the upstream release, a green LLVM 21 CI run, and runtime validation. The LLVM 21 jobs only compile the vector-add example; GPU execution and broader LLVM 21 workspace checks are not covered yet.

Based directly on upstream main; no portable PTX exporter changes are included.

@LegNeato

Copy link
Copy Markdown
Contributor
 = note: /usr/bin/ld: cannot find -lzstd: No such file or directory
            collect2: error: ld returned 1 exit status
            

Looks like we need to install something?

@brandonros
brandonros force-pushed the experiment/cuda13.3-llvm21 branch from 4decb7c to af6880e Compare September 21, 2026 13:44
@brandonros

Copy link
Copy Markdown
Contributor Author
 = note: /usr/bin/ld: cannot find -lzstd: No such file or directory
            collect2: error: ld returned 1 exit status
            

Looks like we need to install something?

image

Replace the LLVM 19 backend feature with LLVM 21 while retaining LLVM 7
for the legacy path. Update feature forwarding, LLVM tool discovery, the
vector-add example, the Nix shell, container definitions, and docs.

- rustc_llvm_wrapper: guard the Instrumentation.h include to LLVM < 19 and
  update wrapper APIs for LLVM 21; add tests/llvm-wrapper capture checks.
- nvvm: restore kernel annotations after the LLVM 21 bitcode upgrade.
- cust: handle CUDA 13.3's CU_GRAPH_NODE_TYPE_RESERVED_16 graph node type.
- CI: add LLVM 21 vector-add jobs on x86_64 and aarch64 using CUDA 13.3.1
  and LLVM 21.1.8 prebuilts, with a configurable PREBUILT_LLVM_URL; install
  libzstd-dev so the static LLVM link resolves -lzstd.
- Update the Windows CUDA installer action for CUDA 13.3.1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@brandonros
brandonros force-pushed the experiment/cuda13.3-llvm21 branch from af6880e to 0e5545c Compare September 21, 2026 13:45
@brandonros

Copy link
Copy Markdown
Contributor Author

@LegNeato Rust-GPU/rustc_codegen_nvvm-llvm#4 and then this whenever you're ready/if you have any feedback

thanks

@LegNeato

Copy link
Copy Markdown
Contributor

Will merge once the other one builds, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants