Skip to content

Commit 5c7a135

Browse files
committed
Auto merge of #151713 - matthiaskrgr:rollup-5CzKDNG, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #148718 (Do not mention `-Zmacro-backtrace` for std macros that are a wrapper around a compiler intrinsic) - #151137 (checksum-freshness: Fix invalid checksum calculation for binary files) - #150863 (Adds two new Tier 3 targets - `aarch64v8r-unknown-none{,-softfloat}`) - #151040 (Don't expose redundant information in `rustc_public`'s `LayoutShape`) - #151699 (Update books) - #151700 (os allow missing_docs)
2 parents b3cda16 + 85852e3 commit 5c7a135

File tree

161 files changed

+475
-353
lines changed

Some content is hidden

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

161 files changed

+475
-353
lines changed

compiler/rustc_builtin_macros/src/source_util.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,15 @@ fn load_binary_file(
275275
}
276276
};
277277
match cx.source_map().load_binary_file(&resolved_path) {
278-
Ok(data) => Ok(data),
278+
Ok(data) => {
279+
cx.sess
280+
.psess
281+
.file_depinfo
282+
.borrow_mut()
283+
.insert(Symbol::intern(&resolved_path.to_string_lossy()));
284+
285+
Ok(data)
286+
}
279287
Err(io_err) => {
280288
let mut err = cx.dcx().struct_span_err(
281289
macro_span,

compiler/rustc_expand/src/base.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ pub struct SyntaxExtension {
849849
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
850850
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
851851
pub collapse_debuginfo: bool,
852+
/// Suppresses the "this error originates in the macro" note when a diagnostic points at this
853+
/// macro.
854+
pub hide_backtrace: bool,
852855
}
853856

854857
impl SyntaxExtension {
@@ -882,6 +885,7 @@ impl SyntaxExtension {
882885
allow_internal_unsafe: false,
883886
local_inner_macros: false,
884887
collapse_debuginfo: false,
888+
hide_backtrace: false,
885889
}
886890
}
887891

@@ -912,6 +916,12 @@ impl SyntaxExtension {
912916
collapse_table[flag as usize][attr as usize]
913917
}
914918

919+
fn get_hide_backtrace(attrs: &[hir::Attribute]) -> bool {
920+
// FIXME(estebank): instead of reusing `#[rustc_diagnostic_item]` as a proxy, introduce a
921+
// new attribute purely for this under the `#[diagnostic]` namespace.
922+
ast::attr::find_by_name(attrs, sym::rustc_diagnostic_item).is_some()
923+
}
924+
915925
/// Constructs a syntax extension with the given properties
916926
/// and other properties converted from attributes.
917927
pub fn new(
@@ -948,6 +958,7 @@ impl SyntaxExtension {
948958
// Not a built-in macro
949959
None => (None, helper_attrs),
950960
};
961+
let hide_backtrace = builtin_name.is_some() || Self::get_hide_backtrace(attrs);
951962

952963
let stability = find_attr!(attrs, AttributeKind::Stability { stability, .. } => *stability);
953964

@@ -982,6 +993,7 @@ impl SyntaxExtension {
982993
allow_internal_unsafe,
983994
local_inner_macros,
984995
collapse_debuginfo,
996+
hide_backtrace,
985997
}
986998
}
987999

@@ -1061,7 +1073,7 @@ impl SyntaxExtension {
10611073
self.allow_internal_unsafe,
10621074
self.local_inner_macros,
10631075
self.collapse_debuginfo,
1064-
self.builtin_name.is_some(),
1076+
self.hide_backtrace,
10651077
)
10661078
}
10671079
}

compiler/rustc_interface/src/passes.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_ast::{self as ast, CRATE_NODE_ID};
99
use rustc_attr_parsing::{AttributeParser, Early, ShouldEmit};
1010
use rustc_codegen_ssa::traits::CodegenBackend;
1111
use rustc_codegen_ssa::{CodegenResults, CrateInfo};
12+
use rustc_data_structures::indexmap::IndexMap;
1213
use rustc_data_structures::jobserver::Proxy;
1314
use rustc_data_structures::steal::Steal;
1415
use rustc_data_structures::sync::{AppendOnlyIndexVec, FreezeLock, WorkerLocal};
@@ -584,7 +585,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
584585
let result: io::Result<()> = try {
585586
// Build a list of files used to compile the output and
586587
// write Makefile-compatible dependency rules
587-
let mut files: Vec<(String, u64, Option<SourceFileHash>)> = sess
588+
let mut files: IndexMap<String, (u64, Option<SourceFileHash>)> = sess
588589
.source_map()
589590
.files()
590591
.iter()
@@ -593,10 +594,12 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
593594
.map(|fmap| {
594595
(
595596
escape_dep_filename(&fmap.name.prefer_local_unconditionally().to_string()),
596-
// This needs to be unnormalized,
597-
// as external tools wouldn't know how rustc normalizes them
598-
fmap.unnormalized_source_len as u64,
599-
fmap.checksum_hash,
597+
(
598+
// This needs to be unnormalized,
599+
// as external tools wouldn't know how rustc normalizes them
600+
fmap.unnormalized_source_len as u64,
601+
fmap.checksum_hash,
602+
),
600603
)
601604
})
602605
.collect();
@@ -614,7 +617,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
614617
fn hash_iter_files<P: AsRef<Path>>(
615618
it: impl Iterator<Item = P>,
616619
checksum_hash_algo: Option<SourceFileHashAlgorithm>,
617-
) -> impl Iterator<Item = (P, u64, Option<SourceFileHash>)> {
620+
) -> impl Iterator<Item = (P, (u64, Option<SourceFileHash>))> {
618621
it.map(move |path| {
619622
match checksum_hash_algo.and_then(|algo| {
620623
fs::File::open(path.as_ref())
@@ -630,8 +633,8 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
630633
})
631634
.ok()
632635
}) {
633-
Some((file_len, checksum)) => (path, file_len, Some(checksum)),
634-
None => (path, 0, None),
636+
Some((file_len, checksum)) => (path, (file_len, Some(checksum))),
637+
None => (path, (0, None)),
635638
}
636639
})
637640
}
@@ -705,18 +708,14 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
705708
file,
706709
"{}: {}\n",
707710
path.display(),
708-
files
709-
.iter()
710-
.map(|(path, _file_len, _checksum_hash_algo)| path.as_str())
711-
.intersperse(" ")
712-
.collect::<String>()
711+
files.keys().map(String::as_str).intersperse(" ").collect::<String>()
713712
)?;
714713
}
715714

