Move linkage to specific modules
diff --git a/src/linkage.rs b/src/linkage.rs
deleted file mode 100644
index 721325c..0000000
--- a/src/linkage.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-
-// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them
-// in when creating a test crate.
-#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))]
-#[link(name = "c")]
-#[link(name = "m")]
-extern {}
-
-// When compiling rust with musl, statically include libc.a in liblibc.rlib.
-// A cargo build of the libc crate will therefore automatically pick up the
-// libc.a symbols because liblibc is transitively linked to by the stdlib.
-#[cfg(all(target_env = "musl", not(feature = "cargo-build"), not(test)))]
-#[link(name = "c", kind = "static")]
-extern {}
-
-#[cfg(all(windows, target_env = "msvc"))]
-#[link(name = "kernel32")]
-#[link(name = "shell32")]
-#[link(name = "msvcrt")]
-extern {}
-
-// libnacl provides functions that require a trip through the IRT to work.
-// ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip
-// to the kernel.
-#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))]
-#[link(name = "nacl", kind = "static")]
-extern {}
-
-// pnaclmm provides a number of functions that the toolchain's Clang emits calls
-// to when codegening atomic ops. All the functions within wrap various atomic
-// operations.
-// Yes, it could be linked by rustc explicitly, however by linking it here
-// instead we save a bit of time where bins are involved (by not running the
-// optimizations on the whole pnaclmm foreach binary built).
-#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))]
-#[link(name = "pnaclmm", kind = "static")]
-extern {}
-
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 820b59d..14c427f 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -63,6 +63,20 @@
     }
 }
 
+cfg_if! {
+    if #[cfg(feature = "default")] {
+        // cargo build, don't pull in anything extra as the libstd libc dep
+        // already pulls in all libs.
+    } else if #[cfg(target_env = "musl")] {
+        #[link(name = "c", kind = "static")]
+        extern {}
+    } else {
+        #[link(name = "c")]
+        #[link(name = "m")]
+        extern {}
+    }
+}
+
 extern {
     pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int;
     #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
diff --git a/src/windows.rs b/src/windows.rs
index 159a311..cade64d 100644
--- a/src/windows.rs
+++ b/src/windows.rs
@@ -667,6 +667,12 @@
 
 pub const FIONBIO: c_long = -0x7FFB9982;
 
+#[cfg(target_env = "msvc")]
+#[link(name = "kernel32")]
+#[link(name = "shell32")]
+#[link(name = "msvcrt")]
+extern {}
+
 extern {
     #[link_name = "_chmod"]
     pub fn chmod(path: *const c_char, mode: c_int) -> c_int;