Commit 8ba3ec2
authored
fix(build-std): always link to std when testing proc-macros (#14850)
### What does this PR try to resolve?
Fixes #14735
rust-lang/rust#131188 removes libstd.so from
sysroot so `cargo test -Zbuild-std` no longer links to it. That results
in a "Library not loaded: @rpath/libstd-[HASH].dylib" when testing a
proc macro.
This is a pretty niche use case, though it can be easily reproduced by
running `cargo test -Zbuild-std` in any proc-macro package. Like in
[serde-rs/serde](https://github.com/serde-rs/serde/tree/b9dbfcb4ac3b7a663d9efc6eb1387c62302a6fb4)
running it would fail.
This patch adds a special case that if it is `cargo run/test` against a
proc-macro, fill in std dynamic library search path for it.
### How should we test and review this PR?
```
CARGO_RUN_BUILD_STD_TESTS=1 cargo +nightly t --test build-std test_proc_macro
```
or
```
git clone https://github.com/serde-rs/serde
cd serde
git switch -d b9dbfcb4ac3b7a663d9efc6eb1387c62302a6fb4
cargo +nightly t --test build-std
```
### Additional informationFile tree
2 files changed
+34
-1
lines changed- src/cargo/core/compiler
- tests/build-std
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
319 | 322 | | |
320 | 323 | | |
321 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
0 commit comments