Skip to content

Commit a3e7853

Browse files
committed
Auto merge of #142059 - matthiaskrgr:rollup-w4jw2de, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #140638 (UnsafePinned: also include the effects of UnsafeCell) - #141272 (modularize the config module bootstrap) - #141777 (Do not run PGO/BOLT in x64 Linux alt builds) - #141870 (Fix broken link to rustc_type_ir module in serialization docs) - #141938 (update rust offload bootstrap) - #141962 (rustc-dev-guide subtree update) - #141965 (`tests/ui`: A New Order [3/N]) - #141970 (implement new `x` flag: `--skip-std-check-if-no-download-rustc`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 425e142 + 9bd566c commit a3e7853

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2798
-2200
lines changed

library/core/src/pin/unsafe_pinned.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
use crate::cell::UnsafeCell;
12
use crate::marker::{PointerLike, Unpin};
23
use crate::ops::{CoerceUnsized, DispatchFromDyn};
34
use crate::pin::Pin;
45
use crate::{fmt, ptr};
56

6-
/// This type provides a way to opt-out of typical aliasing rules;
7+
/// This type provides a way to entirely opt-out of typical aliasing rules;
78
/// specifically, `&mut UnsafePinned<T>` is not guaranteed to be a unique pointer.
9+
/// This also subsumes the effects of `UnsafeCell`, i.e., `&UnsafePinned<T>` may point to data
10+
/// that is being mutated.
811
///
912
/// However, even if you define your type like `pub struct Wrapper(UnsafePinned<...>)`, it is still
1013
/// very risky to have an `&mut Wrapper` that aliases anything else. Many functions that work
@@ -17,38 +20,24 @@ use crate::{fmt, ptr};
1720
/// the public API of a library. It is an internal implementation detail of libraries that need to
1821
/// support aliasing mutable references.
1922
///
20-
/// Further note that this does *not* lift the requirement that shared references must be read-only!
21-
/// Use `UnsafeCell` for that.
22-
///
2323
/// This type blocks niches the same way `UnsafeCell` does.
2424
#[lang = "unsafe_pinned"]
2525
#[repr(transparent)]
2626
#[unstable(feature = "unsafe_pinned", issue = "125735")]
2727
pub struct UnsafePinned<T: ?Sized> {
28-
value: T,
28+
value: UnsafeCell<T>,
2929
}
3030

31+
// Override the manual `!Sync` in `UnsafeCell`.
32+
#[unstable(feature = "unsafe_pinned", issue = "125735")]
33+
unsafe impl<T: ?Sized + Sync> Sync for UnsafePinned<T> {}
34+
3135
/// When this type is used, that almost certainly means safe APIs need to use pinning to avoid the
3236
/// aliases from becoming invalidated. Therefore let's mark this as `!Unpin`. You can always opt
3337
/// back in to `Unpin` with an `impl` block, provided your API is still sound while unpinned.
3438
#[unstable(feature = "unsafe_pinned", issue = "125735")]
3539
impl<T: ?Sized> !Unpin for UnsafePinned<T> {}
3640

37-
/// The type is `Copy` when `T` is to avoid people assuming that `Copy` implies there is no
38-
/// `UnsafePinned` anywhere. (This is an issue with `UnsafeCell`: people use `Copy` bounds to mean
39-
/// `Freeze`.) Given that there is no `unsafe impl Copy for ...`, this is also the option that
40-
/// leaves the user more choices (as they can always wrap this in a `!Copy` type).
41-
// FIXME(unsafe_pinned): this may be unsound or a footgun?
42-
#[unstable(feature = "unsafe_pinned", issue = "125735")]
43-
impl<T: Copy> Copy for UnsafePinned<T> {}
44-
45-
#[unstable(feature = "unsafe_pinned", issue = "125735")]
46-
impl<T: Copy> Clone for UnsafePinned<T> {
47-
fn clone(&self) -> Self {
48-
*self
49-
}
50-
}
51-
5241
// `Send` and `Sync` are inherited from `T`. This is similar to `SyncUnsafeCell`, since
5342
// we eventually concluded that `UnsafeCell` implicitly making things `!Sync` is sometimes
5443
// unergonomic. A type that needs to be `!Send`/`!Sync` should really have an explicit
@@ -63,7 +52,7 @@ impl<T> UnsafePinned<T> {
6352
#[must_use]
6453
#[unstable(feature = "unsafe_pinned", issue = "125735")]
6554
pub const fn new(value: T) -> Self {
66-
UnsafePinned { value }
55+
UnsafePinned { value: UnsafeCell::new(value) }
6756
}
6857

6958
/// Unwraps the value, consuming this `UnsafePinned`.
@@ -72,7 +61,7 @@ impl<T> UnsafePinned<T> {
7261
#[unstable(feature = "unsafe_pinned", issue = "125735")]
7362
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
7463
pub const fn into_inner(self) -> T {
75-
self.value
64+
self.value.into_inner()
7665
}
7766
}
7867

src/bootstrap/src/core/build_steps/check.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ impl Step for Std {
7777
}
7878

7979
fn run(self, builder: &Builder<'_>) {
80+
if !builder.download_rustc() && builder.config.skip_std_check_if_no_download_rustc {
81+
eprintln!(
82+
"WARNING: `--skip-std-check-if-no-download-rustc` flag was passed and `rust.download-rustc` is not available. Skipping."
83+
);
84+
return;
85+
}
86+
8087
builder.require_submodule("library/stdarch", None);
8188

8289
let stage = self.custom_stage.unwrap_or(builder.top_stage);

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,23 +443,26 @@ impl Step for Llvm {
443443
// See https://github.com/rust-lang/rust/pull/50104
444444
cfg.define("LLVM_ENABLE_LIBXML2", "OFF");
445445

446-
if !enabled_llvm_projects.is_empty() {
447-
enabled_llvm_projects.sort();
448-
enabled_llvm_projects.dedup();
449-
cfg.define("LLVM_ENABLE_PROJECTS", enabled_llvm_projects.join(";"));
450-
}
451-
452446
let mut enabled_llvm_runtimes = Vec::new();
453447

454448
if helpers::forcing_clang_based_tests() {
455449
enabled_llvm_runtimes.push("compiler-rt");
456450
}
457451

452+
// This is an experimental flag, which likely builds more than necessary.
453+
// We will optimize it when we get closer to releasing it on nightly.
458454
if builder.config.llvm_offload {
459455
enabled_llvm_runtimes.push("offload");
460456
//FIXME(ZuseZ4): LLVM intends to drop the offload dependency on openmp.
461457
//Remove this line once they achieved it.
462458
enabled_llvm_runtimes.push("openmp");
459+
enabled_llvm_projects.push("compiler-rt");
460+
}
461+
462+
if !enabled_llvm_projects.is_empty() {
463+
enabled_llvm_projects.sort();
464+
enabled_llvm_projects.dedup();
465+
cfg.define("LLVM_ENABLE_PROJECTS", enabled_llvm_projects.join(";"));
463466
}
464467

465468
if !enabled_llvm_runtimes.is_empty() {

0 commit comments

Comments
 (0)