-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Long argsfile doesn't work properly on Windows #79923
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
Comments
I also checked that it doesn't fail neither on Mac nor Linux even if argsfile is 100 times bigger. Also it seems that it starts to fail not because of large argsfile itself but because of total length of paths in |
That array bounds error is from: rust/compiler/rustc_codegen_ssa/src/back/symbol_export.rs Lines 287 to 296 in fa41639
which seems to be assuming that all Should it actually be:
? |
Summary: Attempt to handle rust-lang/rust#79923 on our side which probably won't be fixed very soon. The issue there with length of argsfile with dependency arguments (or actually with the total length of paths to them). Relative paths are obviously much shorter and it's enough to not hit this issue right now. Note that `dependentFilesystem` shouldn't be added to rule key in `RustLibraryArg`, otherwise rule key computation will fail. Reviewed By: jsgf fbshipit-source-id: c8bd2dbfb2982642010c4af1c7da3a637c87eab5
For what it's worth, I added a batch file version of the reproduction script. This way you can reproduce the problem without having to use a unix shell: https://github.com/KapJI/rust_example/blob/main/test.cmd |
I did some debugging and here is what's going on there. All directories from library search path are added to rust/compiler/rustc_interface/src/passes.rs Lines 280 to 309 in 47aeac6
And it gets very long. Documentation says that the maximum length for environment variable is 32,767 and there is no limit on the total size of environment block in recent versions of Windows: It doesn't seem to be the whole truth though. In my case the issue starts when
But after setting the new In this example dependencies look like: rust/compiler/rustc_metadata/src/creader.rs Line 674 in 47aeac6
That call fails and import resolution ends up in some bad state. Some problems I noticed
@alexcrichton as you implemented this logic in the first place, is there something that can be improved on rustc side? |
Sorry this is all so far out of cache for me I fear I won't be of much use. All I remember is that blocks like that in the compiler are really only there to make things work, so if things work without a block like that or if blocks like that are altered and things still work that's probably fine then. It's unlikely rustc needs to do exactly what it does today to keep working. |
RE: The comment that says "Windows dlls do not have rpaths". That's true but also not quite right. Configuration manifests allow setting probing paths. However, they're limited to either subdirectories or a maximum or two levels above the directory. Though I'm not sure if this information is useful for this use case (and it's possible they might be length limited too, I don't know off hand). On the environment limits. I'm not entirely surprised that ~32k is still an issue, unfortunately. The kernel uses structures like |
Summary: See rust-lang/rust#79923 for the motivation, we replicate what happens with cargo Reviewed By: jdonald, jsgf fbshipit-source-id: 9c9ac1c8c99f13014ecf4d552ad2a7690c0e2873
Example: https://github.com/KapJI/rust_example
Commands to repro: https://github.com/KapJI/rust_example/blob/main/test.sh
Example CI job: https://github.com/KapJI/rust_example/runs/1534666156
With shorter argsfile it compiled correctly but longer one failed with
which is very obscure and not really relevant.
Note that I added many duplicated lines in argsfiles to demonstrate that it starts to fail after some threshold, actual content is not important. In the real project we have different lines for different dependencies.
If you comment
in
a/lib.rs
it will work in both cases. But this trait is actually not used in this example.At some point I also got internal compiler error, not sure if it's relevant:
The text was updated successfully, but these errors were encountered: