Skip to content

Commit 4527567

Browse files
committed
fix(build-std): always link to std when testing/running proc-macros
1 parent 33e6b33 commit 4527567

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/cargo/core/compiler/compilation.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,10 @@ impl<'gctx> Compilation<'gctx> {
315315
// libs from the sysroot that ships with rustc. This may not be
316316
// required (at least I cannot craft a situation where it
317317
// matters), but is here to be safe.
318-
if self.gctx.cli_unstable().build_std.is_none() {
318+
if self.gctx.cli_unstable().build_std.is_none() ||
319+
// Proc macros dynamically link to std, so set it anyway.
320+
pkg.proc_macro()
321+
{
319322
search_path.push(self.sysroot_target_libdir[&kind].clone());
320323
}
321324
}

tests/build-std/main.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,7 @@ fn test_proc_macro() {
386386
[COMPILING] foo v0.0.0 ([ROOT]/foo)
387387
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
388388
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH])
389-
dyld[[..]]: Library not loaded: @rpath/libstd-[HASH].dylib
390-
Referenced from: <[..]> [ROOT]/foo/target/debug/deps/foo-[HASH]
391-
Reason: tried: '[ROOT]/foo/target/debug/deps/libstd-[HASH].dylib' (no such file), '[ROOT]/foo/target/debug/libstd-[HASH].dylib' (no such file), '/usr/local/lib/libstd-[HASH].dylib' (no such file), '/usr/lib/libstd-[HASH].dylib' (no such file, not in dyld cache)
392-
[ERROR] test failed, to rerun pass `--lib`
393-
394-
Caused by:
395-
process didn't exit successfully: `[ROOT]/foo/target/debug/deps/foo-[HASH]` ([..])
396389
397390
"#]])
398-
.with_status(101)
399391
.run();
400392
}

0 commit comments

Comments
 (0)