Skip to content

Commit 294967c

Browse files
committed
Auto merge of #10137 - ehuss:lto-pdb-collision-test, r=alexcrichton
Fix some tests with output collisions. This fixes some tests which run afoul of creating colliding outputs (tracked in #6313). In particular, these tests are creating duplicate pdb files on Windows because they have a binary and a library (dylib) with the same name. This is causing significant issues on rust-lang's CI (rust-lang/rust#81890) where the MSVC linker is failing with a mysterious LNK1201 error. Presumably two LINK.exe processes are trying to write to the same PDB file at the same time, which causes it to fail. Ideally this shouldn't happen, but I don't really have any ideas on how to resolve it, as the name of the PDB has some importance. I have not been able to reproduce the LNK1201 error. My hope is that this change will help alleviate the issue, though. I updated the `doc_all_member_dependency_same_name` test to illustrate that it is hitting a collision, which is a fundamental part of that test (and something we should probably figure out how to resolve in the future).
2 parents 26105a4 + 2507d53 commit 294967c

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

tests/testsuite/clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ fn package_cleans_all_the_things() {
416416
"#,
417417
)
418418
.file("src/lib.rs", "")
419-
.file("src/main.rs", "fn main() {}")
419+
.file("src/lib/some-main.rs", "fn main() {}")
420420
.file("src/bin/other-main.rs", "fn main() {}")
421421
.file("examples/foo-ex-rlib.rs", "")
422422
.file("examples/foo-ex-cdylib.rs", "")

tests/testsuite/doc.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,24 @@ fn doc_all_member_dependency_same_name() {
12421242
Package::new("bar", "0.1.0").publish();
12431243

12441244
p.cargo("doc --workspace")
1245-
.with_stderr_contains("[..] Updating `[..]` index")
1246-
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
1245+
.with_stderr_unordered(
1246+
"\
1247+
[UPDATING] [..]
1248+
[DOWNLOADING] crates ...
1249+
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
1250+
warning: output filename collision.
1251+
The lib target `bar` in package `bar v0.1.0` has the same output filename as \
1252+
the lib target `bar` in package `bar v0.1.0 ([ROOT]/foo/bar)`.
1253+
Colliding filename is: [ROOT]/foo/target/doc/bar/index.html
1254+
The targets should have unique names.
1255+
This is a known bug where multiple crates with the same name use
1256+
the same path; see <https://github.com/rust-lang/cargo/issues/6313>.
1257+
[DOCUMENTING] bar v0.1.0
1258+
[CHECKING] bar v0.1.0
1259+
[DOCUMENTING] bar v0.1.0 [..]
1260+
[FINISHED] [..]
1261+
",
1262+
)
12471263
.run();
12481264
}
12491265

tests/testsuite/lto.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ fn complicated() {
177177
)
178178
.file("build.rs", "fn main() { dep_build::foo() }")
179179
.file(
180-
"src/main.rs",
180+
"src/bin/foo-bin.rs",
181181
"#[dep_proc_macro::foo] fn main() { dep_normal::foo() }",
182182
)
183183
.file(
@@ -206,7 +206,9 @@ fn complicated() {
206206
.with_stderr_contains(
207207
"[..]`rustc[..]--crate-name dep_proc_macro [..]-C embed-bitcode=no[..]`",
208208
)
209-
.with_stderr_contains("[..]`rustc[..]--crate-name test [..]--crate-type bin[..]-C lto[..]`")
209+
.with_stderr_contains(
210+
"[..]`rustc[..]--crate-name foo_bin [..]--crate-type bin[..]-C lto[..]`",
211+
)
210212
.with_stderr_contains(
211213
"[..]`rustc[..]--crate-name test [..]--crate-type cdylib[..]-C lto[..]`",
212214
)
@@ -753,7 +755,7 @@ fn dylib_rlib_bin() {
753755
"#,
754756
)
755757
.file("src/lib.rs", "pub fn foo() { println!(\"hi!\"); }")
756-
.file("src/main.rs", "fn main() { foo::foo(); }")
758+
.file("src/bin/ferret.rs", "fn main() { foo::foo(); }")
757759
.build();
758760

759761
let output = p.cargo("build --release -v").exec_with_output().unwrap();
@@ -763,7 +765,7 @@ fn dylib_rlib_bin() {
763765
"--crate-type dylib --crate-type rlib",
764766
Lto::ObjectAndBitcode,
765767
);
766-
verify_lto(&output, "foo", "--crate-type bin", Lto::Run(None));
768+
verify_lto(&output, "ferret", "--crate-type bin", Lto::Run(None));
767769
}
768770

769771
#[cargo_test]

0 commit comments

Comments
 (0)