Skip to content

Commit e167760

Browse files
committed
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.
2 parents fa186bb + ef7ae73 commit e167760

File tree

3 files changed

+599
-8
lines changed

3 files changed

+599
-8
lines changed

Diff for: libc-test/build.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -1875,17 +1875,28 @@ fn test_wasi(target: &str) {
18751875
cfg.define("_GNU_SOURCE", None);
18761876

18771877
headers! { cfg:
1878+
"ctype.h",
1879+
"dirent.h",
18781880
"errno.h",
18791881
"fcntl.h",
18801882
"limits.h",
18811883
"locale.h",
18821884
"malloc.h",
1885+
"poll.h",
1886+
"stdbool.h",
18831887
"stddef.h",
18841888
"stdint.h",
18851889
"stdio.h",
18861890
"stdlib.h",
1891+
"string.h",
1892+
"sys/resource.h",
1893+
"sys/select.h",
1894+
"sys/socket.h",
18871895
"sys/stat.h",
1896+
"sys/times.h",
18881897
"sys/types.h",
1898+
"sys/uio.h",
1899+
"sys/utsname.h",
18891900
"time.h",
18901901
"unistd.h",
18911902
"wasi/core.h",
@@ -1895,7 +1906,7 @@ fn test_wasi(target: &str) {
18951906
}
18961907

18971908
cfg.type_name(move |ty, is_struct, is_union| match ty {
1898-
"FILE" => ty.to_string(),
1909+
"FILE" | "fd_set" | "DIR" => ty.to_string(),
18991910
t if is_union => format!("union {}", t),
19001911
t if t.starts_with("__wasi") && t.ends_with("_u") => {
19011912
format!("union {}", t)
@@ -1920,5 +1931,9 @@ fn test_wasi(target: &str) {
19201931
// import the same thing but have different function pointers
19211932
cfg.skip_fn_ptrcheck(|f| f.starts_with("__wasi"));
19221933

1934+
// d_name is declared as a flexible array in WASI libc, so it
1935+
// doesn't support sizeof.
1936+
cfg.skip_field(|s, field| s == "dirent" && field == "d_name");
1937+
19231938
cfg.generate("../src/lib.rs", "main.rs");
19241939
}

Diff for: src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ cfg_if! {
112112
} else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] {
113113
mod sgx;
114114
pub use sgx::*;
115-
} else if #[cfg(target_env = "wasi")] {
115+
} else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] {
116116
mod wasi;
117117
pub use wasi::*;
118118
} else {

0 commit comments

Comments
 (0)