Skip to content

feat(cuda-oxide): add Windows x86_64 MSVC support - #1770

Merged
nihalpasham merged 4 commits into
NVIDIA:mainfrom
nihalpasham:feat/windows-msvc-support
Nov 11, 2026
Merged

nihalpasham merged 4 commits into
NVIDIA:mainfrom
nihalpasham:feat/windows-msvc-support

Conversation

@nihalpasham

Copy link
Copy Markdown
Collaborator

Summary

Adds native Windows (x86_64-pc-windows-msvc) support for cuda-oxide across the artifact writer, CUDA Toolkit discovery, cargo-oxide backend build and runtime loader paths, and smoke test infrastructure (pairs with #1473 for shared cuda-bindings enum signedness; closes #139):

  • oxide-artifacts and rustc-codegen-cuda:
    • Emits COFF .oxart relocatable object sections (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ) for x86_64-pc-windows-msvc and aarch64-pc-windows-msvc alongside Linux ELF.
    • Uses .obj object extensions on Windows host targets in rustc-codegen-cuda and patches the isolated backend workspace to consume the in-tree COFF writer while keeping host runtimes on the crates.io release.
  • cuda-toolkit-discovery, libnvvm-sys, nvjitlink-sys, and cuda-artifact-finalizer:
    • Adds workspace-private cuda-toolkit-discovery for Linux and Windows CUDA Toolkit roots (CUDA_TOOLKIT_PATH, CUDA_HOME, CUDA_PATH, CUDA_PATH_V*, and C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v*) and versioned nvvm64_*.dll / nvJitLink_*.dll discovery.
    • Handles Windows file identities, path separators, executable suffixes, and CRLF normalization in cuda-host, cuda-oxide-codegen, and cuda-intrinsics-gen.
  • cargo-oxide and cuda-macros:
    • Adds target-aware dylib/executable/loader helpers (platform.rs), builds rustc_codegen_cuda.dll in --release with lld-link and ffi.lib lookup on Windows MSVC, and fixes cargo oxide doctor llc.exe detection on Windows.
    • Emits a COFF /alternatename fallback stub on Windows MSVC in #[device] extern "C" blocks so host binaries do not fail to link device-only LTOIR extern symbols.
  • Smoke tests and documentation:
    • Updates scripts/smoketest.sh to support Windows under Git Bash (pwd -W, ptxas -o NUL, and release/rustc_codegen_cuda.dll backend pinning), adds scripts/smoketest.ps1, and adds the Windows setup guide in cuda-oxide-book/getting-started/windows.md.

Test plan

  • just -f cuda-oxide/Justfile fmt-check
  • just -f cuda-oxide/Justfile check-guards
  • just -f cuda-oxide/Justfile clippy
  • cargo test -p oxide-artifacts --features object
  • cargo test -p cuda-toolkit-discovery -p libnvvm-sys -p nvjitlink-sys -p cuda-artifact-finalizer -p cargo-oxide
  • Validated on Windows 11 24H2 (x86_64-pc-windows-msvc, Blackwell sm_120a): cargo oxide setup, cargo oxide doctor, scripts/smoketest.ps1, bash scripts/smoketest.sh, and cargo oxide sanitize vecadd --arch sm_120a

@nihalpasham
nihalpasham force-pushed the feat/windows-msvc-support branch 7 times, most recently from 94ce588 to 828b27a Compare November 11, 2026 12:36
@nihalpasham
nihalpasham force-pushed the feat/windows-msvc-support branch from 828b27a to 160bab3 Compare November 11, 2026 12:39
@nihalpasham nihalpasham added cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book platform-support OS / target platform support (Windows, macOS, non-Linux toolchains) windows Windows (x86_64-pc-windows-msvc) platform and toolchain support cargo-oxide The `cargo oxide` subcommand and build automation build-related Build scripts, toolchain discovery, or compilation setup documentation Improvements or additions to documentation enhancement New feature or request labels Nov 11, 2026
@nihalpasham
nihalpasham merged commit 4b9133c into NVIDIA:main Nov 11, 2026
81 checks passed
elibol pushed a commit that referenced this pull request Nov 11, 2026
Transplanted from `NVlabs/cutile-rs#318` onto `NVIDIA/cuda-rust` `main`
(closes #1441) and pairs with #1770 to complete native Windows
(`x86_64-pc-windows-msvc`) support.

## Overview

On Linux (`x86_64-unknown-linux-gnu`), Clang maps unscoped C enums whose
enumerators are all non-negative to unsigned `c_uint` (`u32`). On
Windows MSVC (`x86_64-pc-windows-msvc`), the MSVC C ABI defaults all
unscoped C enums to signed `c_int` (`i32`), causing 18 type-mismatch
errors (`expected u32, found i32`) when compiling `cuda-core`:

```text
CUDA C Header (`cuda.h`)
  enum CUstream_flags_enum { CU_STREAM_DEFAULT = 0x0, ... };
        │
        ├──► Linux SysV ABI (Clang / bindgen)
        │      pub type CUstream_flags_enum = c_uint; (u32) ──► matches cuda-core u32 APIs
        │
        └──► Windows MSVC ABI (Clang / bindgen)
               Before: pub type CUstream_flags_enum = c_int;  (i32) ──► 18 type-mismatch errors in cuda-core
               After:  pub type CUstream_flags_enum = c_uint; (u32) ──► matches Linux & cuda-core u32 APIs
```

Standardizing the 9 non-negative CUDA driver enums to
`::core::ffi::c_uint` (`u32`) in `cuda-bindings/build.rs` resolves the
mismatch once at the binding generation boundary without scattering
platform casts across `cuda-core` or downstream crates. Enums with
negative values (such as `CUshared_carveout_enum` with `-1`) remain
signed `c_int`.

## Changes

| File | Change |

|:-----------------------------------------------------------|:-----------------------------------------------------------------------------|
| `cuda-bindings/build.rs` | Maps 9 non-negative CUDA driver enums from
`c_int` to `::core::ffi::c_uint` |
| `cutile-rs/cutile-compiler/src/cuda_tile_runtime_utils.rs` | Uses
`tileiras_executable_name()` (`tileiras.exe` on Windows) in path tests |
| `cutile-rs/cutile-ir/tests/bytecode_validate.rs` | Writes `tileiras`
validation output to `NUL` instead of `/dev/null` on Win32 |
| `cutile-rs/cutile-ir/tests/requirements.rs` | Normalizes `\r\n` line
endings before comparing requirement tables |

### Standardized Enums (`cuda-bindings/build.rs`)

- `CUstream_flags_enum`
- `CUlaunchAttributeID_enum`
- `CUctx_flags_enum`
- `CUevent_flags_enum`
- `CUevent_wait_flags_enum`
- `cudaError_enum`
- `CUdevice_attribute_enum`
- `CUfunction_attribute_enum`
- `CUjit_option_enum`

## Validation

- [x] `cargo check --workspace --all-targets` (root host workspace on
Windows 11 24H2 `x86_64-pc-windows-msvc`)
- [x] `cargo test -p cuda-core --lib` (49 / 49 passed on Windows
Blackwell `sm_120a`)
- [x] `cargo test -p cutile-compiler --lib` (132 / 132 passed on
Windows)
- [x] `cargo test -p cutile-ir` (all unit, determinism, bytecode
validation, and roundtrip suites passed on Windows)
- [x] End-to-end `cuda-oxide` Windows smoke suite
(`scripts/smoketest.sh`: 257 / 257 examples passed on Windows Blackwell
`sm_120a` with #1770)

Signed-off-by: Temo Tskipuri <[email protected]>
@ansidium

Copy link
Copy Markdown
Contributor

I've published CUDA Rust Windows 0.4.0, a community distribution incorporating this PR, with a verified prebuilt backend and signed installer. Details, installer preview and test results: Show and tell.

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

Labels

build-related Build scripts, toolchain discovery, or compilation setup cargo-oxide The `cargo oxide` subcommand and build automation cuda-oxide SIMT programming model: rustc backend, cargo oxide, cuda-device, cuda-host, book documentation Improvements or additions to documentation enhancement New feature or request platform-support OS / target platform support (Windows, macOS, non-Linux toolchains) windows Windows (x86_64-pc-windows-msvc) platform and toolchain support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows MSVC support fork and signed release artifacts

2 participants