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

Rollup of 7 pull requests #59678

Closed
wants to merge 18 commits into from
Closed

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 2, 2019

  1. Never return uninhabited values at all

    Functions with uninhabited return values are already marked `noreturn`,
    but we were still generating return instructions for this. When running
    with `C passes=lint`, LLVM prints:
    
        Unusual: Return statement in function with noreturn attribute
    
    The LLVM manual makes a stronger statement about `noreturn` though:
    
    > This produces undefined behavior at runtime if the function ever does
    dynamically return.
    
    We now mark such return values with a new `IgnoreMode::Uninhabited`, and
    emit an `abort` anywhere that would have returned.
    cuviper committed Apr 2, 2019
    Configuration menu
    Copy the full SHA
    fb575c0 View commit details
    Browse the repository at this point in the history
  2. std: Upgrade compiler_builtins to fix wasi linkage

    Turns out we needed to exclude a number of math functions on the
    `wasm32-unknown-wasi` target, and this was fixed in 0.1.9 of
    compiler-builtins and this is pulling in the fix to libstd's own build.
    alexcrichton committed Apr 2, 2019
    Configuration menu
    Copy the full SHA
    7eb2efd View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2019

  1. Configuration menu
    Copy the full SHA
    1cfed0d View commit details
    Browse the repository at this point in the history
  2. Updated the documentation of core::hints::spin_loop and core::sync::s…

    …pin_loop_hint
    Christian committed Apr 3, 2019
    Configuration menu
    Copy the full SHA
    ab3b657 View commit details
    Browse the repository at this point in the history
  3. Updated the reference in core::hint::spin_loop to the correct relativ…

    …e path.
    Christian committed Apr 3, 2019
    Configuration menu
    Copy the full SHA
    becee90 View commit details
    Browse the repository at this point in the history
  4. Updated the environment description in rustc.

    Christian committed Apr 3, 2019
    Configuration menu
    Copy the full SHA
    7e37b46 View commit details
    Browse the repository at this point in the history
  5. 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
  6. Revert rust-lld place changes.

    o01eg committed Apr 3, 2019
    Configuration menu
    Copy the full SHA
    5b292ec View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#59619 - alexcrichton:wasi-fs, r=fitzgen

    wasi: Implement more of the standard library
    
    This commit fills out more of the `wasm32-unknown-wasi` target's standard library, notably the `std::fs` module and all of its internals. A few tweaks were made along the way to non-`fs` modules, but the last commit contains the bulk of the work which is to wire up all APIs to their equivalent on WASI targets instead of unconditionally returning "unsupported". After this some basic filesystem operations and such should all be working in WASI!
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    9274fba View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#59639 - cuviper:ignore-uninhabited, r=sanxiyn

    Never return uninhabited values at all
    
    Functions with uninhabited return values are already marked `noreturn`,
    but we were still generating return instructions for this. When running
    with `C passes=lint`, LLVM prints:
    
        Unusual: Return statement in function with noreturn attribute
    
    The LLVM manual makes a stronger statement about `noreturn` though:
    
    > This produces undefined behavior at runtime if the function ever does
    dynamically return.
    
    We now mark such return values with a new `IgnoreMode::Uninhabited`, and
    emit an `abort` anywhere that would have returned.
    
    Fixes rust-lang#48227
    cc rust-lang#7463 rust-lang#48229
    
    r? @eddyb
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    6c8d8fe View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#59643 - alexcrichton:wasi-symbols, r=sanxiyn

    std: Upgrade `compiler_builtins` to fix wasi linkage
    
    Turns out we needed to exclude a number of math functions on the
    `wasm32-unknown-wasi` target, and this was fixed in 0.1.9 of
    compiler-builtins and this is pulling in the fix to libstd's own build.
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    0ea4e7b View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#59663 - matklad:borrow, r=dtolnay

    Be more direct about borrow contract
    
    I always was confused by the difference between Borrow and AsRef, despite the fact that I've read all available docs at least a dozen of times.
    
    I finally grokked the difference between the two when I realized the Borrow invariant:
    
    > If you implement Borrow, you **must** make sure that Eq, Ord and Hash implementations are equivalent for borrowed and owned data
    
    My problem was that this invariant is not stated explicitly in documentation, and instead some  vague and philosophical notions are used.
    
    So I suggest to mention the requirements of `Borrow` very explicitly: instead of "use Borrow when X and use AsRef when Y", let's phrase this as `Borrow` differs from `AsRef` in `W`, so that's why `Borrow` is for `X` and `AsRef` is for `Y`.
    
    Note that this change could be seen as tightening contract of the Borrow. Let's say Alice has written the following code:
    
    ```rust
    #[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
    struct Person {
        first_name: String,
        last_name: String,
    }
    
    impl Borrow<str> for Person {
          fn borrow(&self) -> &str { self.first_name.as_str() }
    }
    ```
    
    Now Bob uses this `Person` struct, puts it into `HashMap` and tries to look it up using `&str` for the first name. Bob's code naturally fails.
    
    The question is, who is to blame: Alice, who has written the impl, or Bob, who uses the HashMap. If I read the current docs literally, I would say that `Bob` is to blame: `Eq` and `Hash` bounds appear on HashMap, so it is the HashMap which requires that they are consistent. By using a type for which the `Borrow` impl does not yield well-behaved `Eq`, Bob is violating contract of HashMap.
    
    If, as this PR proposes, we unconditionally require that Eq & friends for borrow should be valid, then the blame shifts to Alice, which I think is more reasonable.
    
    closes rust-lang#44868
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    2b192ae View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#59664 - DevQps:improve-yield-spinlock-docs,…

    … r=alexcrichton
    
    Updated the documentation of spin_loop and spin_loop_hint
    
    # Description
    
    - Updated the description of `core::hints::spin_loop`
    - Updated the description of `core::async::spin_loop_hint`
    
    Both documentation is rewritten to better reflect when one should prefer using a busy-wait spin-loop (and the `spin_loop` and `spin_loop_hint` functions) over `yield_now`. It also dives a little bit deeper on what the function actually does.
    
    closes rust-lang#55418
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    c33f21a View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#59666 - DevQps:update-rustc-environment-des…

    …criptions, r=GuillaumeGomez
    
    Updated the environment description in rustc.
    
    # Description
    
    - Updated the "environment" description in the `rustc` man pages
    
    The old wording suggested that all the mentioned flags influenced the output of the compiler,
    where this was not the case.
    
    closes rust-lang#59504
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    ee4c083 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#59672 - o01eg:fix-59661, r=oli-obk

    Revert rust-lld place changes
    
    Fixes rust-lang#59661.
    
    Instead of rust-lang#59668 it reverts only failed part.
    Centril authored Apr 3, 2019
    Configuration menu
    Copy the full SHA
    4688691 View commit details
    Browse the repository at this point in the history