denzp / rust-ptx-builder

Convenient `build.rs` helper for NVPTX crates
MIT License
53 stars 9 forks source link

Unable to find extra-filename rustc flag #16

Open samsartor opened 4 years ago

samsartor commented 4 years ago

ptx-builder is failing with "Unable to find extra-filename rustc flag" when I am building my project. When I run cargo rustc --target nvptx64-nvidia-cuda -v .. myself I get:

rustc --crate-name sidequest_core --edition=2018 core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --crate-type rlib --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C debuginfo=2 --crate-type cdylib -C metadata=d9bb1f26303a4731 --out-dir /side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps --target nvptx64-nvidia-cuda -L dependency=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps -L dependency=/side/Code/sidequest-meet/target/release/deps --extern fnv=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps/libfnv-3eeaa6958d9eb02f.rlib --extern nalgebra=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps/libnalgebra-f28e713a257293dd.rlib --extern num_traits=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps/libnum_traits-72ce644de10ae911.rlib --extern rand=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps/librand-c254e8c85c3e4e8a.rlib --extern rustacuda_core=/side/Code/sidequest-meet/target/nvptx64-nvidia-cuda/release/deps/librustacuda_core-f3f21a55d0150a50.rlib --extern rustacuda_derive=/side/Code/sidequest-meet/target/release/deps/librustacuda_derive-d2b9f2aba2ab89c4.so

The same happens whether or not I include "rlib" as an additional crate type.

Interestingly, all my dependencies' rustc invokations appear to be getting the "extra-filename" param. It is just the final invocation (the one ptx-builder actually cares about) which is missing extra-filename.

If needed, I can take the time to create a minimal repro for you. But I'm guessing it is simply a problem with a newer cargo version which doesn't pass the argument.

I'm running:

samsartor commented 4 years ago

Figured out the difference! "-C extra-filename=..." won't be passed if in my Cargo.toml I have:

[lib]
crate-type = ["cdylib", "rlib"]

Unfortunately if I remove that section, I then get error: crate [dependency] required to be available in rlib format, but was not found in this form for some of my dependencies.

samsartor commented 4 years ago

Cargo yelling about crate [dependency] required to be available in rlib format, but was not found in this form turned out to be a bug that I can fix by setting set_var("CARGO_BUILD_PIPELINING", "false") in my build.rs.

I'm not sure if you want to handle the "crate-type" case gracefully or not so I'll leave the bug open. But if you decide it is not a problem, you can close it. I have my workaround!