-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CARGO_PATH environment variable #6909
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! I would personally be hesitant to merge this feature though. This seems like a bit of hack in Cargo to work around something that may not be fully understood? Are there perhaps other ways to solve this problem without resorting to this hammer? |
In my understanding about rust-lang/rust#58394, the followings must be system toolchain because official rustc binary is linked to system libc.
Because both of them use PATH to search toolchain, I think the issue can be resolved by CARGO_PATH. individual settingBoth of them can be set individually. Linker called by cargo can be set by
C compiler called by cc-rs can be set by
ProsNo modification is needed. Cons
wrapper of cargoA wrapper of cargo can set PATH passed to cargo.
ProsNo modification is needed. ConsThis is not a feature of cargo/rustc. So I would be hesitant to announce this solution to other linuxbrew users. |
If the goal here is to switch linkers then configuring |
Linker called by cargo can be specified through |
Ok if this is purely about switching linkers I'm going to close this since that's done with various other configuration that we have in Cargo. Switching rustc's linker is done via |
Ok. I will resolve this issue by cargo wrapper function. |
How Windows 10 Solves this Problem error: linker error: aborting due to previous error |
This doesn't really work in a number of cases without something like #9322. |
This PR adds an environment variable CARGO_PATH to specify search path for programs spawned by cargo.
If there is a newer compiler than system compiler on PATH, some rust compilation fail.
This is reported at rust-lang/rust#58394 and #6582.
To resolve the issue, this PR adds CARGO_PATH to specify compiler and linker path.
For example, rust-lang/rust#58394 can be resolved like below.
In this case, cargo without CARGO_PATH calls
~/.linuxbrew/bin/cc
as linker, but rustc expects system linker, therefore the compilation fails. Alternatively cargo with CARGO_PATH calls system linker and the compilation succeeds.