forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#134918 - ChrisDenton:issue-70093, r=<try>
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
Showing
4 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...ssue-70093/issue-70093-link-directives.rs → ...ative-libs/issue-70093/link-directives.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/ui/link-native-libs/issue-70093/link-native-libraries-msvc.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
File renamed without changes.