Skip to content

override cargo config target directory for cargo-gpu-install - #687

Open
wyvernbw wants to merge 2 commits into
Rust-GPU:mainfrom
wyvernbw:wyvernbw/use-target-dir
Open

wyvernbw wants to merge 2 commits into
Rust-GPU:mainfrom
wyvernbw:wyvernbw/use-target-dir

Conversation

@wyvernbw

Copy link
Copy Markdown

currently cargo-gpu-install (and by extension cargo-gpu) fail if you use a custom target directory (for example i use a shared target dir across all my projects, set in ~/.cargo/config.toml). this pr makes it so the install falls back to the target directory that's given by cargo-metadata if the target/release/{dylib_filename} file is missing.

@Firestar99 Firestar99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand the purpose of this patch. If you're compiling the codegen backend crate rustc_codegen_spirv, you're doing so with a specific rustc version. Switching rustc versions always requires a clean build, so your global build cache aint't doing anything if you don't have other projects fixed to the same rustc version. And it won't share with the spirv target either, since every target is getting it's own subdirectory.

Comment thread crates/cargo-gpu-install/src/install.rs Outdated
@wyvernbw

wyvernbw commented Oct 30, 2026 •

Copy link
Copy Markdown
Author

i think you misunderstood, the compilation automatically puts artifacts in the shared target directory and cargo-gpu-install fails to find them at all because it only looks in the hardcoded, relative target/release path. You'd have to temporarily disable the global cargo config to get around it. The purpose isn't to share a build cache between targets. And you're right that I messed up when the check happens

EDIT: I think a much better solution would actually be to use cargo's --target-dir arg to force it to use the right path

@wyvernbw wyvernbw changed the title honor target dir config in cargo-gpu-install override target dir config cargo-gpu-install Oct 30, 2026
@wyvernbw wyvernbw changed the title override target dir config cargo-gpu-install override cargo config target directory for cargo-gpu-install Oct 30, 2026
@wyvernbw

Copy link
Copy Markdown
Author

I changed the install code to pass --target-dir to cargo, which makes it ignore the global target dir config, so it works properly and the artifacts are in the same place for everyone. I think this a way cleaner approach

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants