bazelbuild / bazelbuild/rules_rust
High number of dependencies could lead to `can't find crate` on Windows
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
`rules_rust` sets one `-Ldependency` statement per transitive dependency, leading to potentially a very long library search path.
The issue is, on Windows, in `rustc` the search paths get added to [the PATH environment variable](https://github.com/rust-lang/rust/blob/8b8110e1469d459a196f6feb60d82dec48c3cfc2/compiler/rustc_interface/src/passes.rs#L195-L225), but on Windows [environment variables have a limit of 32,767 characters](https://learn.microsoft.com/en-us/windows/win32/api/processenv/nf-processenv-setenvironmentvariablew).
The probability of that bug happening in `rules_rust` is quite high.
Could we try to workaround it until it is fixed at `rustc`'s side?
See https://github.com/rust-lang/rust/issues/110889
### Steps to reproduce
1. Create a `rust_library` `somecrate`, it does not need to have sources
2. Craete a `rust_binary` `somebinary`, with the following sources:
```rust
// main.rs
use somecrate::*;
pub fn main() {}
```
3. Add `somecrate` to `deps` of `somebinary`, alongside many other (unused) dependencies
4. Try to build `somebinary`
It should lead to:
```
error[E0463]: can't find crate for `somecrate`
--> main.rs:1:5
|
1 | use somecrate::*;
| ^^^^ can't find crate
```
Contributor guide
Assessment
This issue has not been assessed yet.