Skip to content

Commit

Permalink
Auto merge of rust-lang#134918 - ChrisDenton:issue-70093, r=<try>
Browse files Browse the repository at this point in the history
Windows: Enable issue 70093 link tests

`-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.

Marking as draft while I test if it actually *does* work,

try-job: i686-mingw
try-job: x86_64-mingw-1
  • Loading branch information
bors committed Dec 30, 2024
2 parents c156614 + 8ff5758 commit a8a75ad
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2710,8 +2710,6 @@ ui/limits/issue-75158-64.rs
ui/link-native-libs/issue-109144.rs
ui/link-native-libs/issue-43925.rs
ui/link-native-libs/issue-43926.rs
ui/link-native-libs/issue-70093/issue-70093-link-directives.rs
ui/link-native-libs/issue-70093/issue-70093.rs
ui/linkage-attr/auxiliary/issue-12133-dylib.rs
ui/linkage-attr/auxiliary/issue-12133-dylib2.rs
ui/linkage-attr/auxiliary/issue-12133-rlib.rs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@ run-pass
//@ compile-flags: -Zlink-directives=no
//@ ignore-windows - this will probably only work on unixish systems
//@ ignore-fuchsia - missing __libc_start_main for some reason (#84733)
//@ ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// On Windows MSVC, default-linker-libraries=yes doesn't work because
// rustc drives the linker directly instead of going through another compiler.
// Therefore rustc would need to implement default-linker-libraries itself but doesn't.
// So instead we use -Clink-arg to directly set the required msvcrt.lib as a link arg.

//@ run-pass
//@ compile-flags: -Zlink-native-libraries=no -Clink-arg=msvcrt.lib
//@ only-msvc
//@ ignore-cross-compile

#[link(name = "some-random-non-existent-library", kind = "static")]
extern "C" {}

fn main() {}

0 comments on commit a8a75ad

Please sign in to comment.