Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasi: Implement more of the standard library #59619

Merged
merged 4 commits into from
Apr 4, 2019

Commits on Apr 1, 2019

  1. wasi: Load arguments via syscalls

    This commit switches the wasi target to loading CLI arguments via the
    syscalls provided by wasi rather than through the argc/argv passed to
    the main function. While serving the same purpose it's hoped that using
    syscalls will make us a bit more portable (less reliance from libstd on
    an external C library) as well as avoiding the need for a lock!
    alexcrichton committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    382f9a7 View commit details
    Browse the repository at this point in the history
  2. wasi: Use raw syscalls for stdio

    I've since learned that the mapping between libc fds and wasi fds are
    expected to be one-to-one, so we can use the raw syscalls for writing to
    stdout/stderr and reading from stdin! This should help ensure that we
    don't depend on a C library too unnecessarily.
    alexcrichton committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    60f6cbd View commit details
    Browse the repository at this point in the history
  3. wasi: Implement error_string to get readable errors

    This routes the `error_string` API to `strerror` in libc which should
    have more human readable descriptions.
    alexcrichton committed Apr 1, 2019
    Configuration menu
    Copy the full SHA
    32a7684 View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2019

  1. wasi: Fill out std::fs module for WASI

    This commit fills out the `std::fs` module and implementation for WASI.
    Not all APIs are implemented, such as permissions-related ones and
    `canonicalize`, but all others APIs have been implemented and very
    lightly tested so far. We'll eventually want to run a more exhaustive
    test suite!
    
    For now the highlights of this commit are:
    
    * The `std::fs::File` type is now backed by `WasiFd`, a raw WASI file
      descriptor.
    * All APIs in `std::fs` (except permissions/canonicalize) have
      implementations for the WASI target.
    * A suite of unstable extension traits were added to
      `std::os::wasi::fs`. These traits expose the raw filesystem
      functionality of WASI, namely `*at` syscalls (opening a file relative
      to an already opened one, for example). Additionally metadata only
      available on wasi is exposed through these traits.
    
    Perhaps one of the most notable parts is the implementation of
    path-taking APIs. WASI actually has no fundamental API that just takes a
    path, but rather everything is relative to a previously opened file
    descriptor. To allow existing APIs to work (that only take a path) WASI
    has a few syscalls to learn about "pre opened" file descriptors by the
    runtime. We use these to build a map of existing directory names to file
    descriptors, and then when using a path we try to anchor it at an
    already-opened file.
    
    This support is very rudimentary though and is intended to be shared
    with C since it's likely to be so tricky. For now though the C library
    doesn't expose quite an API for us to use, so we implement it for now
    and will swap it out as soon as one is available.
    alexcrichton committed Apr 3, 2019
    Configuration menu
    Copy the full SHA
    61b487c View commit details
    Browse the repository at this point in the history