Skip to content

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

@kafji

Description

@kafji

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions