Skip to content

Commit 702602a

Browse files
authored
Unrolled build for rust-lang#134918
Rollup merge of rust-lang#134918 - ChrisDenton:issue-70093, r=jieyouxu Windows: Enable issue 70093 link tests Tracking issue for `-Z link-native-libraries`: rust-lang#134948 Tracking issue for `-Z link-directives`: rust-lang#134947 `-Zlink-native-libraries=no` and `-Zlink-directives=no` *should* work on Windows, at least for msvc. The fly in ointment is that `default-linker-libraries` doesn't. On unixy platforms rustc calls another compiler which in turn calls the linker along with the default libraries. On MSVC rustc calls the linker directly therefore it would need to be the one to implement `default-linker-libraries`. Except it doesn't so we workaround that in the test by using `-C link-arg` to talk to the linker.
2 parents 7a0cde9 + dc1f2be commit 702602a

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

Diff for: src/tools/tidy/src/issues.txt

-2
Original file line numberDiff line numberDiff line change
@@ -2710,8 +2710,6 @@ ui/limits/issue-75158-64.rs
27102710
ui/link-native-libs/issue-109144.rs
27112711
ui/link-native-libs/issue-43925.rs
27122712
ui/link-native-libs/issue-43926.rs
2713-
ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
2714-
ui/link-native-libs/issue-70093/issue-70093.rs
27152713
ui/linkage-attr/auxiliary/issue-12133-dylib.rs
27162714
ui/linkage-attr/auxiliary/issue-12133-dylib2.rs
27172715
ui/linkage-attr/auxiliary/issue-12133-rlib.rs

Diff for: tests/ui/link-native-libs/issue-70093/issue-70093-link-directives.rs

-10
This file was deleted.

Diff for: tests/ui/link-native-libs/issue-70093/issue-70093.rs

-10
This file was deleted.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Ensure that `#[link]` attributes are entirely ignore when using `-Zlink-directives=no`.
2+
3+
//@ run-pass
4+
//@ compile-flags: -Zlink-directives=no
5+
//@ ignore-fuchsia - missing __libc_start_main for some reason (#84733)
6+
//@ ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling
7+
8+
// Usually these `#[link]` attribute would cause `libsome-random-non-existent-library`
9+
// to be passed to the linker, causing it to fail because the file doesn't exist.
10+
// However, with -Zlink-directives=no, the `#[link]` is ignored.
11+
#[link(name = "some-random-non-existent-library", kind = "static")]
12+
extern "C" {}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Ensure that rust does not pass native libraries to the linker when
2+
// `-Zlink-native-libraries=no` is used.
3+
4+
//@ run-pass
5+
//@ compile-flags: -Zlink-native-libraries=no -Cdefault-linker-libraries=yes
6+
//@ ignore-fuchsia - missing __libc_start_main for some reason (#84733)
7+
//@ ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling
8+
9+
//@ revisions: other
10+
//@[other] ignore-msvc
11+
12+
//@ revisions: msvc
13+
// On Windows MSVC, default-linker-libraries=yes doesn't work because
14+
// rustc drives the linker directly instead of going through another compiler.
15+
// Therefore rustc would need to implement default-linker-libraries itself but doesn't.
16+
// So instead we use -Clink-arg to directly set the required msvcrt.lib as a link arg.
17+
//@[msvc] compile-flags: -Clink-arg=msvcrt.lib
18+
//@[msvc] only-msvc
19+
20+
// Usually these `#[link]` attribute would cause `libsome-random-non-existent-library`
21+
// to be passed to the linker, causing it to fail because the file doesn't exist.
22+
// However, -Zlink-native-libraries=no disables that.
23+
#[link(name = "some-random-non-existent-library", kind = "static")]
24+
extern "C" {}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)