From 7d1d57521a6b69265719eaadadc78a4da3c37450 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Thu, 26 Nov 2015 23:27:45 +0000 Subject: [PATCH 1/2] Add emscripten support --- src/lib.rs | 3 +++ src/unix/mod.rs | 7 ++++++- src/unix/notbsd/linux/mod.rs | 3 ++- src/unix/notbsd/mod.rs | 5 +++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3f3133fafc731..e408ea5e8cd46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,6 +72,9 @@ #![cfg_attr(target_os = "dragonfly", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly" ))] +#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc( + html_root_url = "https://doc.rust-lang.org/libc/asmjs-unknown-emscripten" +))] // Attributes needed when building as part of the standard library #![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute))] diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6fc21538cca37..4060b4eebfb70 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -124,6 +124,9 @@ cfg_if! { } else if #[cfg(target_env = "musl")] { #[link(name = "c", kind = "static")] extern {} + } else if #[cfg(target_os = "emscripten")] { + #[link(name = "c")] + extern {} } else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", @@ -664,7 +667,9 @@ extern { } cfg_if! { - if #[cfg(any(target_os = "linux", target_os = "android"))] { + if #[cfg(any(target_os = "linux", + target_os = "android", + target_os = "emscripten"))] { mod notbsd; pub use self::notbsd::*; } else if #[cfg(any(target_os = "macos", diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 355e2d2ab2bec..512d5adc3879a 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -511,7 +511,8 @@ extern { } cfg_if! { - if #[cfg(target_env = "musl")] { + if #[cfg(any(target_env = "musl", + target_os = "emscripten"))] { mod musl; pub use self::musl::*; } else if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] { diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 1d132b2747ae1..5d18853c007d1 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -50,7 +50,7 @@ s! { pub ai_protocol: ::c_int, pub ai_addrlen: socklen_t, - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "emscripten"))] pub ai_addr: *mut ::sockaddr, pub ai_canonname: *mut c_char, @@ -610,7 +610,8 @@ extern { } cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(any(target_os = "linux", + target_os = "emscripten"))] { mod linux; pub use self::linux::*; } else if #[cfg(target_os = "android")] { From 9d014e9d4039bf0876ab347f76e4701ac30bdd87 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 21 Dec 2015 23:33:54 +0000 Subject: [PATCH 2/2] Remove emscripten docs --- src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e408ea5e8cd46..3f3133fafc731 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,9 +72,6 @@ #![cfg_attr(target_os = "dragonfly", doc( html_root_url = "https://doc.rust-lang.org/libc/x86_64-unknown-dragonfly" ))] -#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc( - html_root_url = "https://doc.rust-lang.org/libc/asmjs-unknown-emscripten" -))] // Attributes needed when building as part of the standard library #![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute))]