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 #117333

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
450d6c5
Initial target specification for aarch64-apple-tvos-sim
simlay Sep 12, 2023
6c43244
Fix typos
simlay Sep 12, 2023
ba5eeda
Fix sdkname for tvos simulator
simlay Sep 13, 2023
4ab4d48
Update platform docs for aarch64-apple-tvos-sim
simlay Oct 6, 2023
0b96e47
Remove `cfg_match` from the prelude
c410-f3r Oct 25, 2023
6642b4b
Add support for i586-unknown-netbsd as target.
he32 Oct 25, 2023
391b472
rustc_llvm/build.rs: improve comment for NetBSD/i386 targets
he32 Oct 26, 2023
0a82920
Declare rustc_target dependency on object/macho
dtolnay Oct 27, 2023
893e726
i586_unknown_netbsd.rs: fix formatting.
he32 Oct 27, 2023
0f04e2d
For i586/NetBSD: fix another formatting insistence.
he32 Oct 27, 2023
64678d4
-Zunpretty help: add missing possible values
RalfJung Oct 28, 2023
a510288
i586_unknown_netbsd.rs: drop "-m32" flag insertion to gcc.
he32 Oct 28, 2023
d9ddad3
i586-unknown-netbsd: add entry in platform-support.md.
he32 Oct 28, 2023
4dd7568
mark constructor of `BinaryHeap` as const fn
Coekjan Oct 28, 2023
f7985af
explain why we don't inline when target features differ
RalfJung Oct 28, 2023
f5fa36f
i586-unknown-netbsd platform-support.md: fix typo.
he32 Oct 28, 2023
56643ec
Remove needless print ctx defs
Noratrieb Oct 28, 2023
4dada60
Move macros to usage
Noratrieb Oct 28, 2023
4e2bbfe
Remove needless `allow`s
Noratrieb Oct 28, 2023
67e6792
Rollup merge of #115773 - simlay:arch64-apple-tvos-sim-for-rustc, r=t…
workingjubilee Oct 28, 2023
16b2b9a
Rollup merge of #117162 - c410-f3r:try, r=workingjubilee
workingjubilee Oct 28, 2023
0709167
Rollup merge of #117170 - he32:netbsd-i586, r=bjorn3
workingjubilee Oct 28, 2023
5130c66
Rollup merge of #117259 - dtolnay:macho, r=Nilstrieb
workingjubilee Oct 28, 2023
adbca94
Rollup merge of #117311 - RalfJung:unpretty-thir-help, r=petrochenkov
workingjubilee Oct 28, 2023
c415a94
Rollup merge of #117316 - Coekjan:const-binary-heap-constructor, r=dt…
workingjubilee Oct 28, 2023
ba1069e
Rollup merge of #117319 - RalfJung:target-feature-inline-comment, r=t…
workingjubilee Oct 28, 2023
bd7c14f
Rollup merge of #117325 - Nilstrieb:pretty-macros, r=compiler-errors
workingjubilee Oct 28, 2023
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
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
}

let sdk_name = match (arch.as_ref(), os.as_ref()) {
("aarch64", "tvos") if llvm_target.ends_with("-simulator") => "appletvsimulator",
("aarch64", "tvos") => "appletvos",
("x86_64", "tvos") => "appletvsimulator",
("arm", "ios") => "iphoneos",
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ fn main() {
{
println!("cargo:rustc-link-lib=z");
} else if target.contains("netbsd") {
// On NetBSD/i386, gcc and g++ is built for i486 (to maximize backward compat)
// However, LLVM insists on using 64-bit atomics.
// This gives rise to a need to link rust itself with -latomic for these targets
if target.starts_with("i586") || target.starts_with("i686") {
println!("cargo:rustc-link-lib=atomic");
}
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=execinfo");
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_middle/src/ty/print/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ pub use self::pretty::*;

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

// FIXME(eddyb) false positive, the lifetime parameters are used with `P: Printer<...>`.
#[allow(unused_lifetimes)]
pub trait Print<'tcx, P> {
fn print(&self, cx: &mut P) -> Result<(), PrintError>;
}
Expand Down
84 changes: 37 additions & 47 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ macro_rules! p {
}
macro_rules! define_scoped_cx {
($cx:ident) => {
#[allow(unused_macros)]
macro_rules! scoped_cx {
() => {
$cx
Expand Down Expand Up @@ -408,8 +407,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
def_id: DefId,
callers: &mut Vec<DefId>,
) -> Result<bool, PrintError> {
define_scoped_cx!(self);

debug!("try_print_visible_def_path: def_id={:?}", def_id);

// If `def_id` is a direct or injected extern crate, return the
Expand Down Expand Up @@ -1868,8 +1865,6 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
def_id: DefId,
args: &'tcx [GenericArg<'tcx>],
) -> Result<(), PrintError> {
define_scoped_cx!(self);

if args.is_empty() {
match self.try_print_trimmed_def_path(def_id)? {
true => return Ok(()),
Expand Down Expand Up @@ -2401,8 +2396,6 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
let _ = write!(cx, "{cont}");
};

define_scoped_cx!(self);

let possible_names = ('a'..='z').rev().map(|s| Symbol::intern(&format!("'{s}")));

let mut available_names = possible_names
Expand Down Expand Up @@ -2630,46 +2623,6 @@ where
}
}

macro_rules! forward_display_to_print {
($($ty:ty),+) => {
// Some of the $ty arguments may not actually use 'tcx
$(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| {
let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
tcx.lift(*self)
.expect("could not lift for printing")
.print(&mut cx)?;
f.write_str(&cx.into_buffer())?;
Ok(())
})
}
})+
};
}

macro_rules! define_print_and_forward_display {
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
define_print!(($self, $cx): $($ty $print)*);
forward_display_to_print!($($ty),+);
};
}

macro_rules! define_print {
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
$(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
#[allow(unused_mut)]
let mut $cx = $cx;
define_scoped_cx!($cx);
let _: () = $print;
#[allow(unreachable_code)]
Ok(())
}
})+
};
}

/// Wrapper type for `ty::TraitRef` which opts-in to pretty printing only
/// the trait path. That is, it will print `Trait<U>` instead of
/// `<T as Trait<U>>`.
Expand Down Expand Up @@ -2744,6 +2697,43 @@ pub struct PrintClosureAsImpl<'tcx> {
pub closure: ty::ClosureArgs<'tcx>,
}

macro_rules! forward_display_to_print {
($($ty:ty),+) => {
// Some of the $ty arguments may not actually use 'tcx
$(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::tls::with(|tcx| {
let mut cx = FmtPrinter::new(tcx, Namespace::TypeNS);
tcx.lift(*self)
.expect("could not lift for printing")
.print(&mut cx)?;
f.write_str(&cx.into_buffer())?;
Ok(())
})
}
})+
};
}

macro_rules! define_print {
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
$(impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for $ty {
fn print(&$self, $cx: &mut P) -> Result<(), PrintError> {
define_scoped_cx!($cx);
let _: () = $print;
Ok(())
}
})+
};
}

macro_rules! define_print_and_forward_display {
(($self:ident, $cx:ident): $($ty:ty $print:block)+) => {
define_print!(($self, $cx): $($ty $print)*);
forward_display_to_print!($($ty),+);
};
}

forward_display_to_print! {
ty::Region<'tcx>,
Ty<'tcx>,
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_mir_transform/src/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ impl<'tcx> Inliner<'tcx> {
}

if callee_attrs.target_features != self.codegen_fn_attrs.target_features {
// In general it is not correct to inline a callee with target features that are a
// subset of the caller. This is because the callee might contain calls, and the ABI of
// those calls depends on the target features of the surrounding function. By moving a
// `Call` terminator from one MIR body to another with more target features, we might
// change the ABI of that call!
return Err("incompatible target features");
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,7 @@ written to standard error output)"),
`hir` (the HIR), `hir,identified`,
`hir,typed` (HIR with types for each node),
`hir-tree` (dump the raw HIR),
`thir-tree`, `thir-flat`,
`mir` (the MIR), or `mir-cfg` (graphviz formatted MIR)"),
unsound_mir_opts: bool = (false, parse_bool, [TRACKED],
"enable unsound and buggy MIR optimizations (default: no)"),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ rustc_index = { path = "../rustc_index" }
[dependencies.object]
version = "0.32.0"
default-features = false
features = ["elf"]
features = ["elf", "macho"]
31 changes: 31 additions & 0 deletions compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use super::apple_base::{opts, tvos_sim_llvm_target, Arch};
use crate::spec::{FramePointer, Target, TargetOptions};

pub fn target() -> Target {
let arch = Arch::Arm64_sim;
Target {
llvm_target: tvos_sim_llvm_target(arch).into(),
pointer_width: 64,
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
arch: arch.target_arch(),
options: TargetOptions {
features: "+neon,+fp-armv8,+apple-a7".into(),
max_atomic_width: Some(128),
forces_embed_bitcode: true,
frame_pointer: FramePointer::NonLeaf,
// Taken from (and slightly modified) the aarch64-apple-ios-sim spec which says:
// Taken from a clang build on Xcode 11.4.1.
// These arguments are not actually invoked - they just have
// to look right to pass App Store validation.
bitcode_llvm_cmdline: "-triple\0\
arm64-apple-tvos15.0-simulator\0\
-emit-obj\0\
-disable-llvm-passes\0\
-target-abi\0\
darwinpcs\0\
-Os\0"
.into(),
..opts("tvos", arch)
},
}
}
18 changes: 18 additions & 0 deletions compiler/rustc_target/src/spec/i586_unknown_netbsd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::spec::{StackProbeType, Target, TargetOptions};

pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.cpu = "pentium".into();
base.max_atomic_width = Some(64);
base.stack_probes = StackProbeType::Call;

Target {
llvm_target: "i586-unknown-netbsdelf".into(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
f64:32:64-f80:32-n8:16:32-S128"
.into(),
arch: "x86".into(),
options: TargetOptions { mcount: "__mcount".into(), ..base },
}
}
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 @@ -1564,6 +1564,7 @@ supported_targets! {
("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd),
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
("i586-unknown-netbsd", i586_unknown_netbsd),
("i686-unknown-netbsd", i686_unknown_netbsd),
("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
("riscv64gc-unknown-netbsd", riscv64gc_unknown_netbsd),
Expand Down Expand Up @@ -1603,6 +1604,7 @@ supported_targets! {
("aarch64-apple-ios-macabi", aarch64_apple_ios_macabi),
("aarch64-apple-ios-sim", aarch64_apple_ios_sim),
("aarch64-apple-tvos", aarch64_apple_tvos),
("aarch64-apple-tvos-sim", aarch64_apple_tvos_sim),
("x86_64-apple-tvos", x86_64_apple_tvos),

("armv7k-apple-watchos", armv7k_apple_watchos),
Expand Down
6 changes: 4 additions & 2 deletions library/alloc/src/collections/binary_heap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ impl<T: Ord> BinaryHeap<T> {
/// heap.push(4);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use]
pub fn new() -> BinaryHeap<T> {
pub const fn new() -> BinaryHeap<T> {
BinaryHeap { data: vec![] }
}

Expand Down Expand Up @@ -477,8 +478,9 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// heap.push(4);
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[must_use]
pub fn new_in(alloc: A) -> BinaryHeap<T, A> {
pub const fn new_in(alloc: A) -> BinaryHeap<T, A> {
BinaryHeap { data: Vec::new_in(alloc) }
}

Expand Down
3 changes: 3 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ pub mod assert_matches {
pub use crate::macros::{assert_matches, debug_assert_matches};
}

#[unstable(feature = "cfg_match", issue = "115585")]
pub use crate::macros::cfg_match;

#[macro_use]
mod internal_macros;

Expand Down
Loading