Commit 0ec9af98 authored by bors's avatar bors

Auto merge of #1325 - sunfishcode:wasi-more-libc, r=alexcrichton

Add more WASI libc bindings

This picks up #1321, adding more WASI libc bindings, adding several more fixes. In particular, `cargo test --all` including libc-test now builds successfully.
parents fa186bb2 13ddc16e
......@@ -28,7 +28,7 @@ RUN mv /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 /wasmcc
# those breaking changes on `libc`'s own CI
RUN git clone https://github.com/CraneStation/wasi-sysroot && \
cd wasi-sysroot && \
git reset --hard e5f14be38362f1ab83302895a6e74b2ffd0e2302
git reset --hard 2201343c17b7149a75f543f523bea0c3243c6091
RUN make -C wasi-sysroot install -j $(nproc) WASM_CC=/wasmcc/bin/clang INSTALL_DIR=/wasi-sysroot
# This is a small wrapper script which executes the actual clang binary in
......
......@@ -1875,17 +1875,28 @@ fn test_wasi(target: &str) {
cfg.define("_GNU_SOURCE", None);
headers! { cfg:
"ctype.h",
"dirent.h",
"errno.h",
"fcntl.h",
"limits.h",
"locale.h",
"malloc.h",
"poll.h",
"stdbool.h",
"stddef.h",
"stdint.h",
"stdio.h",
"stdlib.h",
"string.h",
"sys/resource.h",
"sys/select.h",
"sys/socket.h",
"sys/stat.h",
"sys/times.h",
"sys/types.h",
"sys/uio.h",
"sys/utsname.h",
"time.h",
"unistd.h",
"wasi/core.h",
......@@ -1895,7 +1906,7 @@ fn test_wasi(target: &str) {
}
cfg.type_name(move |ty, is_struct, is_union| match ty {
"FILE" => ty.to_string(),
"FILE" | "fd_set" | "DIR" => ty.to_string(),
t if is_union => format!("union {}", t),
t if t.starts_with("__wasi") && t.ends_with("_u") => {
format!("union {}", t)
......@@ -1920,5 +1931,9 @@ fn test_wasi(target: &str) {
// import the same thing but have different function pointers
cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi"));
// d_name is declared as a flexible array in WASI libc, so it
// doesn't support sizeof.
cfg.skip_field(|s, field| s == "dirent" && field == "d_name");
cfg.generate("../src/lib.rs", "main.rs");
}
......@@ -112,7 +112,7 @@ cfg_if! {
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
mod sgx;
pub use sgx::*;
} else if #[cfg(target_env = "wasi")] {
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
mod wasi;
pub use wasi::*;
} else {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment