about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-01-31 12:46:17 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-01-31 12:46:17 +0100
commit9384af41986da8c1697acde643b3f899d7becaf2 (patch)
tree99e0f2ed69ea97d9726a0cf58325f4cac0719608
parent9c943bf5de795c784aa33e29cb25fa51bc76c833 (diff)
downloadrust-9384af41986da8c1697acde643b3f899d7becaf2.tar.gz
rust-9384af41986da8c1697acde643b3f899d7becaf2.zip
Link examples to the correct libc when targeting Windows
-rw-r--r--example/alloc_example.rs3
-rw-r--r--example/mini_core.rs4
-rw-r--r--example/mod_bench.rs3
3 files changed, 6 insertions, 4 deletions
diff --git a/example/alloc_example.rs b/example/alloc_example.rs
index dc2ad4c676e..f59600ebb33 100644
--- a/example/alloc_example.rs
+++ b/example/alloc_example.rs
@@ -11,7 +11,8 @@ use alloc_system::System;
 #[global_allocator]
 static ALLOC: System = System;
 
-#[link(name = "c")]
+#[cfg_attr(unix, link(name = "c"))]
+#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
 extern "C" {
     fn puts(s: *const u8) -> i32;
 }
diff --git a/example/mini_core.rs b/example/mini_core.rs
index 10cba992056..002ec7e2e3d 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -532,8 +532,8 @@ pub mod intrinsics {
 }
 
 pub mod libc {
-    #[cfg_attr(not(windows), link(name = "c"))]
-    #[cfg_attr(windows, link(name = "msvcrt"))]
+    #[cfg_attr(unix, link(name = "c"))]
+    #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
     extern "C" {
         pub fn puts(s: *const i8) -> i32;
         pub fn printf(format: *const i8, ...) -> i32;
diff --git a/example/mod_bench.rs b/example/mod_bench.rs
index bc652213623..152041aa9ed 100644
--- a/example/mod_bench.rs
+++ b/example/mod_bench.rs
@@ -1,7 +1,8 @@
 #![feature(start, box_syntax, core_intrinsics, lang_items)]
 #![no_std]
 
-#[link(name = "c")]
+#[cfg_attr(unix, link(name = "c"))]
+#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
 extern {}
 
 #[panic_handler]