Skip to content

Commit af432da

Browse files
committed
Auto merge of #151547 - JonathanBrouwer:rollup-5dGyY3j, r=JonathanBrouwer
Rollup of 7 pull requests Successful merges: - #149848 (Use allocator_shim_contents in allocator_shim_symbols) - #150556 (Add Tier 3 Thumb-mode targets for Armv7-A, Armv7-R and Armv8-R) - #151259 (Fix is_ascii performance regression on AVX-512 CPUs when compiling with -C target-cpu=native) - #151482 (Add "Skip to main content" link for keyboard navigation in rustdoc) - #151505 (Various refactors to the proc_macro bridge) - #151517 (Enable reproducible binary builds with debuginfo on Linux) - #151540 (Tweak bounds check in `DepNodeColorMap.get`) r? @ghost
2 parents d222ddc + 20ae8d8 commit af432da

44 files changed

Lines changed: 835 additions & 712 deletions

File tree

Some content is hidden

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

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,9 +1827,9 @@ fn exported_symbols_for_non_proc_macro(
18271827
// Mark allocator shim symbols as exported only if they were generated.
18281828
if export_threshold == SymbolExportLevel::Rust
18291829
&& needs_allocator_shim_for_linking(tcx.dependency_formats(()), crate_type)
1830-
&& tcx.allocator_kind(()).is_some()
1830+
&& let Some(kind) = tcx.allocator_kind(())
18311831
{
1832-
symbols.extend(allocator_shim_symbols(tcx));
1832+
symbols.extend(allocator_shim_symbols(tcx, kind));
18331833
}
18341834

18351835
symbols

compiler/rustc_codegen_ssa/src/back/lto.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ pub(super) fn exported_symbols_for_lto(
118118
}
119119

120120
// Mark allocator shim symbols as exported only if they were generated.
121-
if export_threshold == SymbolExportLevel::Rust && allocator_kind_for_codegen(tcx).is_some() {
122-
symbols_below_threshold.extend(allocator_shim_symbols(tcx).map(|(name, _kind)| name));
121+
if export_threshold == SymbolExportLevel::Rust
122+
&& let Some(kind) = allocator_kind_for_codegen(tcx)
123+
{
124+
symbols_below_threshold.extend(allocator_shim_symbols(tcx, kind).map(|(name, _kind)| name));
123125
}
124126

125127
symbols_below_threshold

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::collections::hash_map::Entry::*;
22

33
use rustc_abi::{CanonAbi, X86Call};
4-
use rustc_ast::expand::allocator::{
5-
ALLOC_ERROR_HANDLER, ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name,
6-
};
4+
use rustc_ast::expand::allocator::{AllocatorKind, NO_ALLOC_SHIM_IS_UNSTABLE, global_fn_name};
75
use rustc_data_structures::unord::UnordMap;
86
use rustc_hir::def::DefKind;
97
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE, LocalDefId};
@@ -21,6 +19,7 @@ use rustc_target::spec::{Arch, Os, TlsModel};
2119
use tracing::debug;
2220

2321
use crate::back::symbol_export;
22+
use crate::base::allocator_shim_contents;
2423

2524
fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
2625
crates_export_threshold(tcx.crate_types())
@@ -490,14 +489,12 @@ pub(crate) fn provide(providers: &mut Providers) {
490489

491490
pub(crate) fn allocator_shim_symbols(
492491
tcx: TyCtxt<'_>,
492+
kind: AllocatorKind,
493493
) -> impl Iterator<Item = (String, SymbolExportKind)> {
494-
ALLOCATOR_METHODS
495-
.iter()
494+
allocator_shim_contents(tcx, kind)
495+
.into_iter()
496496
.map(move |method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str()))
497-
.chain([
498-
mangle_internal_symbol(tcx, global_fn_name(ALLOC_ERROR_HANDLER).as_str()),
499-
mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE),
500-
])
497+
.chain([mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE)])
501498
.map(move |symbol_name| {
502499
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));
503500

compiler/rustc_expand/src/proc_macro_server.rs

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ impl ToInternal<rustc_errors::Level> for Level {
431431
}
432432
}
433433

434-
pub(crate) struct FreeFunctions;
435-
436434
pub(crate) struct Rustc<'a, 'b> {
437435
ecx: &'a mut ExtCtxt<'b>,
438436
def_site: Span,
@@ -461,13 +459,28 @@ impl<'a, 'b> Rustc<'a, 'b> {
461459
}
462460

463461
impl server::Types for Rustc<'_, '_> {
464-
type FreeFunctions = FreeFunctions;
465462
type TokenStream = TokenStream;
466463
type Span = Span;
467464
type Symbol = Symbol;
468465
}
469466

470-
impl server::FreeFunctions for Rustc<'_, '_> {
467+
impl server::Server for Rustc<'_, '_> {
468+
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
469+
ExpnGlobals {
470+
def_site: self.def_site,
471+
call_site: self.call_site,
472+
mixed_site: self.mixed_site,
473+
}
474+
}
475+
476+
fn intern_symbol(string: &str) -> Self::Symbol {
477+
Symbol::intern(string)
478+
}
479+
480+
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
481+
f(symbol.as_str())
482+
}
483+
471484
fn injected_env_var(&mut self, var: &str) -> Option<String> {
472485
self.ecx.sess.opts.logical_env.get(var).cloned()
473486
}
@@ -552,14 +565,20 @@ impl server::FreeFunctions for Rustc<'_, '_> {
552565
}
553566
diag.emit();
554567
}
555-
}
556568

557-
impl server::TokenStream for Rustc<'_, '_> {
558-
fn is_empty(&mut self, stream: &Self::TokenStream) -> bool {
569+
fn ts_drop(&mut self, stream: Self::TokenStream) {
570+
drop(stream);
571+
}
572+
573+
fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
574+
stream.clone()
575+
}
576+
577+
fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
559578
stream.is_empty()
560579
}
561580

562-
fn from_str(&mut self, src: &str) -> Self::TokenStream {
581+
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
563582
unwrap_or_emit_fatal(source_str_to_stream(
564583
self.psess(),
565584
FileName::proc_macro_source_code(src),
@@ -568,11 +587,11 @@ impl server::TokenStream for Rustc<'_, '_> {
568587
))
569588
}
570589

571-
fn to_string(&mut self, stream: &Self::TokenStream) -> String {
590+
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
572591
pprust::tts_to_string(stream)
573592
}
574593

575-
fn expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
594+
fn ts_expand_expr(&mut self, stream: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
576595
// Parse the expression from our tokenstream.
577596
let expr: PResult<'_, _> = try {
578597
let mut p = Parser::new(self.psess(), stream.clone(), Some("proc_macro expand expr"));
@@ -633,14 +652,14 @@ impl server::TokenStream for Rustc<'_, '_> {
633652
}
634653
}
635654

636-
fn from_token_tree(
655+
fn ts_from_token_tree(
637656
&mut self,
638657
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
639658
) -> Self::TokenStream {
640659
Self::TokenStream::new((tree, &mut *self).to_internal().into_iter().collect::<Vec<_>>())
641660
}
642661

643-
fn concat_trees(
662+
fn ts_concat_trees(
644663
&mut self,
645664
base: Option<Self::TokenStream>,
646665
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
@@ -654,7 +673,7 @@ impl server::TokenStream for Rustc<'_, '_> {
654673
stream
655674
}
656675

657-
fn concat_streams(
676+
fn ts_concat_streams(
658677
&mut self,
659678
base: Option<Self::TokenStream>,
660679
streams: Vec<Self::TokenStream>,
@@ -666,24 +685,22 @@ impl server::TokenStream for Rustc<'_, '_> {
666685
stream
667686
}
668687

669-
fn into_trees(
688+
fn ts_into_trees(
670689
&mut self,
671690
stream: Self::TokenStream,
672691
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> {
673692
FromInternal::from_internal((stream, self))
674693
}
675-
}
676694

677-
impl server::Span for Rustc<'_, '_> {
678-
fn debug(&mut self, span: Self::Span) -> String {
695+
fn span_debug(&mut self, span: Self::Span) -> String {
679696
if self.ecx.ecfg.span_debug {
680697
format!("{span:?}")
681698
} else {
682699
format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
683700
}
684701
}
685702

686-
fn file(&mut self, span: Self::Span) -> String {
703+
fn span_file(&mut self, span: Self::Span) -> String {
687704
self.psess()
688705
.source_map()
689706
.lookup_char_pos(span.lo())
@@ -693,7 +710,7 @@ impl server::Span for Rustc<'_, '_> {
693710
.to_string()
694711
}
695712

696-
fn local_file(&mut self, span: Self::Span) -> Option<String> {
713+
fn span_local_file(&mut self, span: Self::Span) -> Option<String> {
697714
self.psess()
698715
.source_map()
699716
.lookup_char_pos(span.lo())
@@ -708,41 +725,41 @@ impl server::Span for Rustc<'_, '_> {
708725
})
709726
}
710727

711-
fn parent(&mut self, span: Self::Span) -> Option<Self::Span> {
728+
fn span_parent(&mut self, span: Self::Span) -> Option<Self::Span> {
712729
span.parent_callsite()
713730
}
714731

715-
fn source(&mut self, span: Self::Span) -> Self::Span {
732+
fn span_source(&mut self, span: Self::Span) -> Self::Span {
716733
span.source_callsite()
717734
}
718735

719-
fn byte_range(&mut self, span: Self::Span) -> Range<usize> {
736+
fn span_byte_range(&mut self, span: Self::Span) -> Range<usize> {
720737
let source_map = self.psess().source_map();
721738

722739
let relative_start_pos = source_map.lookup_byte_offset(span.lo()).pos;
723740
let relative_end_pos = source_map.lookup_byte_offset(span.hi()).pos;
724741

725742
Range { start: relative_start_pos.0 as usize, end: relative_end_pos.0 as usize }
726743
}
727-
fn start(&mut self, span: Self::Span) -> Self::Span {
744+
fn span_start(&mut self, span: Self::Span) -> Self::Span {
728745
span.shrink_to_lo()
729746
}
730747

731-
fn end(&mut self, span: Self::Span) -> Self::Span {
748+
fn span_end(&mut self, span: Self::Span) -> Self::Span {
732749
span.shrink_to_hi()
733750
}
734751

735-
fn line(&mut self, span: Self::Span) -> usize {
752+
fn span_line(&mut self, span: Self::Span) -> usize {
736753
let loc = self.psess().source_map().lookup_char_pos(span.lo());
737754
loc.line
738755
}
739756

740-
fn column(&mut self, span: Self::Span) -> usize {
757+
fn span_column(&mut self, span: Self::Span) -> usize {
741758
let loc = self.psess().source_map().lookup_char_pos(span.lo());
742759
loc.col.to_usize() + 1
743760
}
744761

745-
fn join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span> {
762+
fn span_join(&mut self, first: Self::Span, second: Self::Span) -> Option<Self::Span> {
746763
let self_loc = self.psess().source_map().lookup_char_pos(first.lo());
747764
let other_loc = self.psess().source_map().lookup_char_pos(second.lo());
748765

@@ -753,7 +770,7 @@ impl server::Span for Rustc<'_, '_> {
753770
Some(first.to(second))
754771
}
755772

756-
fn subspan(
773+
fn span_subspan(
757774
&mut self,
758775
span: Self::Span,
759776
start: Bound<usize>,
@@ -789,11 +806,11 @@ impl server::Span for Rustc<'_, '_> {
789806
Some(span.with_lo(new_lo).with_hi(new_hi))
790807
}
791808

792-
fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
809+
fn span_resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
793810
span.with_ctxt(at.ctxt())
794811
}
795812

796-
fn source_text(&mut self, span: Self::Span) -> Option<String> {
813+
fn span_source_text(&mut self, span: Self::Span) -> Option<String> {
797814
self.psess().source_map().span_to_snippet(span).ok()
798815
}
799816

@@ -821,41 +838,21 @@ impl server::Span for Rustc<'_, '_> {
821838
/// span from the metadata of `my_proc_macro` (which we have access to,
822839
/// since we've loaded `my_proc_macro` from disk in order to execute it).
823840
/// In this way, we have obtained a span pointing into `my_proc_macro`
824-
fn save_span(&mut self, span: Self::Span) -> usize {
841+
fn span_save_span(&mut self, span: Self::Span) -> usize {
825842
self.psess().save_proc_macro_span(span)
826843
}
827844

828-
fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span {
845+
fn span_recover_proc_macro_span(&mut self, id: usize) -> Self::Span {
829846
let (resolver, krate, def_site) = (&*self.ecx.resolver, self.krate, self.def_site);
830847
*self.rebased_spans.entry(id).or_insert_with(|| {
831848
// FIXME: `SyntaxContext` for spans from proc macro crates is lost during encoding,
832849
// replace it with a def-site context until we are encoding it properly.
833850
resolver.get_proc_macro_quoted_span(krate, id).with_ctxt(def_site.ctxt())
834851
})
835852
}
836-
}
837853

838-
impl server::Symbol for Rustc<'_, '_> {
839-
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
854+
fn symbol_normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
840855
let sym = nfc_normalize(string);
841856
if rustc_lexer::is_ident(sym.as_str()) { Ok(sym) } else { Err(()) }
842857
}
843858
}
844-
845-
impl server::Server for Rustc<'_, '_> {
846-
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
847-
ExpnGlobals {
848-
def_site: self.def_site,
849-
call_site: self.call_site,
850-
mixed_site: self.mixed_site,
851-
}
852-
}
853-
854-
fn intern_symbol(string: &str) -> Self::Symbol {
855-
Symbol::intern(string)
856-
}
857-
858-
fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
859-
f(symbol.as_str())
860-
}
861-
}

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ impl DepNodeColorMap {
13961396
let value = self.values[index].load(Ordering::Acquire);
13971397
// Green is by far the most common case. Check for that first so we can succeed with a
13981398
// single comparison.
1399-
if value < COMPRESSED_RED {
1399+
if value <= DepNodeIndex::MAX_AS_U32 {
14001400
DepNodeColor::Green(DepNodeIndex::from_u32(value))
14011401
} else if value == COMPRESSED_RED {
14021402
DepNodeColor::Red

compiler/rustc_target/src/spec/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,8 +1596,11 @@ supported_targets! {
15961596
("armebv7r-none-eabi", armebv7r_none_eabi),
15971597
("armebv7r-none-eabihf", armebv7r_none_eabihf),
15981598
("armv7r-none-eabi", armv7r_none_eabi),
1599+
("thumbv7r-none-eabi", thumbv7r_none_eabi),
15991600
("armv7r-none-eabihf", armv7r_none_eabihf),
1601+
("thumbv7r-none-eabihf", thumbv7r_none_eabihf),
16001602
("armv8r-none-eabihf", armv8r_none_eabihf),
1603+
("thumbv8r-none-eabihf", thumbv8r_none_eabihf),
16011604

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

@@ -1649,7 +1652,9 @@ supported_targets! {
16491652
("thumbv8m.main-none-eabihf", thumbv8m_main_none_eabihf),
16501653

16511654
("armv7a-none-eabi", armv7a_none_eabi),
1655+
("thumbv7a-none-eabi", thumbv7a_none_eabi),
16521656
("armv7a-none-eabihf", armv7a_none_eabihf),
1657+
("thumbv7a-none-eabihf", thumbv7a_none_eabihf),
16531658
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
16541659
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),
16551660
("armv7a-vex-v5", armv7a_vex_v5),

0 commit comments

Comments
 (0)