Rust-GPU / Rust-GPU/rust-cuda

Couldn't load codegen backend, specified module could not be found

Open
#327 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.4k
Forks
249
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to build the example described in the getting started guide on Windows but I got an error:

> cargo build
   Compiling rustc_codegen_nvvm v0.3.0 (https://github.com/rust-gpu/rust-cuda?rev=7fa76f3d717038a92c90bf4a482b0b8dd3259344#7fa76f3d)
   Compiling cuda_builder v0.3.0 (https://github.com/rust-gpu/rust-cuda?rev=7fa76f3d717038a92c90bf4a482b0b8dd3259344#7fa76f3d)
   Compiling rust-cuda-basic v0.1.0 (D:\workspace\rust-cuda-basic)
error: failed to run custom build command for `rust-cuda-basic v0.1.0 (D:\workspace\rust-cuda-basic)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `D:\workspace\rust-cuda-basic\target\debug\build\rust-cuda-basic-11d5ae9c94c06876\build-script-build` (exit code: 101)
  --- stdout
  cargo::rerun-if-changed=build.rs
  cargo::rerun-if-changed=kernels
  cargo:rerun-if-changed=D:\workspace\rust-cuda-basic\kernels

  --- stderr
  error: failed to run `rustc` to learn about target-specific information

  Caused by:
    process didn't exit successfully: `C:\Users\Carrot\.rustup\toolchains\nightly-2025-08-04-x86_64-pc-windows-msvc\bin\rustc.exe - --crate-name ___ --print=file-names -Zcodegen-backend=D:\workspace\rust-cuda-basic\target\debug\rustc_codegen_nvvm.dll -Zcrate-attr=feature(register_tool) -Zcrate-attr=register_tool(nvvm_internal) -Zcrate-attr=no_std -Zsaturating_float_casts=false "-Cllvm-args=-arch=compute_75 --override-libm" --target nvptx64-nvidia-cuda --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit code: 1)
    --- stderr
    error: couldn't load codegen backend \\?\D:\workspace\rust-cuda-basic\target\debug\rustc_codegen_nvvm.dll: LoadLibraryExW failed: The specified module could not be found. (os error 126) (The specified module could not be found. (os error 126)) (retried 5 times)


  thread 'main' panicked at build.rs:17:10:
  called `Result::unwrap()` on an `Err` value: BuildFailed
  stack backtrace:
     0: std::panicking::begin_panic_handler
               at /rustc/f34ba774c78ea32b7c40598b8ad23e75cdac42a6/library\std\src\panicking.rs:697
     1: core::panicking::panic_fmt
               at /rustc/f34ba774c78ea32b7c40598b8ad23e75cdac42a6/library\core\src\panicking.rs:75
     2: core::result::unwrap_failed
               at /rustc/f34ba774c78ea32b7c40598b8ad23e75cdac42a6/library\core\src\result.rs:1852
     3: build_script_build::main
     4: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

But the codegen backend path does exist:

> ls D:\workspace\rust-cuda-basic\target\debug\rustc_codegen_nvvm.dll

    Directory: D:\workspace\rust-cuda-basic\target\debug

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          30/11/2025  9:39 am       31755776 rustc_codegen_nvvm.dll

Any idea on what the actual problem is?

I'm using the prebuilt LLVM and CUDA 13.

Repro can be found here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the linked rust-cuda-basic project and the getting started guide, then inspect build.rs around line 17 and the rustc_codegen_nvvm DLL-loading command on Windows. Check why LoadLibraryExW reports a missing module despite the DLL path existing; done means identifying the missing dependency or configuration and documenting or correcting the Windows build path.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.