@@ -8,13 +8,8 @@ |
|
|
8 |
8 |
// Reason: the compiled binary is executed. |
9 |
9 |
//@ ignore-wasm |
10 |
10 |
// Reason: WASM does not support dynamic libraries |
11 |
|
-//@ ignore-msvc |
12 |
|
-//FIXME(Oneirical): Getting this to work on MSVC requires passing libcmt.lib to CC, |
13 |
|
-// which is not trivial to do. |
14 |
|
-// Tracking issue: https://github.com/rust-lang/rust/issues/128602 |
15 |
|
-// Discussion: https://github.com/rust-lang/rust/pull/128407#discussion\_r1702439172 |
16 |
11 |
|
17 |
|
-use run_make_support::{cc, regex, run, rustc}; |
|
12 |
+use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name}; |
18 |
13 |
|
19 |
14 |
fn main() { |
20 |
15 |
rustc().arg("-Cprefer-dynamic").input("bar.rs").run(); |
@@ -29,9 +24,13 @@ fn main() { |
|
|
29 |
24 |
let re = regex::Regex::new(r#"note: native-static-libs:\s*(.+)"#).unwrap(); |
30 |
25 |
let libs = re.find(&libs).unwrap().as_str().trim(); |
31 |
26 |
// remove the note |
32 |
|
-let (_, library_search_paths) = libs.split_once("note: native-static-libs: ").unwrap(); |
|
27 |
+let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap(); |
33 |
28 |
// divide the command-line arguments in a vec |
34 |
|
-let library_search_paths = library_search_paths.split(' ').collect::<Vec<&str>>(); |
35 |
|
-cc().input("foo.c").arg("-lfoo").args(library_search_paths).out_exe("foo").run(); |
|
29 |
+let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>(); |
|
30 |
+if is_msvc() { |
|
31 |
+// For MSVC pass the arguments on to the linker. |
|
32 |
+ native_link_args.insert(0, "-link"); |
|
33 |
+} |
|
34 |
+cc().input("foo.c").input(static_lib_name("foo")).args(native_link_args).out_exe("foo").run(); |
36 |
35 |
run("foo"); |
37 |
36 |
} |