Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

cargo gpu seems to fail when called froma build script. #64

@Makogan

Description

@Makogan

In trying to invoke rustgpu from a build.rs scripts as follows:

 let result = std::process::Command::new("cargo")
        .arg("gpu")
        .arg("build")
        .arg("--force-overwrite-lockfiles-v4-to-v3")
        .arg("--auto-install-rust-toolchain")
        .arg("--output-dir")
        .arg(path)
        .current_dir(path)
        .output()
        .unwrap();

    // TODO(low) log shader compilation.
    println!("aaaaaaaaaa {}", String::from_utf8_lossy(&result.stdout));
    println!("aaaaaaaaaa {}", String::from_utf8_lossy(&result.stderr));
    println!("{}", path);

I encounter the following error:

  Caused by:
    process didn't exit successfully: `/home/makogan/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -Zcodegen-backend=/home/makogan/.cache/rust-gpu/spirv-builder-cli/v0_9_0+nightly-2023-05-27/librustc_codegen_spirv.so -Zbinary-dep-depinfo -Csymbol-mangling-version=v0 '-Zcrate-attr=feature(register_tool)' '-Zcrate-attr=register_tool(rust_gpu)' -Coverflow-checks=off -Cdebug-assertions=off -Zinline-mir=off --target spirv-unknown-vulkan1.2 --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` (exit status: 1)
    --- stderr
    warning: failed to connect to jobserver from environment variable `CARGO_MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9"`: cannot open file descriptor 8 from the jobserver environment variable value: Bad file descriptor (os error 9)
      |
      = note: the build environment is likely misconfigured

    error: error loading target specification: could not find specification for target "spirv-unknown-vulkan1.2"
      |
      = help: run `rustc --print target-list` for a list of built-in targets

  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BuildFailed', src/main.rs:152:38
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  [2025-04-06T16:56:01Z ERROR cargo_gpu] build failed
  Error: build failed

To reproduce, attempt to compile any existing shader through a build.rs script

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