Skip to content

feat(godbolt): add Compiler Explorer integration for rust-cuda kernels#394

Open
g-ampo wants to merge 3 commits intoRust-GPU:mainfrom
g-ampo:godbolt-integration
Open

feat(godbolt): add Compiler Explorer integration for rust-cuda kernels#394
g-ampo wants to merge 3 commits intoRust-GPU:mainfrom
g-ampo:godbolt-integration

Conversation

@g-ampo
Copy link
Copy Markdown

@g-ampo g-ampo commented May 6, 2026

Summary

Add Compiler Explorer integration so users can compile rust-cuda kernels to PTX in the browser.

Closes #177, partially addresses #353.

Building on the discussion between @LegNeato and @Forsworns .This takes the "wrapper script that replicates cuda_builder's rustc invocation" route that @LegNeato suggested (to avoiding the need for cargo on the CE side)

Changes

  • contrib/godbolt/rust-cuda-wrapper.sh - wrapper that creates a temp Cargo project with the same rustflags as cuda_builder::invoke_rustc(), builds to PTX, extracts output from cargo JSON
  • contrib/godbolt/install.sh - installs pinned nightly, builds rustc_codegen_nvvm, lays out a self-contained prefix
  • contrib/godbolt/rust-cuda.defaults.properties - CE language/compiler config
  • contrib/godbolt/test-kernel.rs - sample kernels for smoke-testing
  • contrib/godbolt/README.md - local testing and upstream submission steps

Testing

  • cargo check passes
  • cargo clippy --workspace passes
  • Tested on: Ubuntu 24.04, RTX 3060 Ti, CUDA 13.0

Copy link
Copy Markdown
Contributor

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I am not super familiar with compiler explorer, so apologies if my review questions are dumb.

Comment thread contrib/godbolt/rust-cuda.defaults.properties Outdated
Comment thread contrib/godbolt/rust-cuda.defaults.properties Outdated
Comment thread contrib/godbolt/rust-cuda.defaults.properties
Comment thread contrib/godbolt/rust-cuda.defaults.properties
Comment thread contrib/godbolt/rust-cuda.defaults.properties
Comment thread contrib/godbolt/rust-cuda-wrapper.sh
@g-ampo g-ampo requested a review from LegNeato May 7, 2026 09:38
@LegNeato
Copy link
Copy Markdown
Contributor

LegNeato commented May 7, 2026

Thinking about this some more, instead of shell perhaps it would be better to write this tool in rust (a normal binary that can compile with any version of rust). Then we can add tests and such to our CI to make sure we don't inadvertently break the integration. As it is I am worried that we land something and don't know it breaks until we go to update the version in compiler explorer. Thoughts?

@g-ampo
Copy link
Copy Markdown
Author

g-ampo commented May 7, 2026

Yes would make sense. The main thing the Rust binary would still do is shell out to cargo build under the hood, so the breakage surface is similar to shell (for the glue parts)... but if it imports cuda_std or hooks into the build logic directly, that gives compile-time detection when APIs change, which shell can't do :)

Would be (very) happy to rewrite it in Rust.
Should I do it in this PR or land what's here and follow up?

@LegNeato
Copy link
Copy Markdown
Contributor

LegNeato commented May 8, 2026

Up to you!

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.

Add to godbolt

2 participants