Skip to content

Commit bdd47f7

Browse files
committed
Auto merge of #1342 - sunfishcode:master, r=alexcrichton
Update to the latest wasi-sysroot. - Rename `wasm32-unknown-wasi` to `wasm32-wasi`. - `__wasilibc_rmfileat` was renamed to `__wasilibc_unlinkat` - Add bindings for a few more functions and typedefs.
2 parents 39ca01c + acd7ad8 commit bdd47f7

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

ci/docker/wasm32-unknown-wasi/clang.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

ci/docker/wasm32-unknown-wasi/Dockerfile renamed to ci/docker/wasm32-wasi/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ RUN mv /clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04 /wasmcc
2828
# those breaking changes on `libc`'s own CI
2929
RUN git clone https://github.com/CraneStation/wasi-sysroot && \
3030
cd wasi-sysroot && \
31-
git reset --hard 2201343c17b7149a75f543f523bea0c3243c6091
31+
git reset --hard eee6ee7566e26f2535eb6088c8494a112ff423b9
3232
RUN make -C wasi-sysroot install -j $(nproc) WASM_CC=/wasmcc/bin/clang INSTALL_DIR=/wasi-sysroot
3333

3434
# This is a small wrapper script which executes the actual clang binary in
3535
# `/wasmcc` and then is sure to pass the right `--sysroot` argument which we
3636
# just built above.
37-
COPY docker/wasm32-unknown-wasi/clang.sh /wasi-sysroot/bin/clang
37+
COPY docker/wasm32-wasi/clang.sh /wasi-sysroot/bin/clang
3838

3939
# In the second container we're going to build the `wasmtime` binary which is
4040
# used to execute wasi executables. This is a standard Rust project so we're
@@ -58,9 +58,9 @@ RUN curl -sSf https://sh.rustup.rs | sh -s -- -y
5858
ENV PATH=/root/.cargo/bin:$PATH
5959

6060
RUN apt-get install -y --no-install-recommends python
61-
RUN git clone https://github.com/CraneStation/wasmtime wasmtime && \
61+
RUN git clone --recursive https://github.com/CraneStation/wasmtime wasmtime && \
6262
cd wasmtime && \
63-
git reset --hard a1c123c3dd8f9766990efe0f1734a646f61ba8a0
63+
git reset --hard 67edb00f29b62864b00179fe4bfa99bc29973285
6464
RUN cargo build --release --manifest-path wasmtime/Cargo.toml
6565

6666
# And finally in the last image we're going to assemble everything together.
@@ -86,8 +86,8 @@ COPY --from=wasmtime /wasmtime/target/release/wasmtime /usr/bin/
8686
# executable with the right sysroot, and then we're sure to turn off the
8787
# crt-static feature to ensure that the CRT that we're specifying with `clang`
8888
# is used.
89-
ENV CARGO_TARGET_WASM32_UNKNOWN_WASI_RUNNER=wasmtime \
90-
CARGO_TARGET_WASM32_UNKNOWN_WASI_LINKER=/wasi-sysroot/bin/clang \
91-
CC_wasm32_unknown_wasi=/wasi-sysroot/bin/clang \
89+
ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
90+
CARGO_TARGET_WASM32_WASI_LINKER=/wasi-sysroot/bin/clang \
91+
CC_wasm32_wasi=/wasi-sysroot/bin/clang \
9292
PATH=$PATH:/rust/bin \
9393
RUSTFLAGS=-Ctarget-feature=-crt-static

ci/docker/wasm32-wasi/clang.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
exec /wasmcc/bin/clang --target=wasm32-wasi --sysroot /wasi-sysroot "$@"

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ fn test_wasi(target: &str) {
18831883
"locale.h",
18841884
"malloc.h",
18851885
"poll.h",
1886+
"sched.h",
18861887
"stdbool.h",
18871888
"stddef.h",
18881889
"stdint.h",

src/wasi.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ pub type c_long = i32;
1010
pub type c_ulong = u32;
1111
pub type c_longlong = i64;
1212
pub type c_ulonglong = u64;
13+
pub type intmax_t = i64;
14+
pub type uintmax_t = u64;
1315
pub type size_t = usize;
1416
pub type ssize_t = isize;
17+
pub type ptrdiff_t = isize;
18+
pub type intptr_t = isize;
19+
pub type uintptr_t = usize;
1520
pub type off_t = i64;
1621
pub type pid_t = i32;
1722
pub type int8_t = i8;
@@ -619,11 +624,13 @@ extern {
619624
pub fn getenv(s: *const c_char) -> *mut c_char;
620625
pub fn malloc(amt: size_t) -> *mut c_void;
621626
pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
627+
pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
622628
pub fn rand() -> c_int;
623629
pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t;
624630
pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void;
625631
pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int;
626632
pub fn unsetenv(k: *const c_char) -> c_int;
633+
pub fn clearenv() -> ::c_int;
627634
pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t;
628635
pub static mut environ: *mut *mut c_char;
629636
pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE;
@@ -724,6 +731,7 @@ extern {
724731
pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
725732
-> *mut c_char;
726733
pub fn atoi(s: *const c_char) -> c_int;
734+
pub fn atof(s: *const c_char) -> c_double;
727735
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
728736
pub fn strtol(
729737
s: *const c_char,
@@ -822,6 +830,7 @@ extern {
822830
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
823831
pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
824832
pub fn rewinddir(dirp: *mut ::DIR);
833+
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
825834

826835
pub fn openat(
827836
dirfd: ::c_int,
@@ -902,9 +911,11 @@ extern {
902911
pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
903912

904913
pub fn fsync(fd: ::c_int) -> ::c_int;
914+
pub fn fdatasync(fd: ::c_int) -> ::c_int;
905915

906916
pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
907917

918+
pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
908919
pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
909920

910921
pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
@@ -954,6 +965,11 @@ extern {
954965
whence: ::c_int,
955966
) -> ::c_int;
956967
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
968+
pub fn posix_fallocate(
969+
fd: ::c_int,
970+
offset: ::off_t,
971+
len: ::off_t,
972+
) -> ::c_int;
957973

958974
pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
959975
pub fn getline(
@@ -1019,13 +1035,14 @@ extern {
10191035
base: ::locale_t,
10201036
) -> ::locale_t;
10211037
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
1038+
pub fn sched_yield() -> ::c_int;
10221039

10231040
pub fn __wasilibc_register_preopened_fd(
10241041
fd: c_int,
10251042
path: *const c_char,
10261043
) -> c_int;
10271044
pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int;
1028-
pub fn __wasilibc_rmfileat(fd: c_int, path: *const c_char) -> c_int;
1045+
pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int;
10291046
pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int;
10301047
pub fn __wasilibc_init_preopen();
10311048
pub fn __wasilibc_find_relpath(
@@ -1034,6 +1051,7 @@ extern {
10341051
rights_inheriting: __wasi_rights_t,
10351052
relative_path: *mut *const c_char,
10361053
) -> c_int;
1054+
pub fn __wasilibc_tell(fd: c_int) -> ::off_t;
10371055

10381056
pub fn arc4random() -> u32;
10391057
pub fn arc4random_buf(a: *mut c_void, b: size_t);

0 commit comments

Comments
 (0)