Skip to content

Commit

Permalink
Auto merge of #1342 - sunfishcode:master, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed May 15, 2019
2 parents 39ca01c + acd7ad8 commit bdd47f7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
2 changes: 0 additions & 2 deletions ci/docker/wasm32-unknown-wasi/clang.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ 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 2201343c17b7149a75f543f523bea0c3243c6091
git reset --hard eee6ee7566e26f2535eb6088c8494a112ff423b9
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
# `/wasmcc` and then is sure to pass the right `--sysroot` argument which we
# just built above.
COPY docker/wasm32-unknown-wasi/clang.sh /wasi-sysroot/bin/clang
COPY docker/wasm32-wasi/clang.sh /wasi-sysroot/bin/clang

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

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

# And finally in the last image we're going to assemble everything together.
Expand All @@ -86,8 +86,8 @@ COPY --from=wasmtime /wasmtime/target/release/wasmtime /usr/bin/
# executable with the right sysroot, and then we're sure to turn off the
# crt-static feature to ensure that the CRT that we're specifying with `clang`
# is used.
ENV CARGO_TARGET_WASM32_UNKNOWN_WASI_RUNNER=wasmtime \
CARGO_TARGET_WASM32_UNKNOWN_WASI_LINKER=/wasi-sysroot/bin/clang \
CC_wasm32_unknown_wasi=/wasi-sysroot/bin/clang \
ENV CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
CARGO_TARGET_WASM32_WASI_LINKER=/wasi-sysroot/bin/clang \
CC_wasm32_wasi=/wasi-sysroot/bin/clang \
PATH=$PATH:/rust/bin \
RUSTFLAGS=-Ctarget-feature=-crt-static
2 changes: 2 additions & 0 deletions ci/docker/wasm32-wasi/clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
exec /wasmcc/bin/clang --target=wasm32-wasi --sysroot /wasi-sysroot "$@"
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ fn test_wasi(target: &str) {
"locale.h",
"malloc.h",
"poll.h",
"sched.h",
"stdbool.h",
"stddef.h",
"stdint.h",
Expand Down
20 changes: 19 additions & 1 deletion src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ pub type c_long = i32;
pub type c_ulong = u32;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type size_t = usize;
pub type ssize_t = isize;
pub type ptrdiff_t = isize;
pub type intptr_t = isize;
pub type uintptr_t = usize;
pub type off_t = i64;
pub type pid_t = i32;
pub type int8_t = i8;
Expand Down Expand Up @@ -619,11 +624,13 @@ extern {
pub fn getenv(s: *const c_char) -> *mut c_char;
pub fn malloc(amt: size_t) -> *mut c_void;
pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
pub fn rand() -> c_int;
pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t;
pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void;
pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int;
pub fn unsetenv(k: *const c_char) -> c_int;
pub fn clearenv() -> ::c_int;
pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t;
pub static mut environ: *mut *mut c_char;
pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE;
Expand Down Expand Up @@ -724,6 +731,7 @@ extern {
pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE)
-> *mut c_char;
pub fn atoi(s: *const c_char) -> c_int;
pub fn atof(s: *const c_char) -> c_double;
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtol(
s: *const c_char,
Expand Down Expand Up @@ -822,6 +830,7 @@ extern {
pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
pub fn rewinddir(dirp: *mut ::DIR);
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;

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

pub fn fsync(fd: ::c_int) -> ::c_int;
pub fn fdatasync(fd: ::c_int) -> ::c_int;

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

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

pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
Expand Down Expand Up @@ -954,6 +965,11 @@ extern {
whence: ::c_int,
) -> ::c_int;
pub fn ftello(stream: *mut ::FILE) -> ::off_t;
pub fn posix_fallocate(
fd: ::c_int,
offset: ::off_t,
len: ::off_t,
) -> ::c_int;

pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
pub fn getline(
Expand Down Expand Up @@ -1019,13 +1035,14 @@ extern {
base: ::locale_t,
) -> ::locale_t;
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
pub fn sched_yield() -> ::c_int;

pub fn __wasilibc_register_preopened_fd(
fd: c_int,
path: *const c_char,
) -> c_int;
pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int;
pub fn __wasilibc_rmfileat(fd: c_int, path: *const c_char) -> c_int;
pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int;
pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int;
pub fn __wasilibc_init_preopen();
pub fn __wasilibc_find_relpath(
Expand All @@ -1034,6 +1051,7 @@ extern {
rights_inheriting: __wasi_rights_t,
relative_path: *mut *const c_char,
) -> c_int;
pub fn __wasilibc_tell(fd: c_int) -> ::off_t;

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

0 comments on commit bdd47f7

Please sign in to comment.