-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #129257 - ChrisDenton:rename-null-descriptor, r=<try>
Allow rust staticlib to work with MSVC's /WHOLEARCHIVE This renames the `__NULL_IMPORT_DESCRIPTOR` to prevent conflicts. try-job: x86_64-msvc try-job: i686-msvc r? ghost
- Loading branch information
Showing
8 changed files
with
75 additions
and
6 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
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
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
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
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 @@ | ||
// This page is intentionally left blank |
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,4 @@ | ||
LIBRARY dll | ||
EXPORTS | ||
hello | ||
number |
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,41 @@ | ||
//@ only-msvc | ||
// Reason: this is testing the MSVC linker | ||
|
||
// This is a regression test for #129020 | ||
// It ensures we can link a rust staticlib into DLL using the MSVC linker | ||
|
||
use std::path::Path; | ||
|
||
use run_make_support::{cc, env_var, extra_c_flags, rustc}; | ||
|
||
fn main() { | ||
// FIXME: Make this test either work with or ignore LLVM. | ||
if false { | ||
return; | ||
} | ||
// Build the staticlib | ||
rustc().crate_type("staticlib").input("static.rs").output("static.lib").run(); | ||
// Create an empty obj file (using the C compiler) | ||
// Then use it to link in the staticlib using `/WHOLEARCHIVE` and produce a DLL. | ||
// We test for `cl.exe` to ensure we're using MSVC's tools and not the LLVM equivalents. | ||
|
||
if env_var("CC").ends_with("cl.exe") { | ||
cc().input("c.c") | ||
.args([ | ||
"-MT", | ||
"-link", | ||
"-WHOLEARCHIVE:./static.lib", | ||
"-dll", | ||
"-def:dll.def", | ||
"-out:dll.dll", | ||
]) | ||
.args(extra_c_flags()) | ||
.run(); | ||
} | ||
|
||
// As a sanity check, make sure it works without /WHOLEARCHIVE | ||
cc().input("c.c") | ||
.args(["-MT", "-link", "./static.lib", "-dll", "-def:dll.def", "-out:dll2.dll"]) | ||
.args(extra_c_flags()) | ||
.run(); | ||
} |
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,9 @@ | ||
#[no_mangle] | ||
pub extern "C" fn hello() { | ||
println!("Hello world!"); | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn number() -> u32 { | ||
42 | ||
} |