Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
03fa11a
Remove a couple of unnecessary impls
bjorn3 Oct 3, 2025
c65076a
Handle FreeFunctions outside with_api_handle_types
bjorn3 Oct 3, 2025
5dd7c0b
Rationalise the Armv7-A, Armv7-R and Armv8-R bare-metal target configs
thejpster Dec 31, 2025
96647dd
Add Thumb-mode targets for Armv7-R, Armv7-A and Armv8-R.
thejpster Dec 31, 2025
fb05cac
Update SUMMARY.md too
thejpster Jan 1, 2026
1652f3f
Expand with_api_handle_types
bjorn3 Oct 3, 2025
d3b5f72
Move all bridge methods into a single type
bjorn3 Jan 22, 2026
31c696d
Various simplifications after moving all bridge methods to a single type
bjorn3 Jan 22, 2026
5c2052a
Merge FreeFunctions trait into Server trait
bjorn3 Jan 22, 2026
44fcd04
Get rid of MarkedTypes
bjorn3 Oct 3, 2025
76f9a90
Use rustc_proc_macro in rust-analyzer-proc-macro-srv
bjorn3 Jan 22, 2026
0a2bb4b
Ensure armv7a-none-eabi.md mentions all four targets
thejpster Jan 22, 2026
19d1be5
Ensure armv7r-none-eabi.md mentions all four targets
thejpster Jan 22, 2026
fa526c4
Update armv8r-none-eabi.md - note both targets are hardfloat
thejpster Jan 22, 2026
ff9c5cf
Enable reproducible binary builds with debuginfo on Linux
paradoxicalguy Jan 22, 2026
1e8ffd9
Removed comment on reproducibility issue #89911
paradoxicalguy Jan 23, 2026
78afe87
Add 'Skip to main content' link for keyboard navigation in rustdoc
ThanhNguyxn Jan 23, 2026
e47138f
Fix review comments
bjorn3 Jan 23, 2026
f31ee2d
Rollup merge of #150556 - thejpster:add-thumbv7a-thumbv7r-thumbv8r, r…
JonathanBrouwer Jan 23, 2026
d8fe27f
Rollup merge of #151482 - ThanhNguyxn:fix/rustdoc-skip-nav, r=Guillau…
JonathanBrouwer Jan 23, 2026
e0a2eee
Rollup merge of #151505 - bjorn3:proc_macro_refactors, r=petrochenkov
JonathanBrouwer Jan 23, 2026
ca52966
Rollup merge of #151517 - paradoxicalguy:enable-debuginfo-tests-linux…
JonathanBrouwer Jan 23, 2026
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
103 changes: 50 additions & 53 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@ impl ToInternal<rustc_errors::Level> for Level {
}
}

pub(crate) struct FreeFunctions;

pub(crate) struct Rustc<'a, 'b> {
ecx: &'a mut ExtCtxt<'b>,
def_site: Span,
Expand Down Expand Up @@ -461,13 +459,28 @@ impl<'a, 'b> Rustc<'a, 'b> {
}

impl server::Types for Rustc<'_, '_> {
type FreeFunctions = FreeFunctions;
type TokenStream = TokenStream;
type Span = Span;
type Symbol = Symbol;
}

impl server::FreeFunctions for Rustc<'_, '_> {
impl server::Server for Rustc<'_, '_> {
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
ExpnGlobals {
def_site: self.def_site,
call_site: self.call_site,
mixed_site: self.mixed_site,
}
}

fn intern_symbol(string: &str) -> Self::Symbol {
Symbol::intern(string)
}

fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
f(symbol.as_str())
}

fn injected_env_var(&mut self, var: &str) -> Option<String> {
self.ecx.sess.opts.logical_env.get(var).cloned()
}
Expand Down Expand Up @@ -552,14 +565,20 @@ impl server::FreeFunctions for Rustc<'_, '_> {
}
diag.emit();
}
}

impl server::TokenStream for Rustc<'_, '_> {
fn is_empty(&mut self, stream: &Self::TokenStream) -> bool {
fn ts_drop(&mut self, stream: Self::TokenStream) {
drop(stream);
}

fn ts_clone(&mut self, stream: &Self::TokenStream) -> Self::TokenStream {
stream.clone()
}

fn ts_is_empty(&mut self, stream: &Self::TokenStream) -> bool {
stream.is_empty()
}

fn from_str(&mut self, src: &str) -> Self::TokenStream {
fn ts_from_str(&mut self, src: &str) -> Self::TokenStream {
unwrap_or_emit_fatal(source_str_to_stream(
self.psess(),
FileName::proc_macro_source_code(src),
Expand All @@ -568,11 +587,11 @@ impl server::TokenStream for Rustc<'_, '_> {
))
}

fn to_string(&mut self, stream: &Self::TokenStream) -> String {
fn ts_to_string(&mut self, stream: &Self::TokenStream) -> String {
pprust::tts_to_string(stream)
}

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

fn from_token_tree(
fn ts_from_token_tree(
&mut self,
tree: TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
) -> Self::TokenStream {
Self::TokenStream::new((tree, &mut *self).to_internal().into_iter().collect::<Vec<_>>())
}

fn concat_trees(
fn ts_concat_trees(
&mut self,
base: Option<Self::TokenStream>,
trees: Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>>,
Expand All @@ -654,7 +673,7 @@ impl server::TokenStream for Rustc<'_, '_> {
stream
}

fn concat_streams(
fn ts_concat_streams(
&mut self,
base: Option<Self::TokenStream>,
streams: Vec<Self::TokenStream>,
Expand All @@ -666,24 +685,22 @@ impl server::TokenStream for Rustc<'_, '_> {
stream
}

fn into_trees(
fn ts_into_trees(
&mut self,
stream: Self::TokenStream,
) -> Vec<TokenTree<Self::TokenStream, Self::Span, Self::Symbol>> {
FromInternal::from_internal((stream, self))
}
}

impl server::Span for Rustc<'_, '_> {
fn debug(&mut self, span: Self::Span) -> String {
fn span_debug(&mut self, span: Self::Span) -> String {
if self.ecx.ecfg.span_debug {
format!("{span:?}")
} else {
format!("{:?} bytes({}..{})", span.ctxt(), span.lo().0, span.hi().0)
}
}

fn file(&mut self, span: Self::Span) -> String {
fn span_file(&mut self, span: Self::Span) -> String {
self.psess()
.source_map()
.lookup_char_pos(span.lo())
Expand All @@ -693,7 +710,7 @@ impl server::Span for Rustc<'_, '_> {
.to_string()
}

fn local_file(&mut self, span: Self::Span) -> Option<String> {
fn span_local_file(&mut self, span: Self::Span) -> Option<String> {
self.psess()
.source_map()
.lookup_char_pos(span.lo())
Expand All @@ -708,41 +725,41 @@ impl server::Span for Rustc<'_, '_> {
})
}

fn parent(&mut self, span: Self::Span) -> Option<Self::Span> {
fn span_parent(&mut self, span: Self::Span) -> Option<Self::Span> {
span.parent_callsite()
}

fn source(&mut self, span: Self::Span) -> Self::Span {
fn span_source(&mut self, span: Self::Span) -> Self::Span {
span.source_callsite()
}

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

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

Range { start: relative_start_pos.0 as usize, end: relative_end_pos.0 as usize }
}
fn start(&mut self, span: Self::Span) -> Self::Span {
fn span_start(&mut self, span: Self::Span) -> Self::Span {
span.shrink_to_lo()
}

fn end(&mut self, span: Self::Span) -> Self::Span {
fn span_end(&mut self, span: Self::Span) -> Self::Span {
span.shrink_to_hi()
}

fn line(&mut self, span: Self::Span) -> usize {
fn span_line(&mut self, span: Self::Span) -> usize {
let loc = self.psess().source_map().lookup_char_pos(span.lo());
loc.line
}

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

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

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

fn subspan(
fn span_subspan(
&mut self,
span: Self::Span,
start: Bound<usize>,
Expand Down Expand Up @@ -789,11 +806,11 @@ impl server::Span for Rustc<'_, '_> {
Some(span.with_lo(new_lo).with_hi(new_hi))
}

fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
fn span_resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
span.with_ctxt(at.ctxt())
}

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

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

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

impl server::Symbol for Rustc<'_, '_> {
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
fn symbol_normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
let sym = nfc_normalize(string);
if rustc_lexer::is_ident(sym.as_str()) { Ok(sym) } else { Err(()) }
}
}

impl server::Server for Rustc<'_, '_> {
fn globals(&mut self) -> ExpnGlobals<Self::Span> {
ExpnGlobals {
def_site: self.def_site,
call_site: self.call_site,
mixed_site: self.mixed_site,
}
}

fn intern_symbol(string: &str) -> Self::Symbol {
Symbol::intern(string)
}

fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
f(symbol.as_str())
}
}
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,11 @@ supported_targets! {
("armebv7r-none-eabi", armebv7r_none_eabi),
("armebv7r-none-eabihf", armebv7r_none_eabihf),
("armv7r-none-eabi", armv7r_none_eabi),
("thumbv7r-none-eabi", thumbv7r_none_eabi),
("armv7r-none-eabihf", armv7r_none_eabihf),
("thumbv7r-none-eabihf", thumbv7r_none_eabihf),
("armv8r-none-eabihf", armv8r_none_eabihf),
("thumbv8r-none-eabihf", thumbv8r_none_eabihf),

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

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

("armv7a-none-eabi", armv7a_none_eabi),
("thumbv7a-none-eabi", thumbv7a_none_eabi),
("armv7a-none-eabihf", armv7a_none_eabihf),
("thumbv7a-none-eabihf", thumbv7a_none_eabihf),
("armv7a-nuttx-eabi", armv7a_nuttx_eabi),
("armv7a-nuttx-eabihf", armv7a_nuttx_eabihf),
("armv7a-vex-v5", armv7a_vex_v5),
Expand Down
45 changes: 10 additions & 35 deletions compiler/rustc_target/src/spec/targets/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
// Generic ARMv7-A target for bare-metal code - floating point disabled
//
// This is basically the `armv7-unknown-linux-gnueabi` target with some changes
// (listed below) to bring it closer to the bare-metal `thumb` & `aarch64`
// targets:
//
// - `TargetOptions.features`: added `+strict-align`. rationale: unaligned
// memory access is disabled on boot on these cores
// - linker changed to LLD. rationale: C is not strictly needed to build
// bare-metal binaries (the `gcc` linker has the advantage that it knows where C
// libraries and crt*.o are but it's not much of an advantage here); LLD is also
// faster
// - `panic_strategy` set to `abort`. rationale: matches `thumb` targets
// - `relocation-model` set to `static`; also no PIE, no relro and no dynamic
// linking. rationale: matches `thumb` targets
// Targets the Little-endian Cortex-A8 (and similar) processors (ARMv7-A)

use crate::spec::{
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata,
TargetOptions,
};
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: Abi::Eabi,
llvm_floatabi: Some(FloatAbi::Soft),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
c_enum_min_bits: Some(8),
has_thumb_interworking: true,
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabi".into(),
metadata: TargetMetadata {
Expand All @@ -46,6 +14,13 @@ pub(crate) fn target() -> Target {
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: Arch::Arm,
options: opts,
options: TargetOptions {
abi: Abi::Eabi,
llvm_floatabi: Some(FloatAbi::Soft),
features: "+soft-float,-neon,+strict-align".into(),
max_atomic_width: Some(64),
has_thumb_interworking: true,
..base::arm_none::opts()
},
}
}
37 changes: 10 additions & 27 deletions compiler/rustc_target/src/spec/targets/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
// Generic ARMv7-A target for bare-metal code - floating point enabled (assumes
// FPU is present and emits FPU instructions)
//
// This is basically the `armv7-unknown-linux-gnueabihf` target with some
// changes (list in `armv7a_none_eabi.rs`) to bring it closer to the bare-metal
// `thumb` & `aarch64` targets.
// Targets the Little-endian Cortex-A8 (and similar) processors (ARMv7-A)

use crate::spec::{
Abi, Arch, Cc, FloatAbi, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata,
TargetOptions,
};
use crate::spec::{Abi, Arch, FloatAbi, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let opts = TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
linker: Some("rust-lld".into()),
features: "+v7,+vfp3d16,+thumb2,-neon,+strict-align".into(),
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
panic_strategy: PanicStrategy::Abort,
emit_debug_gdb_scripts: false,
// GCC defaults to 8 for arm-none here.
c_enum_min_bits: Some(8),
has_thumb_interworking: true,
..Default::default()
};
Target {
llvm_target: "armv7a-none-eabihf".into(),
metadata: TargetMetadata {
Expand All @@ -38,6 +14,13 @@ pub(crate) fn target() -> Target {
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: Arch::Arm,
options: opts,
options: TargetOptions {
abi: Abi::EabiHf,
llvm_floatabi: Some(FloatAbi::Hard),
features: "+vfp3d16,-neon,+strict-align".into(),
max_atomic_width: Some(64),
has_thumb_interworking: true,
..base::arm_none::opts()
},
}
}
Loading
Loading