-
Notifications
You must be signed in to change notification settings - Fork 892
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
un-revert "Set RUSTC and RUSTDOC env for child processes run through the proxy" #3035
Comments
There are two broad approaches to take.
|
there's also a third option which is just not to reland this and eat the performance hit. I would rather not take that approach. |
My take on this, there are two layers: usability for folk building things with rustup in play, and robustness of implementation. For folk building things with rustup, we can expect that the default position for everyone will be that they assume rustup is stateless, and are surprised when it isn't. This is already an issue on e.g. Windows, where we literally copy a copy of cargo around in some custom toolchain cases ( Line 622 in ccbce2c
So to my mind, we want the default behaviour to be safe: it should work, it shouldn't need changes in their code, and it should not result in bug reports or people creating gists to document how to make it work. Then, we have a choice: is higher performance opt-in (do something special and wheee it gets faster), or can we make it higher performance by default. Now the robustness of implementation thoughts: We setup RUSTC etc based on toolchain; toolchain is based on CWD (rust-toolchain{.toml}), CLI parameters (+toolchain), environment variables (RUSTUP_TOOLCHAIN). If we run all those inputs through an HMAC, including the calculated value for any variables we set, and export the result as an environment variable, then we have the following cases (when a new toolchain is being selected in an inner proxy):
In case 1, we will be able to detect the change of toolchain and setup everything to work correctly |
There is a fourth case: process sets RUSTC itself. If this is different than the one rustup decided on, we'll detect the change and everything is ok (we'll keep the one the process chose). If it's the same as the one rustup decided on, we won't know and we'll overwrite it. In practice I think it will be super rare to run |
I think if we're going to spend time on this we should also spend some time making an MCVE so we can test the behavior of our changes in different scenarios. |
yes, agreed - thats what I meant by 'RUSTC might be pointing into one of our toolchains'. MCVE? |
"minimum complete viable example" - just a way to reproduce this without spending 10 minutes compiling the projects in the original issue |
I think most people using rustup will be at least mildly aware that rustup has state, due to the prominence of the |
I think adding a persistent setting for this seems reasonable, yeah.
I expect people to know that rustup has state around installed and default toolchains, yes. But I think it's much more unlikely for people to know rustup has state within a single invocation of a rustup proxy. |
@jyn514 I suspect something with cargo-make that invokes a bash script that calls |
re statefulness - I meant within a single invocation, not that there isn't state present at all. But even there - many users have not ever encountered 'default' - the installer takes care of that, and we've had to explain more than once that misconfigurations can be self corrected using that feature |
(deleted; #3036) |
One thing that might be desirable is to tell people to prefer |
Does anyone here have any thoughts on fixing this by changing Cargo to invoke tools in the same directory as the cargo binary in preference to using PATH? rust-lang/cargo#10986 |
A promising approach: rust-lang/cargo#10986 (comment) |
Because I just thought about it, there may be a fairly simple rustup-only solution: instead of setting Footnotes
|
…enkov Add `rustc --print rustc-path` Related: - rust-lang/cargo#10986 - rust-lang/rustup#3035 Goal: Like the original rust-lang/rustup#2958, the goal is to enable `cargo` to call `rustc` directly, rather than through the `rustup` shim. Solution: `cargo` asks `rustc` to tell it what executable to run. Sometime early in compilation, `cargo` will run `$(RUSTC_WRAPPER) $(RUSTC ?: rustc) --print rustc-path`[^1]. Further calls to `rustc` to do execution will use the resolved printed executable path rather than continuing to call the "input `rustc` path," which will allow it to bypass the `rustup` shim. The cargo side is rust-lang/cargo#10998. [^1]: This can potentially be combined with other `--print`s, as well! This is a tiny patch, so I've implemented it as insta-stable; this will need signoff probably from both the compiler and cargo teams. I'm working on the cargo side of the patch currently, but wanted to get this up ASAP. cc `@davidlattimore` `@bjorn3` `@rust-lang/cargo` `@rust-lang/compiler` (sorry for the big ping list 😅)
…enkov Add `rustc --print rustc-path` Related: - rust-lang/cargo#10986 - rust-lang/rustup#3035 Goal: Like the original rust-lang/rustup#2958, the goal is to enable `cargo` to call `rustc` directly, rather than through the `rustup` shim. Solution: `cargo` asks `rustc` to tell it what executable to run. Sometime early in compilation, `cargo` will run `$(RUSTC_WRAPPER) $(RUSTC ?: rustc) --print rustc-path`[^1]. Further calls to `rustc` to do execution will use the resolved printed executable path rather than continuing to call the "input `rustc` path," which will allow it to bypass the `rustup` shim. The cargo side is rust-lang/cargo#10998. [^1]: This can potentially be combined with other `--print`s, as well! This is a tiny patch, so I've implemented it as insta-stable; this will need signoff probably from both the compiler and cargo teams. I'm working on the cargo side of the patch currently, but wanted to get this up ASAP. cc `@davidlattimore` `@bjorn3` `@rust-lang/cargo` `@rust-lang/compiler` (sorry for the big ping list 😅)
…enkov Add `rustc --print rustc-path` Related: - rust-lang/cargo#10986 - rust-lang/rustup#3035 Goal: Like the original rust-lang/rustup#2958, the goal is to enable `cargo` to call `rustc` directly, rather than through the `rustup` shim. Solution: `cargo` asks `rustc` to tell it what executable to run. Sometime early in compilation, `cargo` will run `$(RUSTC_WRAPPER) $(RUSTC ?: rustc) --print rustc-path`[^1]. Further calls to `rustc` to do execution will use the resolved printed executable path rather than continuing to call the "input `rustc` path," which will allow it to bypass the `rustup` shim. The cargo side is rust-lang/cargo#10998. [^1]: This can potentially be combined with other `--print`s, as well! This is a tiny patch, so I've implemented it as insta-stable; this will need signoff probably from both the compiler and cargo teams. I'm working on the cargo side of the patch currently, but wanted to get this up ASAP. cc ``@davidlattimore`` ``@bjorn3`` ``@rust-lang/cargo`` ``@rust-lang/compiler`` (sorry for the big ping list 😅)
…enkov Add `rustc --print rustc-path` Related: - rust-lang/cargo#10986 - rust-lang/rustup#3035 Goal: Like the original rust-lang/rustup#2958, the goal is to enable `cargo` to call `rustc` directly, rather than through the `rustup` shim. Solution: `cargo` asks `rustc` to tell it what executable to run. Sometime early in compilation, `cargo` will run `$(RUSTC_WRAPPER) $(RUSTC ?: rustc) --print rustc-path`[^1]. Further calls to `rustc` to do execution will use the resolved printed executable path rather than continuing to call the "input `rustc` path," which will allow it to bypass the `rustup` shim. The cargo side is rust-lang/cargo#10998. [^1]: This can potentially be combined with other `--print`s, as well! This is a tiny patch, so I've implemented it as insta-stable; this will need signoff probably from both the compiler and cargo teams. I'm working on the cargo side of the patch currently, but wanted to get this up ASAP. cc ```@davidlattimore``` ```@bjorn3``` ```@rust-lang/cargo``` ```@rust-lang/compiler``` (sorry for the big ping list 😅)
…enkov Add `rustc --print rustc-path` Related: - rust-lang/cargo#10986 - rust-lang/rustup#3035 Goal: Like the original rust-lang/rustup#2958, the goal is to enable `cargo` to call `rustc` directly, rather than through the `rustup` shim. Solution: `cargo` asks `rustc` to tell it what executable to run. Sometime early in compilation, `cargo` will run `$(RUSTC_WRAPPER) $(RUSTC ?: rustc) --print rustc-path`[^1]. Further calls to `rustc` to do execution will use the resolved printed executable path rather than continuing to call the "input `rustc` path," which will allow it to bypass the `rustup` shim. The cargo side is rust-lang/cargo#10998. [^1]: This can potentially be combined with other `--print`s, as well! This is a tiny patch, so I've implemented it as insta-stable; this will need signoff probably from both the compiler and cargo teams. I'm working on the cargo side of the patch currently, but wanted to get this up ASAP. cc ````@davidlattimore```` ````@bjorn3```` ````@rust-lang/cargo```` ````@rust-lang/compiler```` (sorry for the big ping list 😅)
Problem you are trying to solve
We had some nice performance enhancements but hadn't caught an edge case well enough (which has led to a reversion). Lets support that and then re-enable the code
Solution you'd like
Robust automatic detection of different toolchain selection in recursive rustup proxy use. Nothing special needed by callers, except passing through variables
Notes
The text was updated successfully, but these errors were encountered: