Skip to content

Commit bbcc169

Browse files
committedOct 29, 2023
Auto merge of #117336 - workingjubilee:rollup-6negquv, r=workingjubilee
Rollup of 4 pull requests Successful merges: - #117170 (Add support for i586-unknown-netbsd as target.) - #117259 (Declare rustc_target's dependency on object/macho) - #117322 (change default output mode of `BootstrapCommand`) - #117325 (Small ty::print cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2106b63 + 505bc85 commit bbcc169

File tree

9 files changed

+70
-52
lines changed

9 files changed

+70
-52
lines changed
 

‎compiler/rustc_llvm/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,12 @@ fn main() {
258258
{
259259
println!("cargo:rustc-link-lib=z");
260260
} else if target.contains("netbsd") {
261+
// On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat)
262+
// However, LLVM insists on using 64-bit atomics.
263+
// This gives rise to a need to link rust itself with -latomic for these targets
264+
if target.starts_with("i586") || target.starts_with("i686") {
265+
println!("cargo:rustc-link-lib=atomic");
266+
}
261267
println!("cargo:rustc-link-lib=z");
262268
println!("cargo:rustc-link-lib=execinfo");
263269
}

‎compiler/rustc_middle/src/ty/print/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub use self::pretty::*;
1212

1313
pub type PrintError = std::fmt::Error;
1414

15-
// FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`.
16-
#[allow(unused_lifetimes)]
1715
pub trait Print<'tcx, P> {
1816
fn print(&self, cx: &mut P) -> Result<(), PrintError>;
1917
}

‎compiler/rustc_middle/src/ty/print/pretty.rs

+37-47
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ macro_rules! p {
5353
}
5454
macro_rules! define_scoped_cx {
5555
($cx:ident) => {
56-
#[allow(unused_macros)]
5756
macro_rules! scoped_cx {
5857
() => {
5958
$cx
@@ -408,8 +407,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
408407
def_id: DefId,
409408
callers: &mut Vec<DefId>,
410409
) -> Result<bool, PrintError> {
411-
define_scoped_cx!(self);
412-
413410
debug!("try_print_visible_def_path: def_id={:?}", def_id);
414411

415412
// If `def_id` is a direct or injected extern crate, return the
@@ -1868,8 +1865,6 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
18681865
def_id: DefId,
18691866
args: &'tcx [GenericArg<'tcx>],
18701867
) -> Result<(), PrintError> {
1871-
define_scoped_cx!(self);
1872-
18731868
if args.is_empty() {
18741869
match self.try_print_trimmed_def_path(def_id)? {
18751870
true => return Ok(()),
@@ -2401,8 +2396,6 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
24012396
let _ = write!(cx, "{cont}");
24022397
};
24032398

2404-
define_scoped_cx!(self);
2405-
24062399
let possible_names = ('a'..='z').rev().map(|s| Symbol::intern(&format!("'{s}")));
24072400

24082401
let mut available_names = possible_names
@@ -2630,46 +2623,6 @@ where
26302623
}
26312624
}
26322625

2633-
macro_rules! forward_display_to_print {
2634-
($($ty:ty),+) => {
2635-
// Some of the $ty arguments may not actually use 'tcx
2636-
$(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
2637-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2638-
ty::tls::with(|tcx| {
2639-
let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
2640-
tcx.lift(*self)
2641-
.expect("could not lift for printing")
2642-
.print(&mut cx)?;
2643-
f.write_str(&cx.into_buffer())?;
2644-
Ok(())
2645-
})
2646-
}
2647-
})+
2648-
};
2649-
}
2650-
2651-
macro_rules! define_print_and_forward_display {
2652-
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
2653-
define_print!(($self, $cx): $($ty $print)*);
2654-
forward_display_to_print!($($ty),+);
2655-
};
2656-
}
2657-
2658-
macro_rules! define_print {
2659-
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
2660-
$(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
2661-
fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
2662-
#[allow(unused_mut)]
2663-
let mut $cx = $cx;
2664-
define_scoped_cx!($cx);
2665-
let _: () = $print;
2666-
#[allow(unreachable_code)]
2667-
Ok(())
2668-
}
2669-
})+
2670-
};
2671-
}
2672-
26732626
/// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
26742627
/// the trait path. That is, it will print `Trait<U>` instead of
26752628
/// `<T as Trait<U>>`.
@@ -2744,6 +2697,43 @@ pub struct PrintClosureAsImpl<'tcx> {
27442697
pub closure: ty::ClosureArgs<'tcx>,
27452698
}
27462699

2700+
macro_rules! forward_display_to_print {
2701+
($($ty:ty),+) => {
2702+
// Some of the $ty arguments may not actually use 'tcx
2703+
$(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
2704+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2705+
ty::tls::with(|tcx| {
2706+
let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
2707+
tcx.lift(*self)
2708+
.expect("could not lift for printing")
2709+
.print(&mut cx)?;
2710+
f.write_str(&cx.into_buffer())?;
2711+
Ok(())
2712+
})
2713+
}
2714+
})+
2715+
};
2716+
}
2717+
2718+
macro_rules! define_print {
2719+
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
2720+
$(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
2721+
fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
2722+
define_scoped_cx!($cx);
2723+
let _: () = $print;
2724+
Ok(())
2725+
}
2726+
})+
2727+
};
2728+
}
2729+
2730+
macro_rules! define_print_and_forward_display {
2731+
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
2732+
define_print!(($self, $cx): $($ty $print)*);
2733+
forward_display_to_print!($($ty),+);
2734+
};
2735+
}
2736+
27472737
forward_display_to_print! {
27482738
ty::Region<'tcx>,
27492739
Ty<'tcx>,

‎compiler/rustc_target/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ rustc_index = { path = "../rustc_index" }
1919
[dependencies.object]
2020
version = "0.32.0"
2121
default-features = false
22-
features = ["elf"]
22+
features = ["elf", "macho"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use crate::spec::{StackProbeType, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
let mut base = super::netbsd_base::opts();
5+
base.cpu = "pentium".into();
6+
base.max_atomic_width = Some(64);
7+
base.stack_probes = StackProbeType::Call;
8+
9+
Target {
10+
llvm_target: "i586-unknown-netbsdelf".into(),
11+
pointer_width: 32,
12+
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
13+
f64:32:64-f80:32-n8:16:32-S128"
14+
.into(),
15+
arch: "x86".into(),
16+
options: TargetOptions { mcount: "__mcount".into(), ..base },
17+
}
18+
}

‎compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,7 @@ supported_targets! {
15641564
("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd),
15651565
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
15661566
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
1567+
("i586-unknown-netbsd", i586_unknown_netbsd),
15671568
("i686-unknown-netbsd", i686_unknown_netbsd),
15681569
("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
15691570
("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd),

‎src/bootstrap/src/lib.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ impl Build {
586586
.args(&["diff-index", "--quiet", "HEAD"])
587587
.current_dir(&absolute_path),
588588
)
589-
.allow_failure(),
589+
.allow_failure()
590+
.output_mode(match self.is_verbose() {
591+
true => OutputMode::PrintAll,
592+
false => OutputMode::PrintOutput,
593+
}),
590594
);
591595
if has_local_modifications {
592596
self.run(Command::new("git").args(&["stash", "push"]).current_dir(&absolute_path));

‎src/bootstrap/src/utils/exec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
5454
Self {
5555
command,
5656
failure_behavior: BehaviorOnFailure::Exit,
57-
output_mode: OutputMode::SuppressOnSuccess,
57+
output_mode: OutputMode::PrintAll,
5858
}
5959
}
6060
}

‎src/doc/rustc/src/platform-support.md

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ target | std | notes
152152
`i586-pc-windows-msvc` | * | 32-bit Windows w/o SSE [^x86_32-floats-x87]
153153
`i586-unknown-linux-gnu` | ✓ | 32-bit Linux w/o SSE (kernel 3.2, glibc 2.17) [^x86_32-floats-x87]
154154
`i586-unknown-linux-musl` | ✓ | 32-bit Linux w/o SSE, MUSL [^x86_32-floats-x87]
155+
[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | 32-bit x86, restricted to Pentium
155156
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android [^x86_32-floats-return-ABI]
156157
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
157158
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with MUSL [^x86_32-floats-return-ABI]

0 commit comments

Comments
 (0)
Please sign in to comment.