1. 29 8月, 2020 1 次提交
  2. 24 8月, 2020 1 次提交
    • A
      Introduce expect snapshot testing library into rustc · f7be59c5
      Aleksey Kladov 提交于
      Snapshot testing is a technique for writing maintainable unit tests.
      Unlike usual `assert_eq!` tests, snapshot tests allow
      to *automatically* upgrade expected values on test failure.
      In a sense, snapshot tests are inline-version of our beloved
      UI-tests.
      
      Example:
      
      ![expect](https://user-images.githubusercontent.com/1711539/90888810-3bcc8180-e3b7-11ea-9626-d06e89e1a0bb.gif)
      
      A particular library we use, `expect_test` provides an `expect!`
      macro, which creates a sort of self-updating string literal (by using
      `file!` macro). Self-update is triggered by setting `UPDATE_EXPECT`
      environmental variable (this info is printed during the test failure).
      This library was extracted from rust-analyzer, where we use it for
      most of our tests.
      
      There are some other, more popular snapshot testing libraries:
      
      * https://github.com/mitsuhiko/insta
      * https://github.com/aaronabramov/k9
      
      The main differences of `expect` are:
      
      * first-class snapshot objects (so, tests can be written as functions,
        rather than as macros)
      * focus on inline-snapshots (but file snapshots are also supported)
      * restricted feature set (only `assert_eq` and `assert_debug_eq`)
      * no extra runtime (ie, no `cargo insta`)
      
      See https://github.com/rust-analyzer/rust-analyzer/pull/5101 for a
      an extended comparison.
      
      It is unclear if this testing style will stick with rustc in the long
      run. At the moment, rustc is mainly tested via integrated UI tests.
      But in the library-ified world, unit-tests will become somewhat more
      important (that's why use use `rustc_lexer` library-ified library as
      an example in this PR). Given that the cost of removal shouldn't be
      too high, it probably makes sense to just see if this flies!
      f7be59c5
  3. 22 8月, 2020 1 次提交
  4. 19 8月, 2020 2 次提交
  5. 18 8月, 2020 4 次提交
    • J
      Downgrade version_check 0.9.2 -> 0.9.1 · 25441fb6
      Jubilee Young 提交于
      0.9.2 is a breaking change to the #[cfg(version)] test in
      src/test/ui/feature-gates/feature-gate-config-version.*
      Let's downgrade for now.
      25441fb6
    • J
      Resolve licensing by updating tinyvec 0.3.3 -> 0.3.4 · 8f5ea808
      Jubilee Young 提交于
      Per https://github.com/rust-lang/rust/pull/75555#issuecomment-675090858
      Zlib license might be OK. "OR Apache-2.0 OR MIT" definitely is.
      unicode-normalization depends on this and rustc_parse, clippy,
      and many other things depend on unicode-normalization.
      8f5ea808
    • M
      Update dependencies · 342d9567
      Mark Rousskov 提交于
      This runs cargo update, applying the following changes:
            Adding arrayref v0.3.6
            Adding base64 v0.11.0
            Adding blake2b_simd v0.5.10
            Adding cloudabi v0.1.0
            Adding crossbeam-queue v0.2.3
            Adding instant v0.1.6
            Adding lock_api v0.4.1
            Adding maybe-uninit v2.0.0
            Adding parking_lot_core v0.7.2
            Adding parking_lot_core v0.8.0
            Adding parking_lot v0.11.0
            Adding proc-macro-error-attr v1.0.4
            Adding quick-error v2.0.0
            Adding rust-argon2 v0.7.0
            Adding signal-hook-registry v1.2.1
            Adding smallvec v0.6.13
            Adding smallvec v1.4.2
            Adding tinyvec v0.3.3
          Removing argon2rs v0.2.5
          Removing arrayvec v0.4.7
          Removing blake2-rfc v0.2.18
          Removing fuchsia-cprng v0.1.1
          Removing nodrop v0.1.12
          Removing parking_lot_core v0.7.1
          Removing rand_core v0.3.0
          Removing rand_core v0.4.0
          Removing rand_os v0.1.3
          Removing rdrand v0.4.0
          Removing scoped_threadpool v0.1.9
          Removing signal-hook v0.1.7
          Removing smallvec v0.6.10
          Removing smallvec v1.4.0
          Updating aho-corasick v0.7.10 -> v0.7.13
          Updating anyhow v1.0.31 -> v1.0.32
          Updating arc-swap v0.3.7 -> v0.4.7
          Updating bitmaps v2.0.0 -> v2.1.0
          Updating bstr v0.1.3 -> v0.2.13
          Updating byteorder v1.3.2 -> v1.3.4
          Updating bytesize v1.0.0 -> v1.0.1
          Updating bytes v0.4.11 -> v0.4.12
          Updating cargo_metadata v0.8.0 -> v0.8.2
          Updating chrono v0.4.6 -> v0.4.15
          Updating clap v2.33.0 -> v2.33.3
          Updating cmake v0.1.42 -> v0.1.44
          Updating constant_time_eq v0.1.3 -> v0.1.5
          Updating crossbeam-channel v0.4.0 -> v0.4.3
          Updating crossbeam-deque v0.7.1 -> v0.7.3
          Updating crossbeam-epoch v0.7.2 -> v0.8.2
          Updating crossbeam-utils v0.6.5 -> v0.6.6
          Updating crypto-hash v0.3.1 -> v0.3.4
          Updating ctor v0.1.13 -> v0.1.15
          Updating curl-sys v0.4.25 -> v0.4.34+curl-7.71.1
          Updating curl v0.4.25 -> v0.4.31
          Updating derive_more v0.99.2 -> v0.99.9
          Updating diff v0.1.11 -> v0.1.12
          Updating directories v2.0.1 -> v2.0.2
          Updating dirs-sys v0.3.3 -> v0.3.5
          Updating dirs v2.0.1 -> v2.0.2
          Updating either v1.5.0 -> v1.6.0
          Updating failure v0.1.5 -> v0.1.8
          Updating filetime v0.2.9 -> v0.2.12
          Updating fnv v1.0.6 -> v1.0.7
          Updating fortanix-sgx-abi v0.3.2 -> v0.3.3
          Updating fst v0.3.0 -> v0.3.5
          Updating futures v0.1.28 -> v0.1.29
          Updating git2 v0.13.5 -> v0.13.8
          Updating globset v0.4.3 -> v0.4.5
          Updating handlebars v3.0.1 -> v3.4.0
          Updating heck v0.3.0 -> v0.3.1
          Updating hex v0.4.0 -> v0.4.2
          Updating home v0.5.1 -> v0.5.3
          Updating humantime v2.0.0 -> v2.0.1
          Updating ignore v0.4.11 -> v0.4.16
          Updating itertools v0.8.0 -> v0.8.2
          Updating itoa v0.4.4 -> v0.4.6
          Updating jemalloc-sys v0.3.0 -> v0.3.2
          Updating jsonrpc-client-transports v14.0.5 -> v14.2.1
          Updating jsonrpc-core-client v14.0.5 -> v14.2.0
          Updating jsonrpc-core v14.0.5 -> v14.2.0
          Updating jsonrpc-derive v14.0.5 -> v14.2.1
          Updating jsonrpc-pubsub v14.0.6 -> v14.2.0
          Updating jsonrpc-server-utils v14.0.5 -> v14.2.0
          Updating json v0.11.13 -> v0.11.15
          Updating lazycell v1.2.1 -> v1.3.0
          Updating libgit2-sys v0.12.7+1.0.0 -> v0.12.9+1.0.1
          Updating libnghttp2-sys v0.1.2 -> v0.1.4+1.41.0
          Updating libssh2-sys v0.2.14 -> v0.2.18
          Updating libz-sys v1.0.25 -> v1.0.27
          Updating linked-hash-map v0.5.2 -> v0.5.3
          Updating log v0.4.8 -> v0.4.11
          Updating lzma-sys v0.1.14 -> v0.1.16
          Updating macro-utils v0.1.2 -> v0.1.3
          Updating maplit v1.0.1 -> v1.0.2
          Updating mdbook v0.4.0 -> v0.4.2
          Updating memoffset v0.5.1 -> v0.5.5
          Updating mio-named-pipes v0.1.6 -> v0.1.7
          Updating mio-uds v0.6.7 -> v0.6.8
          Updating mio v0.6.16 -> v0.6.22
          Updating miow v0.3.3 -> v0.3.5
          Updating net2 v0.2.33 -> v0.2.34
          Updating new_debug_unreachable v1.0.3 -> v1.0.4
          Updating num_cpus v1.10.1 -> v1.13.0
          Updating num-integer v0.1.39 -> v0.1.43
          Updating num-traits v0.2.6 -> v0.2.12
          Updating once_cell v1.1.0 -> v1.4.0
          Updating opener v0.4.0 -> v0.4.1
          Updating openssl-src v111.9.0+1.1.1g -> v111.10.2+1.1.1g
          Updating openssl-sys v0.9.54 -> v0.9.58
          Updating openssl v0.10.25 -> v0.10.30
          Updating open v1.2.1 -> v1.4.0
          Updating packed_simd v0.3.1 -> v0.3.3
          Updating pest v2.1.0 -> v2.1.3
          Updating pkg-config v0.3.17 -> v0.3.18
          Updating proc-macro2 v1.0.3 -> v1.0.19
          Updating proc-macro-crate v0.1.4 -> v0.1.5
          Updating proc-macro-error v0.2.6 -> v1.0.4
          Updating psm v0.1.10 -> v0.1.11
          Updating pulldown-cmark v0.7.1 -> v0.7.2
          Updating punycode v0.4.0 -> v0.4.1
          Updating quote v1.0.2 -> v1.0.7
          Updating rayon-core v1.6.0 -> v1.7.1
          Updating rayon v1.2.0 -> v1.3.1
          Updating redox_syscall v0.1.56 -> v0.1.57
          Updating redox_users v0.3.0 -> v0.3.4
          Updating regex-syntax v0.6.17 -> v0.6.18
          Updating regex v1.3.7 -> v1.3.9
          Updating remove_dir_all v0.5.2 -> v0.5.3
          Updating rustfix v0.5.0 -> v0.5.1
          Updating ryu v1.0.0 -> v1.0.5
          Updating same-file v1.0.4 -> v1.0.6
          Updating schannel v0.1.16 -> v0.1.19
          Updating scopeguard v1.0.0 -> v1.1.0
          Updating serde_derive v1.0.106 -> v1.0.115
          Updating serde_ignored v0.1.0 -> v0.1.2
          Updating serde_json v1.0.40 -> v1.0.57
          Updating serde_repr v0.1.5 -> v0.1.6
          Updating serde v1.0.99 -> v1.0.115
          Updating shell-escape v0.1.4 -> v0.1.5
          Updating stable_deref_trait v1.1.0 -> v1.2.0
          Updating stacker v0.1.9 -> v0.1.11
          Updating structopt-derive v0.3.1 -> v0.4.9
          Updating structopt v0.3.1 -> v0.3.16
          Updating synstructure v0.12.1 -> v0.12.4
          Updating syn v1.0.11 -> v1.0.38
          Updating tar v0.4.26 -> v0.4.29
          Updating tendril v0.4.0 -> v0.4.1
          Updating term v0.6.0 -> v0.6.1
          Updating thiserror-impl v1.0.5 -> v1.0.20
          Updating thiserror v1.0.5 -> v1.0.20
          Updating time v0.1.42 -> v0.1.43
          Updating tokio-codec v0.1.1 -> v0.1.2
          Updating tokio-current-thread v0.1.6 -> v0.1.7
          Updating tokio-executor v0.1.9 -> v0.1.10
          Updating tokio-fs v0.1.6 -> v0.1.7
          Updating tokio-io v0.1.12 -> v0.1.13
          Updating tokio-process v0.2.4 -> v0.2.5
          Updating tokio-reactor v0.1.11 -> v0.1.12
          Updating tokio-signal v0.2.7 -> v0.2.9
          Updating tokio-sync v0.1.7 -> v0.1.8
          Updating tokio-tcp v0.1.3 -> v0.1.4
          Updating tokio-threadpool v0.1.17 -> v0.1.18
          Updating tokio-timer v0.2.12 -> v0.2.13
          Updating tokio-udp v0.1.5 -> v0.1.6
          Updating tokio-uds v0.2.5 -> v0.2.7
          Updating toml v0.5.3 -> v0.5.6
          Updating tracing-attributes v0.1.9 -> v0.1.10
          Updating tracing-core v0.1.12 -> v0.1.14
          Updating tracing-subscriber v0.2.10 -> v0.2.11
          Updating tracing v0.1.18 -> v0.1.19
          Updating ucd-parse v0.1.4 -> v0.1.8
          Updating ucd-trie v0.1.1 -> v0.1.3
          Updating unicode-normalization v0.1.12 -> v0.1.13
          Updating unicode-script v0.5.1 -> v0.5.2
          Updating unicode-width v0.1.6 -> v0.1.8
          Updating unicode-xid v0.2.0 -> v0.2.1
          Updating url v2.1.0 -> v2.1.1
          Updating utf-8 v0.7.2 -> v0.7.5
          Updating vcpkg v0.2.8 -> v0.2.10
          Updating vec_map v0.8.1 -> v0.8.2
          Updating version_check v0.9.1 -> v0.9.2
          Updating walkdir v2.2.7 -> v2.3.1
          Updating winapi v0.3.8 -> v0.3.9
          Updating xz2 v0.1.5 -> v0.1.6
          Updating yaml-merge-keys v0.4.0 -> v0.4.1
          Updating yaml-rust v0.4.3 -> v0.4.4
      342d9567
    • C
  6. 15 8月, 2020 2 次提交
    • M
      Fix rustc_serialize unit tests · c4f91bb2
      Matthew Jasper 提交于
      c4f91bb2
    • M
      Rework `rustc_serialize` · cbcef3ef
      Matthew Jasper 提交于
      - Move the type parameter from `encode` and `decode` methods to
        the trait.
      - Remove `UseSpecialized(En|De)codable` traits.
      - Remove blanket impls for references.
      - Add `RefDecodable` trait to allow deserializing to arena-allocated
        references safely.
      - Remove ability to (de)serialize HIR.
      - Create proc-macros `(Ty)?(En|De)codable` to help implement these new
        traits.
      cbcef3ef
  7. 12 8月, 2020 2 次提交
  8. 11 8月, 2020 1 次提交
  9. 10 8月, 2020 1 次提交
  10. 09 8月, 2020 1 次提交
    • M
      Avoid deleting temporary files on error · 2627eedd
      Mark Rousskov 提交于
      Previously if the compiler error'd, fatally, then temporary directories which
      should be preserved by -Csave-temps would be deleted due to fatal compiler
      errors being implemented as panics.
      2627eedd
  11. 08 8月, 2020 3 次提交
    • A
      Update hashbrown to 0.8.2 · 99f00521
      Amanieu d'Antras 提交于
      99f00521
    • N
    • N
      Eliminate the `SessionGlobals` from `librustc_ast`. · e539dd65
      Nicholas Nethercote 提交于
      By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
      means they are accessed via the `Session`, rather than via TLS. A few
      `Attr` methods and `librustc_ast` functions are now methods of
      `Session`.
      
      All of this required passing a `Session` to lots of functions that didn't
      already have one. Some of these functions also had arguments removed, because
      those arguments could be accessed directly via the `Session` argument.
      
      `contains_feature_attr()` was dead, and is removed.
      
      Some functions were moved from `librustc_ast` elsewhere because they now need
      to access `Session`, which isn't available in that crate.
      - `entry_point_type()` --> `librustc_builtin_macros`
      - `global_allocator_spans()` --> `librustc_metadata`
      - `is_proc_macro_attr()` --> `Session`
      e539dd65
  12. 07 8月, 2020 1 次提交
  13. 03 8月, 2020 1 次提交
    • N
      Remove `GCX_PTR`. · d93277b9
      Nicholas Nethercote 提交于
      We store an `ImplicitCtxt` pointer in a thread-local value (TLV). This allows
      implicit access to a `GlobalCtxt` and some other things.
      
      We also store a `GlobalCtxt` pointer in `GCX_PTR`. This is always the same
      `GlobalCtxt` as the one within the `ImplicitCtxt` pointer in TLV. `GCX_PTR`
      is only used in the parallel compiler's `handle_deadlock()` function.
      
      This commit does the following.
      - It removes `GCX_PTR`.
      - It also adds `ImplicitCtxt::new()`, which constructs an `ImplicitCtxt` from a
        `GlobalCtxt`. `ImplicitCtxt::new()` + `tls::enter_context()` is now
        equivalent to the old `tls::enter_global()`.
      - Makes `tls::get_tlv()` public for the parallel compiler, because it's
        now used in `handle_deadlock()`.
      d93277b9
  14. 02 8月, 2020 2 次提交
  15. 01 8月, 2020 3 次提交
  16. 30 7月, 2020 1 次提交
  17. 29 7月, 2020 3 次提交
    • X
      Move mir-opt tests to toplevel · f07607f4
      Xavier Denis 提交于
      f07607f4
    • P
      bump libc version to 0.2.74 · 7baa87fc
      Paul Sajna 提交于
      7baa87fc
    • A
      std: Switch from libbacktrace to gimli · 06d565c9
      Alex Crichton 提交于
      This commit is a proof-of-concept for switching the standard library's
      backtrace symbolication mechanism on most platforms from libbacktrace to
      gimli. The standard library's support for `RUST_BACKTRACE=1` requires
      in-process parsing of object files and DWARF debug information to
      interpret it and print the filename/line number of stack frames as part
      of a backtrace.
      
      Historically this support in the standard library has come from a
      library called "libbacktrace". The libbacktrace library seems to have
      been extracted from gcc at some point and is written in C. We've had a
      lot of issues with libbacktrace over time, unfortunately, though. The
      library does not appear to be actively maintained since we've had
      patches sit for months-to-years without comments. We have discovered a
      good number of soundness issues with the library itself, both when
      parsing valid DWARF as well as invalid DWARF. This is enough of an issue
      that the libs team has previously decided that we cannot feed untrusted
      inputs to libbacktrace. This also doesn't take into account the
      portability of libbacktrace which has been difficult to manage and
      maintain over time. While possible there are lots of exceptions and it's
      the main C dependency of the standard library right now.
      
      For years it's been the desire to switch over to a Rust-based solution
      for symbolicating backtraces. It's been assumed that we'll be using the
      Gimli family of crates for this purpose, which are targeted at safely
      and efficiently parsing DWARF debug information. I've been working
      recently to shore up the Gimli support in the `backtrace` crate. As of a
      few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
      from crates.io. This transition has gone well enough that I figured it
      was time to start talking seriously about this change to the standard
      library.
      
      This commit is a preview of what's probably the best way to integrate
      the `backtrace` crate into the standard library with the Gimli feature
      turned on. While today it's used as a crates.io dependency, this commit
      switches the `backtrace` crate to a submodule of this repository which
      will need to be updated manually. This is not done lightly, but is
      thought to be the best solution. The primary reason for this is that the
      `backtrace` crate needs to do some pretty nontrivial filesystem
      interactions to locate debug information. Working without `std::fs` is
      not an option, and while it might be possible to do some sort of
      trait-based solution when prototyped it was found to be too unergonomic.
      Using a submodule allows the `backtrace` crate to build as a submodule
      of the `std` crate itself, enabling it to use `std::fs` and such.
      
      Otherwise this adds new dependencies to the standard library. This step
      requires extra attention because this means that these crates are now
      going to be included with all Rust programs by default. It's important
      to note, however, that we're already shipping libbacktrace with all Rust
      programs by default and it has a bunch of C code implementing all of
      this internally anyway, so we're basically already switching
      already-shipping functionality to Rust from C.
      
      * `object` - this crate is used to parse object file headers and
        contents. Very low-level support is used from this crate and almost
        all of it is disabled. Largely we're just using struct definitions as
        well as convenience methods internally to read bytes and such.
      
      * `addr2line` - this is the main meat of the implementation for
        symbolication. This crate depends on `gimli` for DWARF parsing and
        then provides interfaces needed by the `backtrace` crate to turn an
        address into a filename / line number. This crate is actually pretty
        small (fits in a single file almost!) and mirrors most of what
        `dwarf.c` does for libbacktrace.
      
      * `miniz_oxide` - the libbacktrace crate transparently handles
        compressed debug information which is compressed with zlib. This crate
        is used to decompress compressed debug sections.
      
      * `gimli` - not actually used directly, but a dependency of `addr2line`.
      
      * `adler32`- not used directly either, but a dependency of
        `miniz_oxide`.
      
      The goal of this change is to improve the safety of backtrace
      symbolication in the standard library, especially in the face of
      possibly malformed DWARF debug information. Even to this day we're still
      seeing segfaults in libbacktrace which could possibly become security
      vulnerabilities. This change should almost entirely eliminate this
      possibility whilc also paving the way forward to adding more features
      like split debug information.
      
      Some references for those interested are:
      
      * Original addition of libbacktrace - #12602
      * OOM with libbacktrace - #24231
      * Backtrace failure due to use of uninitialized value - #28447
      * Possibility to feed untrusted data to libbacktrace - #21889
      * Soundness fix for libbacktrace - #33729
      * Crash in libbacktrace - #39468
      * Support for macOS, never merged - ianlancetaylor/libbacktrace#2
      * Performance issues with libbacktrace - #29293, #37477
      * Update procedure is quite complicated due to how many patches we
        need to carry - #50955
      * Libbacktrace doesn't work on MinGW with dynamic libs - #71060
      * Segfault in libbacktrace on macOS - #71397
      
      Switching to Rust will not make us immune to all of these issues. The
      crashes are expected to go away, but correctness and performance may
      still have bugs arise. The gimli and `backtrace` crates, however, are
      actively maintained unlike libbacktrace, so this should enable us to at
      least efficiently apply fixes as situations come up.
      06d565c9
  18. 26 7月, 2020 1 次提交
  19. 23 7月, 2020 1 次提交
  20. 22 7月, 2020 1 次提交
  21. 21 7月, 2020 1 次提交
  22. 18 7月, 2020 3 次提交
    • F
      fixes #67108 by using the external crate · 4b6a0278
      Federico Ponzi 提交于
      4b6a0278
    • A
      std: Switch from libbacktrace to gimli · 13db3cc1
      Alex Crichton 提交于
      This commit is a proof-of-concept for switching the standard library's
      backtrace symbolication mechanism on most platforms from libbacktrace to
      gimli. The standard library's support for `RUST_BACKTRACE=1` requires
      in-process parsing of object files and DWARF debug information to
      interpret it and print the filename/line number of stack frames as part
      of a backtrace.
      
      Historically this support in the standard library has come from a
      library called "libbacktrace". The libbacktrace library seems to have
      been extracted from gcc at some point and is written in C. We've had a
      lot of issues with libbacktrace over time, unfortunately, though. The
      library does not appear to be actively maintained since we've had
      patches sit for months-to-years without comments. We have discovered a
      good number of soundness issues with the library itself, both when
      parsing valid DWARF as well as invalid DWARF. This is enough of an issue
      that the libs team has previously decided that we cannot feed untrusted
      inputs to libbacktrace. This also doesn't take into account the
      portability of libbacktrace which has been difficult to manage and
      maintain over time. While possible there are lots of exceptions and it's
      the main C dependency of the standard library right now.
      
      For years it's been the desire to switch over to a Rust-based solution
      for symbolicating backtraces. It's been assumed that we'll be using the
      Gimli family of crates for this purpose, which are targeted at safely
      and efficiently parsing DWARF debug information. I've been working
      recently to shore up the Gimli support in the `backtrace` crate. As of a
      few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
      from crates.io. This transition has gone well enough that I figured it
      was time to start talking seriously about this change to the standard
      library.
      
      This commit is a preview of what's probably the best way to integrate
      the `backtrace` crate into the standard library with the Gimli feature
      turned on. While today it's used as a crates.io dependency, this commit
      switches the `backtrace` crate to a submodule of this repository which
      will need to be updated manually. This is not done lightly, but is
      thought to be the best solution. The primary reason for this is that the
      `backtrace` crate needs to do some pretty nontrivial filesystem
      interactions to locate debug information. Working without `std::fs` is
      not an option, and while it might be possible to do some sort of
      trait-based solution when prototyped it was found to be too unergonomic.
      Using a submodule allows the `backtrace` crate to build as a submodule
      of the `std` crate itself, enabling it to use `std::fs` and such.
      
      Otherwise this adds new dependencies to the standard library. This step
      requires extra attention because this means that these crates are now
      going to be included with all Rust programs by default. It's important
      to note, however, that we're already shipping libbacktrace with all Rust
      programs by default and it has a bunch of C code implementing all of
      this internally anyway, so we're basically already switching
      already-shipping functionality to Rust from C.
      
      * `object` - this crate is used to parse object file headers and
        contents. Very low-level support is used from this crate and almost
        all of it is disabled. Largely we're just using struct definitions as
        well as convenience methods internally to read bytes and such.
      
      * `addr2line` - this is the main meat of the implementation for
        symbolication. This crate depends on `gimli` for DWARF parsing and
        then provides interfaces needed by the `backtrace` crate to turn an
        address into a filename / line number. This crate is actually pretty
        small (fits in a single file almost!) and mirrors most of what
        `dwarf.c` does for libbacktrace.
      
      * `miniz_oxide` - the libbacktrace crate transparently handles
        compressed debug information which is compressed with zlib. This crate
        is used to decompress compressed debug sections.
      
      * `gimli` - not actually used directly, but a dependency of `addr2line`.
      
      * `adler32`- not used directly either, but a dependency of
        `miniz_oxide`.
      
      The goal of this change is to improve the safety of backtrace
      symbolication in the standard library, especially in the face of
      possibly malformed DWARF debug information. Even to this day we're still
      seeing segfaults in libbacktrace which could possibly become security
      vulnerabilities. This change should almost entirely eliminate this
      possibility whilc also paving the way forward to adding more features
      like split debug information.
      
      Some references for those interested are:
      
      * Original addition of libbacktrace - #12602
      * OOM with libbacktrace - #24231
      * Backtrace failure due to use of uninitialized value - #28447
      * Possibility to feed untrusted data to libbacktrace - #21889
      * Soundness fix for libbacktrace - #33729
      * Crash in libbacktrace - #39468
      * Support for macOS, never merged - ianlancetaylor/libbacktrace#2
      * Performance issues with libbacktrace - #29293, #37477
      * Update procedure is quite complicated due to how many patches we
        need to carry - #50955
      * Libbacktrace doesn't work on MinGW with dynamic libs - #71060
      * Segfault in libbacktrace on macOS - #71397
      
      Switching to Rust will not make us immune to all of these issues. The
      crashes are expected to go away, but correctness and performance may
      still have bugs arise. The gimli and `backtrace` crates, however, are
      actively maintained unlike libbacktrace, so this should enable us to at
      least efficiently apply fixes as situations come up.
      13db3cc1
    • R
      Generating the coverage map · a6f8b8a2
      Rich Kadel 提交于
      rustc now generates the coverage map and can support (limited)
      coverage report generation, at the function level.
      
      Example:
      
      $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
      $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
      $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
      $ LLVM_PROFILE_FILE="main.profraw" ./main
      called
      $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
      $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
          1|      1|pub fn will_be_called() {
          2|      1|    println!("called");
          3|      1|}
          4|       |
          5|      0|pub fn will_not_be_called() {
          6|      0|    println!("should not have been called");
          7|      0|}
          8|       |
          9|      1|fn main() {
         10|      1|    let less = 1;
         11|      1|    let more = 100;
         12|      1|
         13|      1|    if less < more {
         14|      1|        will_be_called();
         15|      1|    } else {
         16|      1|        will_not_be_called();
         17|      1|    }
         18|      1|}
      a6f8b8a2
  23. 17 7月, 2020 2 次提交
  24. 16 7月, 2020 1 次提交