2023-05-01 17:05:44 +00:00
|
|
|
cargo-features = ["public-dependency"]
|
|
|
|
|
2016-01-21 23:19:23 +00:00
|
|
|
[package]
|
|
|
|
name = "std"
|
|
|
|
version = "0.0.0"
|
2019-05-09 22:37:37 +00:00
|
|
|
license = "MIT OR Apache-2.0"
|
2017-10-31 19:57:27 +00:00
|
|
|
repository = "https://github.com/rust-lang/rust.git"
|
2017-10-31 20:10:10 +00:00
|
|
|
description = "The Rust Standard Library"
|
2021-12-17 09:08:36 +00:00
|
|
|
edition = "2021"
|
2016-01-21 23:19:23 +00:00
|
|
|
|
|
|
|
[lib]
|
|
|
|
crate-type = ["dylib", "rlib"]
|
|
|
|
|
|
|
|
[dependencies]
|
2023-05-01 17:05:44 +00:00
|
|
|
alloc = { path = "../alloc", public = true }
|
2022-09-15 15:39:03 +00:00
|
|
|
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
|
2020-06-12 02:31:49 +00:00
|
|
|
panic_unwind = { path = "../panic_unwind", optional = true }
|
|
|
|
panic_abort = { path = "../panic_abort" }
|
2023-05-01 17:05:44 +00:00
|
|
|
core = { path = "../core", public = true }
|
2023-10-08 08:33:54 +00:00
|
|
|
libc = { version = "0.2.149", default-features = false, features = ['rustc-dep-of-std'], public = true }
|
2023-08-07 23:38:09 +00:00
|
|
|
compiler_builtins = { version = "0.1.100" }
|
2020-06-12 02:31:49 +00:00
|
|
|
profiler_builtins = { path = "../profiler_builtins", optional = true }
|
|
|
|
unwind = { path = "../unwind" }
|
2023-06-08 14:55:49 +00:00
|
|
|
hashbrown = { version = "0.14", default-features = false, features = ['rustc-dep-of-std'] }
|
2021-04-02 08:11:46 +00:00
|
|
|
std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = ['rustc-dep-of-std'] }
|
2019-05-15 14:30:15 +00: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-13 21:22:37 +00:00
|
|
|
# Dependencies of the `backtrace` crate
|
2021-08-10 21:05:25 +00:00
|
|
|
rustc-demangle = { version = "0.1.21", features = ['rustc-dep-of-std'] }
|
2023-07-06 13:26:37 +00:00
|
|
|
|
|
|
|
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies]
|
|
|
|
miniz_oxide = { version = "0.7.0", optional = true, default-features = false }
|
2023-08-14 14:57:38 +00:00
|
|
|
addr2line = { version = "0.21.0", optional = true, default-features = false }
|
|
|
|
object = { version = "0.32.0", default-features = false, optional = true, features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] }
|
2016-01-21 23:19:23 +00:00
|
|
|
|
2017-11-01 19:32:13 +00:00
|
|
|
[dev-dependencies]
|
2022-11-21 00:55:41 +00:00
|
|
|
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
|
|
|
|
rand_xorshift = "0.3.0"
|
2017-11-01 19:32:13 +00:00
|
|
|
|
2023-07-31 08:22:27 +00:00
|
|
|
[target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "xous", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies]
|
|
|
|
dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] }
|
2018-11-03 18:15:48 +00:00
|
|
|
|
2018-08-28 04:33:26 +00:00
|
|
|
[target.x86_64-fortanix-unknown-sgx.dependencies]
|
2023-05-21 03:14:38 +00:00
|
|
|
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }
|
2018-08-28 04:33:26 +00:00
|
|
|
|
2022-02-15 12:57:07 +00:00
|
|
|
[target.'cfg(target_os = "hermit")'.dependencies]
|
2023-07-04 13:58:02 +00:00
|
|
|
hermit-abi = { version = "0.3.2", features = ['rustc-dep-of-std'], public = true }
|
2019-10-20 07:55:10 +00:00
|
|
|
|
2023-07-26 16:26:20 +00:00
|
|
|
[target.'cfg(target_os = "wasi")'.dependencies]
|
2022-01-21 13:19:13 +00:00
|
|
|
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }
|
2019-09-03 14:37:53 +00:00
|
|
|
|
2022-12-18 04:24:54 +00:00
|
|
|
[target.'cfg(target_os = "uefi")'.dependencies]
|
2023-03-28 14:44:33 +00:00
|
|
|
r-efi = { version = "4.2.0", features = ['rustc-dep-of-std']}
|
2022-12-18 04:24:54 +00:00
|
|
|
r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std']}
|
|
|
|
|
2016-01-21 23:19:23 +00:00
|
|
|
[features]
|
2019-09-14 10:12:32 +00:00
|
|
|
backtrace = [
|
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-13 21:22:37 +00:00
|
|
|
"gimli-symbolize",
|
|
|
|
'addr2line/rustc-dep-of-std',
|
|
|
|
'object/rustc-dep-of-std',
|
|
|
|
'miniz_oxide/rustc-dep-of-std',
|
2019-09-14 08:23:10 +00: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-13 21:22:37 +00:00
|
|
|
gimli-symbolize = []
|
2019-09-14 08:23:10 +00:00
|
|
|
|
2016-11-24 02:49:54 +00:00
|
|
|
panic-unwind = ["panic_unwind"]
|
2017-02-13 09:57:50 +00:00
|
|
|
profiler = ["profiler_builtins"]
|
2019-05-20 18:00:34 +00:00
|
|
|
compiler-builtins-c = ["alloc/compiler-builtins-c"]
|
2020-09-28 03:31:06 +00:00
|
|
|
compiler-builtins-mem = ["alloc/compiler-builtins-mem"]
|
2020-12-09 19:48:08 +00:00
|
|
|
compiler-builtins-no-asm = ["alloc/compiler-builtins-no-asm"]
|
2020-10-28 06:54:30 +00:00
|
|
|
compiler-builtins-mangled-names = ["alloc/compiler-builtins-mangled-names"]
|
2023-06-23 10:15:34 +00:00
|
|
|
compiler-builtins-weak-intrinsics = ["alloc/compiler-builtins-weak-intrinsics"]
|
2019-03-11 02:27:59 +00:00
|
|
|
llvm-libunwind = ["unwind/llvm-libunwind"]
|
2020-10-08 13:05:31 +00:00
|
|
|
system-llvm-libunwind = ["unwind/system-llvm-libunwind"]
|
std: Implement TLS for wasm32-unknown-unknown
This adds an implementation of thread local storage for the
`wasm32-unknown-unknown` target when the `atomics` feature is
implemented. This, however, comes with a notable caveat of that it
requires a new feature of the standard library, `wasm-bindgen-threads`,
to be enabled.
Thread local storage for wasm (when `atomics` are enabled and there's
actually more than one thread) is powered by the assumption that an
external entity can fill in some information for us. It's not currently
clear who will fill in this information nor whose responsibility it
should be long-term. In the meantime there's a strategy being gamed out
in the `wasm-bindgen` project specifically, and the hope is that we can
continue to test and iterate on the standard library without committing
to a particular strategy yet.
As to the details of `wasm-bindgen`'s strategy, LLVM doesn't currently
have the ability to emit custom `global` values (thread locals in a
`WebAssembly.Module`) so we leverage the `wasm-bindgen` CLI tool to do
it for us. To that end we have a few intrinsics, assuming two global values:
* `__wbindgen_current_id` - gets the current thread id as a 32-bit
integer. It's `wasm-bindgen`'s responsibility to initialize this
per-thread and then inform libstd of the id. Currently `wasm-bindgen`
performs this initialization as part of the `start` function.
* `__wbindgen_tcb_{get,set}` - in addition to a thread id it's assumed
that there's a global available for simply storing a pointer's worth
of information (a thread control block, which currently only contains
thread local storage). This would ideally be a native `global`
injected by LLVM, but we don't have a great way to support that right
now.
To reiterate, this is all intended to be unstable and purely intended
for testing out Rust on the web with threads. The story is very likely
to change in the future and we want to make sure that we're able to do
that!
2018-10-10 06:10:25 +00:00
|
|
|
|
2018-11-29 21:06:10 +00:00
|
|
|
# Make panics and failed asserts immediately abort without formatting any message
|
2023-04-24 22:08:37 +00:00
|
|
|
panic_immediate_abort = ["core/panic_immediate_abort"]
|
2018-11-29 21:06:10 +00:00
|
|
|
|
2019-07-15 11:53:44 +00:00
|
|
|
# Enable std_detect default features for stdarch/crates/std_detect:
|
|
|
|
# https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml
|
2021-04-02 08:11:46 +00:00
|
|
|
std_detect_file_io = ["std_detect/std_detect_file_io"]
|
|
|
|
std_detect_dlsym_getauxval = ["std_detect/std_detect_dlsym_getauxval"]
|
2021-09-15 15:12:46 +00:00
|
|
|
std_detect_env_override = ["std_detect/std_detect_env_override"]
|
2019-03-12 17:58:30 +00:00
|
|
|
|
|
|
|
[package.metadata.fortanix-sgx]
|
|
|
|
# Maximum possible number of threads when testing
|
|
|
|
threads = 125
|
2019-06-06 21:06:49 +00:00
|
|
|
# Maximum heap size
|
|
|
|
heap_size = 0x8000000
|
2020-06-08 16:09:21 +00:00
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
name = "stdbenches"
|
|
|
|
path = "benches/lib.rs"
|
|
|
|
test = true
|