diff --git a/src/dox.rs b/src/dox.rs
index 10e39348f8165bea0d72b4c1b3dba2faad126685..3a608c8cb99bb86ca0c81a5c015fdeb9bf03e049 100644
--- a/src/dox.rs
+++ b/src/dox.rs
@@ -2,10 +2,10 @@ pub use self::imp::*;
 
 #[cfg(not(dox))]
 mod imp {
-    pub use std::option::Option;
-    pub use std::clone::Clone;
-    pub use std::marker::Copy;
-    pub use std::mem;
+    pub use core::option::Option;
+    pub use core::clone::Clone;
+    pub use core::marker::Copy;
+    pub use core::mem;
 }
 
 #[cfg(dox)]
diff --git a/src/lib.rs b/src/lib.rs
index ff53835fd1e3639d8935b106406242bda157b432..db6e46b205cb05844a2d2f6cc91ae73148b4d343 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,6 +11,8 @@
 //! Crate docs
 
 #![allow(bad_style, raw_pointer_derive, overflowing_literals, improper_ctypes)]
+#![crate_type = "rlib"]
+#![crate_name = "libc"]
 #![cfg_attr(dox, feature(no_core, lang_items))]
 #![cfg_attr(dox, no_core)]
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
@@ -56,6 +58,17 @@
     html_root_url = "https://doc.rust-lang.org/libc/arm-linux-androideabi"
 ))]
 
+// Attributes needed when building as part of the standard library
+#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api))]
+#![cfg_attr(stdbuild, no_std)]
+#![cfg_attr(stdbuild, staged_api)]
+#![cfg_attr(stdbuild, unstable(feature = "libc",
+                               reason = "use `libc` from crates.io",
+                               issue = "27783"))]
+
+#[cfg(all(not(stdbuild), not(dox)))]
+extern crate std as core;
+
 #[macro_use] mod macros;
 mod dox;