Replace Linux Mutex and Condvar with futex based ones. by m-ou-se · Pull Request #95035 · rust-lang/rust (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Relevant to the library team, which will review and decide on the PR/issue.
label
1 similar comment
m-ou-se marked this pull request as ready for review
joshtriplett added the relnotes
Marks issues that should be documented in the release notes of the next release.
label
This was referenced
Apr 25, 2022
This was referenced
May 26, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request
Make {Mutex, Condvar, RwLock}::new() const.
This makes it possible to have static M: Mutex<_> = Mutex::new(..);
🎉
Our implementations on Linux, on Windows, and various BSDs and some tier 3 platforms have already been using a non-allocating const-constructible implementation. As of rust-lang#97647, the remaining platforms (most notably macOS) now have a const-constructible implementation as well. This means we can finally make these functions publicly const.
Tracking issue: rust-lang#93740
nnmm mentioned this pull request
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request
yvt mentioned this pull request
yvt added a commit to r3-os/r3 that referenced this pull request
This drop
call is intended to cut short the borrow 'a
maintained by
a reference-containing Mutex<&'a mut _>
, but actually it's unnecessary
because Mutex
's contained data (&'a mut _
) is not subject to drop
check, hence the borrow is allowed to expire before the containing
Mutex
is dropped.
As for the drop_non_drop
lint, I would say it's a false-positive
because not every target supported by std
has a trivial destructor for
Mutex
. This lint started to trigger only recently because
rust-lang/rust#95035 replaced the Mutex
implementation with a
futex-based one on Linux.
yorickpeterse added a commit to inko-lang/inko that referenced this pull request
As of rust-lang/rust#95035, the locking API provided by std::sync is improved on Linux, outperforming parking_lot in various cases. Using the built-in locking APIs means we can remove parking_lot as a dependency, along with its own (indirect) dependencies; removing a total of 10 dependencies.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request
Pkgsrc changes:
- Bump required GCC to 7 (same as LLVM) to avoid ABI issues Fixes native i386 and powerpc 8.x build w/pkgsrc LLVM 14
- Bump available bootstraps to 1.61.0.
- Also unlimit stacksize
- Sync patches over from wip/rust
- Adjust line number in patches which had non-zero offsets.
- no longer pass -I/usr/pkg/include through via gcc-wrap script when building natively. Attempt at fixing version skew with curl package vs. internal version of curl (may not work...)
- The NetBSD bootstraps now use .xz compression.
- Use mk/atomic64.mk. Still have conditional for libatomic-links.
- Default to using the internal LLVM when cross-building.
Upstream changes:
Version 1.62.1 (2022-07-19)
Rust 1.62.1 addresses a few recent regressions in the compiler and standard library, and also mitigates a CPU vulnerability on Intel SGX.
- The compiler fixed unsound function coercions involving
impl Trait
return types. - The compiler fixed an incremental compilation bug with
async fn
lifetimes. - Windows added a fallback for overlapped I/O in synchronous reads and writes.
- The
x86_64-fortanix-unknown-sgx
target added a mitigation for the MMIO stale data vulnerability, advisory INTEL-SA-00615.
Version 1.62.0 (2022-06-30)
Language
- Stabilize
#[derive(Default)]
on enums with a#[default]
variant - Stop validating some checks in dead code after functions with uninhabited return types
- Fix constants not getting dropped if part of a diverging expression
- Support unit struct/enum variant in destructuring assignment
- Remove mutable_borrow_reservation_conflict lint and allow the code pattern
Compiler
- linker: Stop using whole-archive on dependencies of dylibs
- Make
unaligned_references
lint deny-by-default This lint is also a future compatibility lint, and is expected to eventually become a hard error. - Only add codegen backend to dep info if -Zbinary-dep-depinfo is used
- Reject
#[thread_local]
attribute on non-static items - Add tier 3
aarch64-pc-windows-gnullvm
andx86_64-pc-windows-gnullvm
targets* - Implement a lint to warn about unused macro rules
- Promote
x86_64-unknown-none
target to Tier 2*
* Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
Libraries
- Move
CStr
to libcore, andCString
to liballoc - Windows: Use a pipe relay for chaining pipes
- Replace Linux Mutex and Condvar with futex based ones.
- Replace RwLock by a futex based one on Linux
- std: directly use pthread in UNIX parker implementation
Stabilized APIs
bool::then_some
f32::total_cmp
f64::total_cmp
Stdin::lines
windows::CommandExt::raw_arg
impl<T: Default> Default for AssertUnwindSafe<T>
From<Rc<str>> for Rc<[u8]>
From<Arc<str>> for Arc<[u8]>
FusedIterator for EncodeWide
- RDM intrinsics on aarch64
Clippy
Cargo
- Added the
cargo add
command for adding dependencies toCargo.toml
from the command-line. docs - Package ID specs now support
name@version
syntax in addition to the previousname:version
to align with the behavior incargo add
and other tools.cargo install
andcargo yank
also now support this syntax so the version does not need to passed as a separate flag. - The
git
andregistry
directories in Cargo's home directory (usually~/.cargo
) are now marked as cache directories so that they are not included in backups or content indexing (on Windows). - Added automatic
@
argfile support, which will use "response files" if the command-line torustc
exceeds the operating system's limit.
Compatibility Notes
cargo test
now passes--target
torustdoc
if the specified target is the same as the host target. #10594- rustdoc: Remove .woff font files
- Enforce Copy bounds for repeat elements while considering lifetimes
Internal Changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
Version 1.61.0 (2022-05-19)
Language
const fn
signatures can now include generic trait boundsconst fn
signatures can now useimpl Trait
in argument and return position- Function pointers can now be created, cast, and passed around in a
const fn
- Recursive calls can now set the value of a function's opaque
impl Trait
return type
Compiler
- Linking modifier syntax in
#[link]
attributes and on the command line, as well as thewhole-archive
modifier specifically, are now supported - The
char
type is now described as UTF-32 in debuginfo - The
#[target_feature]
attribute can now be used with aarch64 features - X86
#[target_feature = "adx"]
is now stable
Libraries
ManuallyDrop<T>
is now documented to have the same layout asT
#[ignore = "#"]
messages are printed when running tests- Consistently show absent stdio handles on Windows as NULL handles
- Make
std::io::stdio::lock()
return'static
handles. Previously, the creation of locked handles to stdin/stdout/stderr would borrow the handles being locked, which prevented writinglet out = std::io::stdout().lock();
becauseout
would outlive the return value ofstdout()
. Such code now works, eliminating a common pitfall that affected many Rust users. Vec::from_raw_parts
is now less restrictive about its inputsstd::thread::available_parallelism
now takes cgroup quotas into account. Sinceavailable_parallelism
is often used to create a thread pool for parallel computation, which may be CPU-bound for performance,available_parallelism
will return a value consistent with the ability to use that many threads continuously, if possible. For instance, in a container with 8 virtual CPUs but quotas only allowing for 50% usage,available_parallelism
will return 4.
Stabilized APIs
Pin::static_mut
Pin::static_ref
Vec::retain_mut
VecDeque::retain_mut
Write
forCursor<[u8; N]>
std::os::unix:🥅:SocketAddr::from_pathname
std::process::ExitCode
andstd::process::Termination
. The stabilization of these two API s now makes it possible for programs to return errors frommain
with custom exit codes.std::thread::JoinHandle::is_finished
These APIs are now usable in const contexts:
<*const T>::offset
and<*mut T>::offset
- [
<*const T>::wrapping_offset
and<*mut T>::wrapping_offset
] ptr-wrapping_offset <*const T>::add
and<*mut T>::add
<*const T>::sub
and<*mut T>::sub
<*const T>::wrapping_add
and<*mut T>::wrapping_add
<*const T>::wrapping_sub
and<*mut T>::wrapping_sub
<[T]>::as_mut_ptr
<[T]>::as_ptr_range
<[T]>::as_mut_ptr_range
Cargo
No feature changes, but see compatibility notes.
Compatibility Notes
- Previously native static libraries were linked as
whole-archive
in some cases, but now rustc tries not to usewhole-archive
unless explicitly requested. This change may result in linking errors in some cases. To fix such errors, native libraries linked from the command line, build scripts, or#[link]
attributes need to- (more common) either be reordered to respect dependencies between them
(if
a
depends onb
thena
should go first andb
second) - (less common) or be updated to use the
+whole-archive
modifier.
- (more common) either be reordered to respect dependencies between them
(if
- Catching a second unwind from FFI code while cleaning up from a Rust panic now causes the process to abort
- Proc macros no longer see
ident
matchers wrapped in groups - The number of
#
inr#
raw string literals is now required to be less than 256 - When checking that a dyn type satisfies a trait bound, supertrait bounds are now enforced
- [
cargo vendor
now only accepts one value for each--sync
flag] cargo/10448 cfg
predicates inall()
andany()
are always evaluated to detect errors, instead of short-circuiting. The compatibility considerations here arise in nightly-only code that used the short-circuiting behavior ofall
to write something likecfg(all(feature = "nightly", syntax-requiring-nightly))
, which will now fail to compile. Instead, use eithercfg_attr(feature = "nightly", ...)
or nested uses ofcfg
.- bootstrap: static-libstdcpp is now enabled by default, and can now be disabled when llvm-tools is enabled
Internal Changes
These changes provide no direct user facing benefits, but represent significant improvements to the internals and overall performance of rustc and related tools.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request
Make {Mutex, Condvar, RwLock}::new() const.
This makes it possible to have static M: Mutex<_> = Mutex::new(..);
🎉
Our implementations on Linux, on Windows, and various BSDs and some tier 3 platforms have already been using a non-allocating const-constructible implementation. As of rust-lang/rust#97647, the remaining platforms (most notably macOS) now have a const-constructible implementation as well. This means we can finally make these functions publicly const.
Tracking issue: rust-lang/rust#93740
Tpt mentioned this pull request
gz mentioned this pull request