2016-09-02 16:55:29 +08:00
|
|
|
[workspace]
|
|
|
|
members = [
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/bootstrap",
|
2020-08-28 11:58:48 +08:00
|
|
|
"compiler/rustc",
|
2020-06-12 10:31:49 +08:00
|
|
|
"library/std",
|
|
|
|
"library/test",
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/tools/cargotest",
|
|
|
|
"src/tools/clippy",
|
|
|
|
"src/tools/compiletest",
|
|
|
|
"src/tools/error_index_generator",
|
|
|
|
"src/tools/linkchecker",
|
2020-09-09 06:09:57 +08:00
|
|
|
"src/tools/lint-docs",
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/tools/rustbook",
|
|
|
|
"src/tools/unstable-book-gen",
|
|
|
|
"src/tools/tidy",
|
2020-08-12 07:49:39 +08:00
|
|
|
"src/tools/tier-check",
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/tools/build-manifest",
|
|
|
|
"src/tools/remote-test-client",
|
|
|
|
"src/tools/remote-test-server",
|
|
|
|
"src/tools/rust-installer",
|
2020-07-03 02:27:15 +08:00
|
|
|
"src/tools/rust-demangler",
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/tools/cargo",
|
|
|
|
"src/tools/rustdoc",
|
|
|
|
"src/tools/rls",
|
|
|
|
"src/tools/rustfmt",
|
|
|
|
"src/tools/miri",
|
2020-06-02 02:17:20 +08:00
|
|
|
"src/tools/miri/cargo-miri",
|
2018-08-22 10:50:46 +08:00
|
|
|
"src/tools/rustdoc-themes",
|
2020-01-14 05:40:19 +08:00
|
|
|
"src/tools/unicode-table-generator",
|
2019-11-26 19:06:30 +08:00
|
|
|
"src/tools/expand-yaml-anchors",
|
2018-07-27 05:58:55 +08:00
|
|
|
]
|
|
|
|
exclude = [
|
2018-11-25 20:59:52 +08:00
|
|
|
"build",
|
2020-10-15 20:23:43 +08:00
|
|
|
"compiler/rustc_codegen_cranelift",
|
2018-11-26 05:15:20 +08:00
|
|
|
# HACK(eddyb) This hardcodes the fact that our CI uses `/checkout/obj`.
|
|
|
|
"obj",
|
2017-04-21 05:32:54 +08:00
|
|
|
]
|
|
|
|
|
2020-06-15 22:54:20 +08:00
|
|
|
[profile.release.package.compiler_builtins]
|
|
|
|
# The compiler-builtins crate cannot reference libcore, and it's own CI will
|
|
|
|
# verify that this is the case. This requires, however, that the crate is built
|
|
|
|
# without overflow checks and debug assertions. Forcefully disable debug
|
|
|
|
# assertions and overflow checks here which should ensure that even if these
|
|
|
|
# assertions are enabled for libstd we won't enable then for compiler_builtins
|
|
|
|
# which should ensure we still link everything correctly.
|
2016-11-17 01:19:02 +08:00
|
|
|
debug-assertions = false
|
2020-06-15 22:54:20 +08:00
|
|
|
overflow-checks = false
|
2017-04-30 07:11:58 +08:00
|
|
|
|
2020-06-09 00:02:57 +08:00
|
|
|
# For compiler-builtins we always use a high number of codegen units.
|
|
|
|
# The goal here is to place every single intrinsic into its own object
|
|
|
|
# file to avoid symbol clashes with the system libgcc if possible. Note
|
|
|
|
# that this number doesn't actually produce this many object files, we
|
|
|
|
# just don't create more than this number of object files.
|
|
|
|
#
|
|
|
|
# It's a bit of a bummer that we have to pass this here, unfortunately.
|
|
|
|
# Ideally this would be specified through an env var to Cargo so Cargo
|
|
|
|
# knows how many CGUs are for this specific crate, but for now
|
|
|
|
# per-crate configuration isn't specifiable in the environment.
|
|
|
|
codegen-units = 10000
|
|
|
|
|
std: Switch from libbacktrace to gimli
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.
2020-05-14 05:22:37 +08:00
|
|
|
# These dependencies of the standard library implement symbolication for
|
|
|
|
# backtraces on most platforms. Their debuginfo causes both linking to be slower
|
|
|
|
# (more data to chew through) and binaries to be larger without really all that
|
|
|
|
# much benefit. This section turns them all to down to have no debuginfo which
|
|
|
|
# helps to improve link times a little bit.
|
|
|
|
[profile.release.package]
|
|
|
|
addr2line.debug = 0
|
|
|
|
adler.debug = 0
|
|
|
|
gimli.debug = 0
|
|
|
|
miniz_oxide.debug = 0
|
|
|
|
object.debug = 0
|
|
|
|
|
2018-01-09 05:56:22 +08:00
|
|
|
# We want the RLS to use the version of Cargo that we've got vendored in this
|
|
|
|
# repository to ensure that the same exact version of Cargo is used by both the
|
|
|
|
# RLS and the Cargo binary itself. The RLS depends on Cargo as a git repository
|
|
|
|
# so we use a `[patch]` here to override the github repository with our local
|
|
|
|
# vendored copy.
|
2017-09-12 08:17:31 +08:00
|
|
|
[patch."https://github.com/rust-lang/cargo"]
|
2018-08-22 10:50:46 +08:00
|
|
|
cargo = { path = "src/tools/cargo" }
|
2017-09-01 13:13:15 +08:00
|
|
|
|
2020-08-18 18:45:20 +08:00
|
|
|
[patch."https://github.com/rust-lang/rustfmt"]
|
2018-01-09 05:56:22 +08:00
|
|
|
# Similar to Cargo above we want the RLS to use a vendored version of `rustfmt`
|
|
|
|
# that we're shipping as well (to ensure that the rustfmt in RLS and the
|
2018-07-09 16:04:28 +08:00
|
|
|
# `rustfmt` executable are the same exact version).
|
2018-08-22 10:50:46 +08:00
|
|
|
rustfmt-nightly = { path = "src/tools/rustfmt" }
|
2018-07-09 16:04:28 +08:00
|
|
|
|
2020-08-18 18:45:20 +08:00
|
|
|
[patch.crates-io]
|
2018-08-22 10:50:46 +08:00
|
|
|
# See comments in `src/tools/rustc-workspace-hack/README.md` for what's going on
|
2018-08-01 05:16:55 +08:00
|
|
|
# here
|
2018-08-22 10:50:46 +08:00
|
|
|
rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' }
|
2018-08-01 05:16:55 +08:00
|
|
|
|
2020-06-12 10:31:49 +08:00
|
|
|
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
|
std: Depend directly on crates.io crates
Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.
I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!
The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.
Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:
* The standard library (or some transitive dep) decides to depend on a
crate `foo`.
* The standard library adds
```toml
[dependencies]
foo = { version = "0.1", features = ['rustc-dep-of-std'] }
```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
crates and any other necessary infrastructure in the crate.
A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.
As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.
This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!
[commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-11-20 13:52:50 +08:00
|
|
|
# here
|
2020-06-12 10:31:49 +08:00
|
|
|
rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
|
|
|
|
rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' }
|
|
|
|
rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' }
|
std: Depend directly on crates.io crates
Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.
I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!
The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.
Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:
* The standard library (or some transitive dep) decides to depend on a
crate `foo`.
* The standard library adds
```toml
[dependencies]
foo = { version = "0.1", features = ['rustc-dep-of-std'] }
```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
crates and any other necessary infrastructure in the crate.
A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.
As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.
This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!
[commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-11-20 13:52:50 +08:00
|
|
|
|
std: Switch from libbacktrace to gimli
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.
2020-05-14 05:22:37 +08:00
|
|
|
# This crate's integration with libstd is a bit wonky, so we use a submodule
|
|
|
|
# instead of a crates.io dependency. Make sure everything else in the repo is
|
|
|
|
# also using the submodule, however, so we can avoid duplicate copies of the
|
|
|
|
# source code for this crate.
|
|
|
|
backtrace = { path = "library/backtrace" }
|
|
|
|
|
2018-12-01 18:36:32 +08:00
|
|
|
[patch."https://github.com/rust-lang/rust-clippy"]
|
2018-08-22 10:50:46 +08:00
|
|
|
clippy_lints = { path = "src/tools/clippy/clippy_lints" }
|