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

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f7d12b4
Session object: Decouple e_flags from FileFlags
mkroening Jun 1, 2022
37fd294
rustc_target: Remove some redundant target properties
petrochenkov Jun 17, 2022
3f12fa7
Add support for macro in "jump to def" feature
GuillaumeGomez Nov 26, 2021
dda980d
Rename ContextInfo into HrefContext
GuillaumeGomez Jun 18, 2022
810254b
Improve code readability and documentation
GuillaumeGomez Jun 18, 2022
f4db07e
Add test for macro support in "jump to def" feature
GuillaumeGomez Nov 26, 2021
987c731
Integrate `generate_macro_def_id_path` into `href_with_root_path`
GuillaumeGomez Jun 20, 2022
beb2f36
Fix panic by checking if `CStore` has the crate data we want before a…
GuillaumeGomez Jun 20, 2022
d15fed7
Improve suggestion for calling closure on type mismatch
compiler-errors Jun 20, 2022
36ccdbe
Remove (transitive) reliance on sorting by DefId in pretty-printer
Aaron1011 May 11, 2022
9730221
Remove excess rib while resolving closures
WaffleLapkin Jun 23, 2022
21625e5
Session object: Set OS/ABI
mkroening Jun 1, 2022
fb00d51
Fix cross compiling on macOS
topjohnwu Jun 21, 2022
91c7dd0
Set CLANG_TABLEGEN when cross compiling clang
topjohnwu Jun 23, 2022
774e814
Fix BTreeSet's range API panic message, document
tnballo Jun 23, 2022
7411548
Rollup merge of #91264 - GuillaumeGomez:macro-jump-to-def, r=jsha
JohnTitor Jun 24, 2022
433a9ea
Rollup merge of #96955 - Aaron1011:pretty-print-sort, r=petrochenkov
JohnTitor Jun 24, 2022
4db9a9f
Rollup merge of #97633 - mkroening:object-osabi, r=petrochenkov
JohnTitor Jun 24, 2022
4d2021b
Rollup merge of #98039 - tnballo:master, r=thomcc
JohnTitor Jun 24, 2022
abd04ee
Rollup merge of #98214 - petrochenkov:islike, r=compiler-errors
JohnTitor Jun 24, 2022
910b60f
Rollup merge of #98280 - compiler-errors:better-call-closure-on-type-…
JohnTitor Jun 24, 2022
483a299
Rollup merge of #98328 - topjohnwu:fix_cross, r=jyn514
JohnTitor Jun 24, 2022
3c62245
Rollup merge of #98419 - WaffleLapkin:remove_excess_rib, r=compiler-e…
JohnTitor Jun 24, 2022
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
15 changes: 14 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@ version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758"
dependencies = [
"ahash",
"compiler_builtins",
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -2571,6 +2572,18 @@ dependencies = [
"memchr",
]

[[package]]
name = "object"
version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [
"crc32fast",
"hashbrown 0.12.0",
"indexmap",
"memchr",
]

[[package]]
name = "odht"
version = "0.3.1"
Expand Down Expand Up @@ -3720,7 +3733,7 @@ dependencies = [
"itertools",
"jobserver",
"libc",
"object 0.28.4",
"object 0.29.0",
"pathdiff",
"regex",
"rustc_apfloat",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ impl<'ll> CodegenCx<'ll, '_> {
return eh_catch_typeinfo;
}
let tcx = self.tcx;
assert!(self.sess().target.is_like_emscripten);
assert!(self.sess().target.os == "emscripten");
let eh_catch_typeinfo = match tcx.lang_items().eh_catch_typeinfo() {
Some(def_id) => self.get_static(def_id),
_ => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fn try_intrinsic<'ll>(
bx.store(bx.const_i32(0), dest, ret_align);
} else if wants_msvc_seh(bx.sess()) {
codegen_msvc_try(bx, try_func, data, catch_func, dest);
} else if bx.sess().target.is_like_emscripten {
} else if bx.sess().target.os == "emscripten" {
codegen_emcc_try(bx, try_func, data, catch_func, dest);
} else {
codegen_gnu_try(bx, try_func, data, catch_func, dest);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ rustc_target = { path = "../rustc_target" }
rustc_session = { path = "../rustc_session" }

[dependencies.object]
version = "0.28.4"
version = "0.29.0"
default-features = false
features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"]
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ fn add_order_independent_options(

add_link_script(cmd, sess, tmpdir, crate_type);

if sess.target.is_like_fuchsia && crate_type == CrateType::Executable {
if sess.target.os == "fuchsia" && crate_type == CrateType::Executable {
let prefix = if sess.opts.debugging_opts.sanitizer.contains(SanitizerSet::ADDRESS) {
"asan/"
} else {
Expand All @@ -2051,7 +2051,7 @@ fn add_order_independent_options(
cmd.no_crt_objects();
}

if sess.target.is_like_emscripten {
if sess.target.os == "emscripten" {
cmd.arg("-s");
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
"DISABLE_EXCEPTION_CATCHING=1"
Expand Down
19 changes: 14 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
};

let mut file = write::Object::new(binary_format, architecture, endianness);
match architecture {
let e_flags = match architecture {
Architecture::Mips => {
let arch = match sess.target.options.cpu.as_ref() {
"mips1" => elf::EF_MIPS_ARCH_1,
Expand All @@ -149,7 +149,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
if sess.target.options.cpu.contains("r6") {
e_flags |= elf::EF_MIPS_NAN2008;
}
file.flags = FileFlags::Elf { e_flags };
e_flags
}
Architecture::Mips64 => {
// copied from `mips64el-linux-gnuabi64-gcc foo.c -c`
Expand All @@ -160,17 +160,26 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
} else {
elf::EF_MIPS_ARCH_64R2
};
file.flags = FileFlags::Elf { e_flags };
e_flags
}
Architecture::Riscv64 if sess.target.options.features.contains("+d") => {
// copied from `riscv64-linux-gnu-gcc foo.c -c`, note though
// that the `+d` target feature represents whether the double
// float abi is enabled.
let e_flags = elf::EF_RISCV_RVC | elf::EF_RISCV_FLOAT_ABI_DOUBLE;
file.flags = FileFlags::Elf { e_flags };
e_flags
}
_ => {}
_ => 0,
};
// adapted from LLVM's `MCELFObjectTargetWriter::getOSABI`
let os_abi = match sess.target.options.os.as_ref() {
"hermit" => elf::ELFOSABI_STANDALONE,
"freebsd" => elf::ELFOSABI_FREEBSD,
"solaris" => elf::ELFOSABI_SOLARIS,
_ => elf::ELFOSABI_NONE,
};
let abi_version = 0;
file.flags = FileFlags::Elf { os_abi, abi_version, e_flags };
Some(file)
}

Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ impl CStore {
CrateNum::new(self.metas.len() - 1)
}

pub fn has_crate_data(&self, cnum: CrateNum) -> bool {
self.metas[cnum].is_some()
}

pub(crate) fn get_crate_data(&self, cnum: CrateNum) -> CrateMetadataRef<'_> {
let cdata = self.metas[cnum]
.as_ref()
Expand Down
23 changes: 11 additions & 12 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ty::{
TypeSuperFoldable,
};
use rustc_apfloat::ieee::{Double, Single};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::sso::SsoHashSet;
use rustc_hir as hir;
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
Expand Down Expand Up @@ -779,8 +779,8 @@ pub trait PrettyPrinter<'tcx>:
// by looking up the projections associated with the def_id.
let bounds = self.tcx().bound_explicit_item_bounds(def_id);

let mut traits = BTreeMap::new();
let mut fn_traits = BTreeMap::new();
let mut traits = FxIndexMap::default();
let mut fn_traits = FxIndexMap::default();
let mut is_sized = false;

for predicate in bounds.transpose_iter().map(|e| e.map_bound(|(p, _)| *p)) {
Expand Down Expand Up @@ -856,7 +856,7 @@ pub trait PrettyPrinter<'tcx>:
p!(")");
if let Term::Ty(ty) = return_ty.skip_binder() {
if !ty.is_unit() {
p!("-> ", print(return_ty));
p!(" -> ", print(return_ty));
}
}
p!(write("{}", if paren_needed { ")" } else { "" }));
Expand Down Expand Up @@ -970,11 +970,11 @@ pub trait PrettyPrinter<'tcx>:
&mut self,
trait_ref: ty::PolyTraitRef<'tcx>,
proj_ty: Option<(DefId, ty::Binder<'tcx, Term<'tcx>>)>,
traits: &mut BTreeMap<
traits: &mut FxIndexMap<
ty::PolyTraitRef<'tcx>,
BTreeMap<DefId, ty::Binder<'tcx, Term<'tcx>>>,
FxIndexMap<DefId, ty::Binder<'tcx, Term<'tcx>>>,
>,
fn_traits: &mut BTreeMap<ty::PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>,
fn_traits: &mut FxIndexMap<ty::PolyTraitRef<'tcx>, OpaqueFnEntry<'tcx>>,
) {
let trait_def_id = trait_ref.def_id();

Expand Down Expand Up @@ -1110,19 +1110,18 @@ pub trait PrettyPrinter<'tcx>:
// Builtin bounds.
// FIXME(eddyb) avoid printing twice (needed to ensure
// that the auto traits are sorted *and* printed via cx).
let mut auto_traits: Vec<_> =
predicates.auto_traits().map(|did| (self.tcx().def_path_str(did), did)).collect();
let mut auto_traits: Vec<_> = predicates.auto_traits().collect();

// The auto traits come ordered by `DefPathHash`. While
// `DefPathHash` is *stable* in the sense that it depends on
// neither the host nor the phase of the moon, it depends
// "pseudorandomly" on the compiler version and the target.
//
// To avoid that causing instabilities in compiletest
// To avoid causing instabilities in compiletest
// output, sort the auto-traits alphabetically.
auto_traits.sort();
auto_traits.sort_by_cached_key(|did| self.tcx().def_path_str(*did));

for (_, def_id) in auto_traits {
for def_id in auto_traits {
if !first {
p!(" + ");
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
if items.eh_personality().is_none() {
items.missing.push(LangItem::EhPersonality);
}
if tcx.sess.target.is_like_emscripten && items.eh_catch_typeinfo().is_none() {
if tcx.sess.target.os == "emscripten" && items.eh_catch_typeinfo().is_none() {
items.missing.push(LangItem::EhCatchTypeinfo);
}

Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,9 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
})
});
}
ExprKind::Async(..) | ExprKind::Closure(..) => {
// For closures, ClosureOrAsyncRibKind is added in visit_fn
ExprKind::Closure(..) => visit::walk_expr(self, expr),
ExprKind::Async(..) => {
self.with_label_rib(ClosureOrAsyncRibKind, |this| visit::walk_expr(this, expr));
}
ExprKind::Repeat(ref elem, ref ct) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/asm/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl AArch64InlineAsmRegClass {
}

pub fn target_reserves_x18(target: &Target) -> bool {
target.os == "android" || target.is_like_fuchsia || target.is_like_osx || target.is_like_windows
target.os == "android" || target.os == "fuchsia" || target.is_like_osx || target.is_like_windows
}

fn reserved_x18(
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub fn opts() -> TargetOptions {
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
is_like_fuchsia: true,
pre_link_args,
pre_link_objects: crt_objects::new(&[
(LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]),
Expand Down
12 changes: 0 additions & 12 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1273,12 +1273,6 @@ pub struct TargetOptions {
/// - uses SEH-based unwinding,
/// - supports control flow guard mechanism.
pub is_like_msvc: bool,
/// Whether the target toolchain is like Emscripten's. Only useful for compiling with
/// Emscripten toolchain.
/// Defaults to false.
pub is_like_emscripten: bool,
/// Whether the target toolchain is like Fuchsia's.
pub is_like_fuchsia: bool,
/// Whether a target toolchain is like WASM.
pub is_like_wasm: bool,
/// Version of DWARF to use if not using the default.
Expand Down Expand Up @@ -1505,9 +1499,7 @@ impl Default for TargetOptions {
is_like_osx: false,
is_like_solaris: false,
is_like_windows: false,
is_like_emscripten: false,
is_like_msvc: false,
is_like_fuchsia: false,
is_like_wasm: false,
dwarf_version: None,
linker_is_gnu: true,
Expand Down Expand Up @@ -2112,8 +2104,6 @@ impl Target {
key!(is_like_solaris, bool);
key!(is_like_windows, bool);
key!(is_like_msvc, bool);
key!(is_like_emscripten, bool);
key!(is_like_fuchsia, bool);
key!(is_like_wasm, bool);
key!(dwarf_version, Option<u32>);
key!(linker_is_gnu, bool);
Expand Down Expand Up @@ -2358,8 +2348,6 @@ impl ToJson for Target {
target_option_val!(is_like_solaris);
target_option_val!(is_like_windows);
target_option_val!(is_like_msvc);
target_option_val!(is_like_emscripten);
target_option_val!(is_like_fuchsia);
target_option_val!(is_like_wasm);
target_option_val!(dwarf_version);
target_option_val!(linker_is_gnu);
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_target/src/spec/tests/tests_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ pub(super) fn test_target(target: Target) {

impl Target {
fn check_consistency(&self) {
assert_eq!(self.is_like_osx, self.vendor == "apple");
assert_eq!(self.is_like_solaris, self.os == "solaris" || self.os == "illumos");
assert_eq!(self.is_like_windows, self.os == "windows" || self.os == "uefi");
assert_eq!(self.is_like_wasm, self.arch == "wasm32" || self.arch == "wasm64");
assert!(self.is_like_windows || !self.is_like_msvc);

// Check that LLD with the given flavor is treated identically to the linker it emulates.
// If your target really needs to deviate from the rules below, except it and document the
// reasons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn target() -> Target {
// functionality, and a .wasm file.
exe_suffix: ".js".into(),
linker: None,
is_like_emscripten: true,
panic_strategy: PanicStrategy::Unwind,
no_default_libraries: false,
post_link_args,
Expand Down
Loading