Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #129949

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
9a29081
call `Cargo::configure_linker` only for specific commands
onur-ozkan Aug 9, 2024
94fbe14
don't try to find target tools on certain commands
onur-ozkan Aug 9, 2024
318b4f3
Sort impl associated items by kinds and then by appearance
GuillaumeGomez Aug 23, 2024
b7cd99d
Add regression test for impl associated items sorting
GuillaumeGomez Aug 23, 2024
846cb34
Make impl associated constants sorted first
GuillaumeGomez Aug 25, 2024
893413d
Add a run-make test for checking that certain `rustc_` crates build o…
Kobzol Aug 24, 2024
7957140
inhibit proc-macro2 nightly detection
lqd Aug 24, 2024
d9794a9
run test in tmp dir and emit artifacts there
lqd Aug 24, 2024
2190c28
remove use of RUSTC_BOOTSTRAP and cargo nightly features
lqd Aug 25, 2024
0577035
separate the crates to test from the test setup
lqd Aug 25, 2024
f1df0c5
remove unneeded type ascription
lqd Aug 25, 2024
78971f3
Add missing sidebar associated items
GuillaumeGomez Aug 26, 2024
4a80840
Add regression test for sidebar associated items
GuillaumeGomez Aug 26, 2024
0d156f2
Unify scraped examples with other code examples
GuillaumeGomez Aug 30, 2024
5b75f8a
Update rustdoc GUI tests
GuillaumeGomez Aug 30, 2024
121e9f4
Add rust.randomize-layout config to build artifacts with -Zrandomize-…
the8472 Sep 2, 2022
f3bc08a
ignore/fix layout-sensitive tests
the8472 Sep 2, 2022
5bf8eeb
disable size asserts in the compiler when randomizing layouts
the8472 Sep 2, 2022
e3169f7
when -Zrandomize-layout is enabled disable alloc test testing interna…
the8472 Sep 2, 2022
1e377c5
enable layout randomization in x86_64-gnu-llvm-17 CI job
the8472 Sep 2, 2022
df20808
inhibit layout randomization for Box
the8472 Aug 31, 2024
c218c75
exclude tools with deps that have size asserts
the8472 Aug 31, 2024
5afc461
Fix wrong rounded corners when line numbers are displayed on code exa…
GuillaumeGomez Aug 31, 2024
84259ff
Add GUI tests to ensure that rounded corners on code blocks are worki…
GuillaumeGomez Aug 31, 2024
35a7c1b
Fix position of scraped examples title on mobile devices
GuillaumeGomez Sep 1, 2024
dd5f7bc
Add GUI regression test for scraped examples title position on mobile
GuillaumeGomez Sep 1, 2024
4825fb1
Add missing CSS variables in GUI test for `custom-theme.css`
GuillaumeGomez Sep 1, 2024
5a85632
Correctly handle code examples buttons position
GuillaumeGomez Sep 1, 2024
01d8235
Fix scraped examples background gradient
GuillaumeGomez Sep 1, 2024
a178559
address review comments
lqd Sep 2, 2024
e3af6dc
Simplify CSS but wrapping scraped example into a div and move the tit…
GuillaumeGomez Sep 2, 2024
55bc638
Fix wrong padding for expanded scraped example
GuillaumeGomez Sep 2, 2024
6f435cb
Port std library to RTEMS
thesummer Aug 21, 2023
124454c
rtems: Add spec file for arm_rtems6_eabihf
thesummer Jan 23, 2024
6fd358e
Add documentation for target armv7-rtems-eabihf
thesummer Jun 26, 2024
8f0ea94
Pin memchr to 2.5.0 in the library rather than rustc_ast
tgross35 Aug 26, 2024
9c671a1
Run `cargo update` in the root, library, and rustbook
tgross35 Aug 26, 2024
07c0585
Adjust allowed dependencies from the latest `cargo update`
tgross35 Aug 26, 2024
98f74b4
explain why Rvalue::Len still exists
RalfJung Sep 3, 2024
7157f98
Fix square corners on line numbers when code is collapsed
GuillaumeGomez Sep 3, 2024
add2bcc
Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum
tgross35 Sep 4, 2024
f393f86
Rollup merge of #127021 - thesummer:1-add-target-support-for-rtems-ar…
tgross35 Sep 4, 2024
5f10e04
Rollup merge of #128871 - onur-ozkan:128180, r=Kobzol
tgross35 Sep 4, 2024
8b5361e
Rollup merge of #129471 - GuillaumeGomez:sort-impl-associated-items, …
tgross35 Sep 4, 2024
f60debf
Rollup merge of #129529 - lqd:stable-new-solver, r=Kobzol
tgross35 Sep 4, 2024
1b2a4de
Rollup merge of #129624 - tgross35:cargo-update, r=Mark-Simulacrum
tgross35 Sep 4, 2024
784cbd7
Rollup merge of #129796 - GuillaumeGomez:unify-code-examples, r=notri…
tgross35 Sep 4, 2024
6aeb9b4
Rollup merge of #129939 - RalfJung:rvalue-len, r=compiler-errors
tgross35 Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 154 additions & 131 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions compiler/rustc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ features = ['unprefixed_malloc_on_supported_platforms']
jemalloc = ['dep:jemalloc-sys']
llvm = ['rustc_driver_impl/llvm']
max_level_info = ['rustc_driver_impl/max_level_info']
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
rustc_use_parallel_compiler = ['rustc_driver_impl/rustc_use_parallel_compiler']
# tidy-alphabetical-end
11 changes: 7 additions & 4 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ fn univariant<
let mut align = if pack.is_some() { dl.i8_align } else { dl.aggregate_align };
let mut max_repr_align = repr.align;
let mut inverse_memory_index: IndexVec<u32, FieldIdx> = fields.indices().collect();
let optimize = !repr.inhibit_struct_field_reordering();
if optimize && fields.len() > 1 {
let optimize_field_order = !repr.inhibit_struct_field_reordering();
if optimize_field_order && fields.len() > 1 {
let end = if let StructKind::MaybeUnsized = kind { fields.len() - 1 } else { fields.len() };
let optimizing = &mut inverse_memory_index.raw[..end];
let fields_excluding_tail = &fields.raw[..end];
Expand Down Expand Up @@ -1176,7 +1176,7 @@ fn univariant<
// If field 5 has offset 0, offsets[0] is 5, and memory_index[5] should be 0.
// Field 5 would be the first element, so memory_index is i:
// Note: if we didn't optimize, it's already right.
let memory_index = if optimize {
let memory_index = if optimize_field_order {
inverse_memory_index.invert_bijective_mapping()
} else {
debug_assert!(inverse_memory_index.iter().copied().eq(fields.indices()));
Expand All @@ -1189,6 +1189,9 @@ fn univariant<
}
let mut layout_of_single_non_zst_field = None;
let mut abi = Abi::Aggregate { sized };

let optimize_abi = !repr.inhibit_newtype_abi_optimization();

// Try to make this a Scalar/ScalarPair.
if sized && size.bytes() > 0 {
// We skip *all* ZST here and later check if we are good in terms of alignment.
Expand All @@ -1205,7 +1208,7 @@ fn univariant<
match field.abi {
// For plain scalars, or vectors of them, we can't unpack
// newtypes for `#[repr(C)]`, as that affects C ABIs.
Abi::Scalar(_) | Abi::Vector { .. } if optimize => {
Abi::Scalar(_) | Abi::Vector { .. } if optimize_abi => {
abi = field.abi;
}
// But scalar pairs are Rust-specific and get
Expand Down
15 changes: 11 additions & 4 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ bitflags! {
const IS_SIMD = 1 << 1;
const IS_TRANSPARENT = 1 << 2;
// Internal only for now. If true, don't reorder fields.
// On its own it does not prevent ABI optimizations.
const IS_LINEAR = 1 << 3;
// If true, the type's layout can be randomized using
// the seed stored in `ReprOptions.field_shuffle_seed`
// If true, the type's crate has opted into layout randomization.
// Other flags can still inhibit reordering and thus randomization.
// The seed stored in `ReprOptions.field_shuffle_seed`.
const RANDOMIZE_LAYOUT = 1 << 4;
// Any of these flags being set prevent field reordering optimisation.
const IS_UNOPTIMISABLE = ReprFlags::IS_C.bits()
const FIELD_ORDER_UNOPTIMIZABLE = ReprFlags::IS_C.bits()
| ReprFlags::IS_SIMD.bits()
| ReprFlags::IS_LINEAR.bits();
const ABI_UNOPTIMIZABLE = ReprFlags::IS_C.bits() | ReprFlags::IS_SIMD.bits();
}
}

Expand Down Expand Up @@ -139,10 +142,14 @@ impl ReprOptions {
self.c() || self.int.is_some()
}

pub fn inhibit_newtype_abi_optimization(&self) -> bool {
self.flags.intersects(ReprFlags::ABI_UNOPTIMIZABLE)
}

/// Returns `true` if this `#[repr()]` guarantees a fixed field order,
/// e.g. `repr(C)` or `repr(<int>)`.
pub fn inhibit_struct_field_reordering(&self) -> bool {
self.flags.intersects(ReprFlags::IS_UNOPTIMISABLE) || self.int.is_some()
self.flags.intersects(ReprFlags::FIELD_ORDER_UNOPTIMIZABLE) || self.int.is_some()
}

/// Returns `true` if this type is valid for reordering and `-Z randomize-layout`
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ version = "0.0.0"
edition = "2021"

[dependencies]
# FIXME: bumping memchr to 2.7.1 causes linker errors in MSVC thin-lto
# tidy-alphabetical-start
bitflags = "2.4.1"
memchr = "=2.5.0"
memchr = "2.7.4"
rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_index = { path = "../rustc_index" }
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ rustc_hir_analysis = { path = "../rustc_hir_analysis" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_hir_typeck = { path = "../rustc_hir_typeck" }
rustc_incremental = { path = "../rustc_incremental" }
rustc_index = { path = "../rustc_index" }
rustc_infer = { path = "../rustc_infer" }
rustc_interface = { path = "../rustc_interface" }
rustc_lint = { path = "../rustc_lint" }
Expand Down Expand Up @@ -72,6 +73,10 @@ ctrlc = "3.4.4"
# tidy-alphabetical-start
llvm = ['rustc_interface/llvm']
max_level_info = ['rustc_log/max_level_info']
rustc_randomized_layouts = [
'rustc_index/rustc_randomized_layouts',
'rustc_middle/rustc_randomized_layouts'
]
rustc_use_parallel_compiler = [
'rustc_data_structures/rustc_use_parallel_compiler',
'rustc_interface/rustc_use_parallel_compiler',
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ nightly = [
"dep:rustc_macros",
"rustc_index_macros/nightly",
]
rustc_randomized_layouts = []
# tidy-alphabetical-end
11 changes: 11 additions & 0 deletions compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,19 @@ pub use vec::IndexVec;
///
/// </div>
#[macro_export]
#[cfg(not(feature = "rustc_randomized_layouts"))]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
};
}

#[macro_export]
#[cfg(feature = "rustc_randomized_layouts")]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
// no effect other than using the statements.
// struct sizes are not deterministic under randomized layouts
const _: (usize, usize) = ($size, ::std::mem::size_of::<$ty>());
};
}
1 change: 1 addition & 0 deletions compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ tracing = "0.1"

[features]
# tidy-alphabetical-start
rustc_randomized_layouts = []
rustc_use_parallel_compiler = ["dep:rustc-rayon-core"]
# tidy-alphabetical-end
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,9 @@ pub enum Rvalue<'tcx> {
/// If the type of the place is an array, this is the array length. For slices (`[T]`, not
/// `&[T]`) this accesses the place's metadata to determine the length. This rvalue is
/// ill-formed for places of other types.
///
/// This cannot be a `UnOp(PtrMetadata, _)` because that expects a value, and we only
/// have a place, and `UnOp(PtrMetadata, RawPtr(place))` is not a thing.
Len(Place<'tcx>),

/// Performs essentially all of the casts that can be performed via `as`.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ macro_rules! define_callbacks {
// Ensure that values grow no larger than 64 bytes by accident.
// Increase this limit if necessary, but do try to keep the size low if possible
#[cfg(target_pointer_width = "64")]
#[cfg(not(feature = "rustc_randomized_layouts"))]
const _: () = {
if mem::size_of::<Value<'static>>() > 64 {
panic!("{}", concat!(
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
use rustc_errors::{Diag, ErrorGuaranteed, StashKey};
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
use rustc_hir::LangItem;
use rustc_index::IndexVec;
use rustc_macros::{
extension, Decodable, Encodable, HashStable, TyDecodable, TyEncodable, TypeFoldable,
Expand Down Expand Up @@ -1570,8 +1571,15 @@ impl<'tcx> TyCtxt<'tcx> {
flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
}

// box is special, on the one hand the compiler assumes an ordered layout, with the pointer
// always at offset zero. On the other hand we want scalar abi optimizations.
let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);

// This is here instead of layout because the choice must make it into metadata.
if !self.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did))) {
if is_box
|| !self
.consider_optimizing(|| format!("Reorder fields of {:?}", self.def_path_str(did)))
{
flags.insert(ReprFlags::IS_LINEAR);
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,8 @@ supported_targets! {
("armv7r-none-eabihf", armv7r_none_eabihf),
("armv8r-none-eabihf", armv8r_none_eabihf),

("armv7-rtems-eabihf", armv7_rtems_eabihf),

("x86_64-pc-solaris", x86_64_pc_solaris),
("sparcv9-sun-solaris", sparcv9_sun_solaris),

Expand Down
35 changes: 35 additions & 0 deletions compiler/rustc_target/src/spec/targets/armv7_rtems_eabihf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};

pub(crate) fn target() -> Target {
Target {
llvm_target: "armv7-unknown-none-eabihf".into(),
metadata: crate::spec::TargetMetadata {
description: Some("Armv7 RTEMS (Requires RTEMS toolchain and kernel".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),

options: TargetOptions {
os: "rtems".into(),
families: cvs!["unix"],
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
linker: None,
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
features: "+thumb2,+neon,+vfp3".into(),
max_atomic_width: Some(64),
emit_debug_gdb_scripts: false,
// GCC defaults to 8 for arm-none here.
c_enum_min_bits: Some(8),
eh_frame_header: false,
no_default_libraries: false,
env: "newlib".into(),
..Default::default()
},
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn supertrait_def_ids<I: Interner>(
cx: I,
trait_def_id: I::DefId,
) -> impl Iterator<Item = I::DefId> {
let mut set: HashSet<I::DefId> = HashSet::default();
let mut set = HashSet::default();
let mut stack = vec![trait_def_id];

set.insert(trait_def_id);
Expand Down
3 changes: 3 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@
# are disabled statically" because `max_level_info` is enabled, set this value to `true`.
#debug-logging = rust.debug-assertions (boolean)

# Whether or not to build rustc, tools and the libraries with randomized type layout
#randomize-layout = false

# Whether or not overflow checks are enabled for the compiler and standard
# library.
#
Expand Down
Loading
Loading