bootstrap: support shell argfiles in compiler shims#159083
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Hm, I guess Miri will also need this support (I assume it doesn't have it) if we continue to perpetuate shell files containing the arguments most wrappers look for (e.g., --target, --sysroot probably). cc @RalfJung I'm wondering if we should instead be teaching Cargo to not put those inside the argfile rather than copying the wrapper code to undo the argfiles into a bunch of places. I guess the undoing of argfiles is more general but it also seems fairly hard to get right (based on needing several PRs) -- maybe the right answer is that we need to have a crates.io crate that implements that, perhaps published from Cargo repo -- so that we can at least reuse a single implementation? Skimming the implementation here it looks OK though. Is there a tracking issue for shell-argfiles? I'm not seeing one right now. The original MCP (rust-lang/compiler-team#684) seems to suggest it was needed for Ninja compatibility, but it's not clear to me if that actually materialized / we are compatible. |
|
Miri has no support for argfiles indeed. When this came up with rustdoc, we were able to keep the relevant arguments out of the argfile and only stuff the long list of linker flags there, which Miri does not care about. Would something like that also be possible here? |
Thanks, that makes sense. The current change mirrors rustc's expansion so the bootstrap shims see the same arguments, Cargo currently writes all rustc/rustdoc arguments to its response file. I’ll investigate keeping wrapper-visible I have not found a dedicated tracking issue for -Zshell-argfiles; rust-lang/compiler-team#684 appears to be the |
That's up to the bootstrap maintainers. This PR doesn't make things any worse for Miri, but it may become unnecessary if a cargo-side solution gets implemented. |
Follow-up to #159036.
The bootstrap rustc and rustdoc shims expand argument files so that they can
inspect arguments such as
--targetbefore invoking the actual compiler.However, the current expansion treats every
@...argument as a regularline-based argument file. When rustc's
-Zshell-argfilesoption is enabled,an argument such as
@shell:<path>is therefore interpreted as a file namedshell:<path>. The shim fails while opening that path before the real compilercan process it.
This change makes the shim's argument expansion follow rustc's behavior:
-Zshell-argfilesand-Z shell-argfiles.@shell:<path>usingshlex.Tests cover both supported
-Zforms, including enabling shell argument filesfrom another argument file.
Tested with: