rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.76k stars 425 forks source link

CUDA compiler family detection failed #1121

Open mrjbom opened 3 days ago

mrjbom commented 3 days ago

cc 1.0.104 My build.rs the script successfully compiles the CUDA file, but it has problems running its detect_compiler_family.c This is due to the fact that nvcc does not see cl.exe . But I can't help him by setting -ccbin how I do it to compile my CUDA file. How can I get rid of the warnings related to this?

fn main() {
    println!("cargo::rerun-if-changed=cuda/mandelbrot.cu");

    let mut build = cc::Build::new();
    let compiler = build.get_compiler();
    let ccbin = compiler.path();

    build
        .cuda(true)
        .cudart("static")
        .ccbin(false)
        .flag("-ccbin").flag(ccbin)
        .file("cuda/mandelbrot.cu");
    build.compile("mandelbrotcuda");
}

Warning is: Compiler family detection failed due to error: ToolExecError: Command "nvcc" "-E" "C:\Rust\mandelbrot_test_render\target\debug\build\mandelbrot_test_render-02f861198c0a4c7d\out\4903743526134228929detect_compiler_family.c" with args nvcc did not execute successfully (status code exit code: 1). If i run this directly in cmd nvcc fatal : Cannot find compiler 'cl.exe' in PATH

NobodyXu commented 3 days ago

nvcc fatal : Cannot find compiler 'cl.exe' in PATH

That's probably a limitation of our detection logic:

https://github.com/rust-lang/cc-rs/blob/eddc1fd3f944c2e00e9f067a6373b28868b54bcd/src/tool.rs#L143

I think maybe we should special case cuda here?

mrjbom commented 16 hours ago

I think maybe we should special case cuda here?

Of course. Although this is not critical, a lot of warnings get in the way.