716715
// Emit a fake target for each input file to the compilation. This
717716
// prevents `make` from spitting out an error if a file is later
718717
// deleted. For more info see #28735
719-
for (path, _file_len, _checksum_hash_algo) in &files {
718+
for path in files.keys() {
720719
writeln!(file, "{path}:")?;
721720
}
722721

@@ -745,7 +744,7 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
745744
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
746745
files
747746
.iter()
748-
.filter_map(|(path, file_len, hash_algo)| {
747+
.filter_map(|(path, (file_len, hash_algo))| {
749748
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
750749
})
751750
.try_for_each(|(path, file_len, checksum_hash)| {

compiler/rustc_public/src/abi.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,27 @@ pub enum VariantsShape {
188188
tag: Scalar,
189189
tag_encoding: TagEncoding,
190190
tag_field: usize,
191-
variants: Vec<LayoutShape>,
191+
variants: Vec<VariantFields>,
192192
},
193193
}
194194

195+
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
196+
pub struct VariantFields {
197+
/// Offsets for the first byte of each field,
198+
/// ordered to match the source definition order.
199+
/// I.e.: It follows the same order as [super::ty::VariantDef::fields()].
200+
/// This vector does not go in increasing order.
201+
pub offsets: Vec<Size>,
202+
}
203+
204+
impl VariantFields {
205+
pub fn fields_by_offset_order(&self) -> Vec<FieldIdx> {
206+
let mut indices = (0..self.offsets.len()).collect::<Vec<_>>();
207+
indices.sort_by_key(|idx| self.offsets[*idx]);
208+
indices
209+
}
210+
}
211+
195212
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
196213
pub enum TagEncoding {
197214
/// The tag directly stores the discriminant, but possibly with a smaller layout

compiler/rustc_public/src/unstable/convert/stable/abi.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_target::callconv;
1111
use crate::abi::{
1212
AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength,
1313
IntegerType, Layout, LayoutShape, PassMode, Primitive, ReprFlags, ReprOptions, Scalar,
14-
TagEncoding, TyAndLayout, ValueAbi, VariantsShape, WrappingRange,
14+
TagEncoding, TyAndLayout, ValueAbi, VariantFields, VariantsShape, WrappingRange,
1515
};
1616
use crate::compiler_interface::BridgeTys;
1717
use crate::target::MachineSize as Size;
@@ -213,7 +213,15 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Variants<rustc_abi::FieldIdx, rustc_abi::
213213
tag: tag.stable(tables, cx),
214214
tag_encoding: tag_encoding.stable(tables, cx),
215215
tag_field: tag_field.stable(tables, cx),
216-
variants: variants.iter().as_slice().stable(tables, cx),
216+
variants: variants
217+
.iter()
218+
.map(|v| match &v.fields {
219+
rustc_abi::FieldsShape::Arbitrary { offsets, .. } => VariantFields {
220+
offsets: offsets.iter().as_slice().stable(tables, cx),
221+
},
222+
_ => panic!("variant layout should be Arbitrary"),
223+
})
224+
.collect(),
217225
}
218226
}
219227
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,8 @@ supported_targets! {
17091709
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
17101710
("aarch64_be-unknown-none-softfloat", aarch64_be_unknown_none_softfloat),
17111711
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
1712+
("aarch64v8r-unknown-none", aarch64v8r_unknown_none),
1713+
("aarch64v8r-unknown-none-softfloat", aarch64v8r_unknown_none_softfloat),
17121714

17131715
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
17141716

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use crate::spec::{
2+
Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
3+
TargetMetadata, TargetOptions,
4+
};
5+
6+
pub(crate) fn target() -> Target {
7+
let opts = TargetOptions {
8+
// based off the aarch64-unknown-none target at time of addition
9+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
10+
linker: Some("rust-lld".into()),
11+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
12+
relocation_model: RelocModel::Static,
13+
disable_redzone: true,
14+
max_atomic_width: Some(128),
15+
stack_probes: StackProbeType::Inline,
16+
panic_strategy: PanicStrategy::Abort,
17+
default_uwtable: true,
18+
19+
// deviations from aarch64-unknown-none: `+v8a` -> `+v8r`; `+v8r` implies `+neon`
20+
features: "+v8r,+strict-align".into(),
21+
..Default::default()
22+
};
23+
Target {
24+
llvm_target: "aarch64-unknown-none".into(),
25+
metadata: TargetMetadata {
26+
description: Some("Bare Armv8-R AArch64, hardfloat".into()),
27+
tier: Some(3),
28+
host_tools: Some(false),
29+
std: Some(false),
30+
},
31+
pointer_width: 64,
32+
// $ clang-21 -S -emit-llvm -target aarch64 -mcpu=cortex-r82 stub.c
33+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
34+
arch: Arch::AArch64,
35+
options: opts,
36+
}
37+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use crate::spec::{
2+
Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType,
3+
Target, TargetMetadata, TargetOptions,
4+
};
5+
6+
pub(crate) fn target() -> Target {
7+
let opts = TargetOptions {
8+
abi: Abi::SoftFloat,
9+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
10+
linker: Some("rust-lld".into()),
11+
relocation_model: RelocModel::Static,
12+
disable_redzone: true,
13+
max_atomic_width: Some(128),
14+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
15+
stack_probes: StackProbeType::Inline,
16+
panic_strategy: PanicStrategy::Abort,
17+
default_uwtable: true,
18+
19+
// deviations from aarch64-unknown-none: `+v8a` -> `+v8r`
20+
features: "+v8r,+strict-align,-neon".into(),
21+
..Default::default()
22+
};
23+
Target {
24+
llvm_target: "aarch64-unknown-none".into(),
25+
metadata: TargetMetadata {
26+
description: Some("Bare Armv8-R AArch64, softfloat".into()),
27+
tier: Some(3),
28+
host_tools: Some(false),
29+
std: Some(false),
30+
},
31+
pointer_width: 64,
32+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
33+
arch: Arch::AArch64,
34+
options: opts,
35+
}
36+
}

library/core/src/os/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! OS-specific functionality.
22
33
#![unstable(feature = "darwin_objc", issue = "145496")]
4+
#![allow(missing_docs)]
45

56
#[cfg(all(
67
doc,

src/bootstrap/src/core/sanity.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
4646
"armv6-none-eabi",
4747
"armv6-none-eabihf",
4848
"thumbv6-none-eabi",
49+
"aarch64v8r-unknown-none",
50+
"aarch64v8r-unknown-none-softfloat",
4951
];
5052

5153
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

0 commit comments

Comments
 (0)