Skip to content

Commit 0d75160

Browse files
committed
Auto merge of #148368 - matthiaskrgr:rollup-kiditp5, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #147137 (Mention crate being analyzed in query description) - #148099 (Prepare to move debugger discovery from compiletest to bootstrap) - #148194 (compiletest: Remove `cleanup_debug_info_options`) - #148199 (compiletest: Don't modify `testpaths` when creating aux contexts) - #148240 (rustc_codegen: fix musttail returns for cast/indirect ABIs) - #148247 (Remove two special cases from reachable_non_generics) - #148290 (Do not emit solver errors that contain error types) - #148362 (docs: makes a note about possible building `rustc 1.91.0 + host tools` for win7) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bd3ac03 + a4e8997 commit 0d75160

File tree

58 files changed

+311
-870
lines changed

Some content is hidden

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

58 files changed

+311
-870
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1616
use rustc_codegen_ssa::traits::*;
1717
use rustc_data_structures::small_c_str::SmallCStr;
1818
use rustc_hir::def_id::DefId;
19-
use rustc_middle::bug;
2019
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2120
use rustc_middle::ty::layout::{
2221
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTypingEnv, LayoutError, LayoutOfHelpers,
@@ -1458,10 +1457,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
14581457

14591458
match &fn_abi.ret.mode {
14601459
PassMode::Ignore | PassMode::Indirect { .. } => self.ret_void(),
1461-
PassMode::Direct(_) | PassMode::Pair { .. } => self.ret(call),
1462-
mode @ PassMode::Cast { .. } => {
1463-
bug!("Encountered `PassMode::{mode:?}` during codegen")
1464-
}
1460+
PassMode::Direct(_) | PassMode::Pair { .. } | PassMode::Cast { .. } => self.ret(call),
14651461
}
14661462
}
14671463

compiler/rustc_codegen_ssa/src/back/symbol_export.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
5151
return Default::default();
5252
}
5353

54-
// Check to see if this crate is a "special runtime crate". These
55-
// crates, implementation details of the standard library, typically
56-
// have a bunch of `pub extern` and `#[no_mangle]` functions as the
57-
// ABI between them. We don't want their symbols to have a `C`
58-
// export level, however, as they're just implementation details.
59-
// Down below we'll hardwire all of the symbols to the `Rust` export
60-
// level instead.
61-
let special_runtime_crate =
62-
tcx.is_panic_runtime(LOCAL_CRATE) || tcx.is_compiler_builtins(LOCAL_CRATE);
54+
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
6355

6456
let mut reachable_non_generics: DefIdMap<_> = tcx
6557
.reachable_set(())
@@ -104,11 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
10496
if tcx.cross_crate_inlinable(def_id) { None } else { Some(def_id) }
10597
})
10698
.map(|def_id| {
107-
// We won't link right if this symbol is stripped during LTO.
108-
let name = tcx.symbol_name(Instance::mono(tcx, def_id.to_def_id())).name;
109-
let used = name == "rust_eh_personality";
110-
111-
let export_level = if special_runtime_crate {
99+
let export_level = if is_compiler_builtins {
100+
// We don't want to export compiler-builtins symbols from any
101+
// dylibs, even rust dylibs. Unlike all other crates it gets
102+
// duplicated in every linker invocation and it may otherwise
103+
// unintentionally override definitions of these symbols by
104+
// libgcc or compiler-rt for C code.
112105
SymbolExportLevel::Rust
113106
} else {
114107
symbol_export_level(tcx, def_id.to_def_id())
@@ -131,8 +124,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
131124
SymbolExportKind::Text
132125
},
133126
used: codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_COMPILER)
134-
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER)
135-
|| used,
127+
|| codegen_attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER),
136128
rustc_std_internal_symbol: codegen_attrs
137129
.flags
138130
.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL),

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10631063
let return_dest = self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs);
10641064
target.map(|target| (return_dest, target))
10651065
}
1066-
CallKind::Tail => None,
1066+
CallKind::Tail => {
1067+
if fn_abi.ret.is_indirect() {
1068+
match self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs) {
1069+
ReturnDest::Nothing => {}
1070+
_ => bug!(
1071+
"tail calls to functions with indirect returns cannot store into a destination"
1072+
),
1073+
}
1074+
}
1075+
None
1076+
}
10671077
};
10681078

10691079
// Split the rust-call tupled arguments off.

compiler/rustc_infer/src/traits/project.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
44
use rustc_data_structures::undo_log::Rollback;
5+
use rustc_macros::TypeVisitable;
56
use rustc_middle::traits::EvaluationResult;
67
use rustc_middle::ty;
78
use tracing::{debug, info};
@@ -12,7 +13,7 @@ use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
1213
pub(crate) type UndoLog<'tcx> =
1314
snapshot_map::UndoLog<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>;
1415

15-
#[derive(Clone)]
16+
#[derive(Clone, TypeVisitable)]
1617
pub struct MismatchedProjectionTypes<'tcx> {
1718
pub err: ty::error::TypeError<'tcx>,
1819
}

compiler/rustc_middle/src/query/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ rustc_queries! {
397397
/// The root query triggering all analysis passes like typeck or borrowck.
398398
query analysis(key: ()) {
399399
eval_always
400-
desc { "running analysis passes on this crate" }
400+
desc { |tcx|
401+
"running analysis passes on crate `{}`",
402+
tcx.crate_name(LOCAL_CRATE),
403+
}
401404
}
402405

403406
/// This query checks the fulfillment of collected lint expectations.

compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_infer::traits::{
2020
PredicateObligation, SelectionError,
2121
};
2222
use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths};
23-
use rustc_middle::ty::{self, Ty, TyCtxt};
23+
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _};
2424
use rustc_span::{DesugaringKind, ErrorGuaranteed, ExpnKind, Span};
2525
use tracing::{info, instrument};
2626

@@ -253,7 +253,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
253253

254254
for from_expansion in [false, true] {
255255
for (error, suppressed) in iter::zip(&errors, &is_suppressed) {
256-
if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion {
256+
if !suppressed
257+
&& error.obligation.cause.span.from_expansion() == from_expansion
258+
&& !error.references_error()
259+
{
257260
let guar = self.report_fulfillment_error(error);
258261
self.infcx.set_tainted_by_errors(guar);
259262
reported = Some(guar);

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use std::ops::ControlFlow;
2929
use rustc_errors::ErrorGuaranteed;
3030
use rustc_hir::def::DefKind;
3131
pub use rustc_infer::traits::*;
32+
use rustc_macros::TypeVisitable;
3233
use rustc_middle::query::Providers;
3334
use rustc_middle::span_bug;
3435
use rustc_middle::ty::error::{ExpectedFound, TypeError};
@@ -75,7 +76,7 @@ use crate::infer::{InferCtxt, TyCtxtInferExt};
7576
use crate::regions::InferCtxtRegionExt;
7677
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
7778

78-
#[derive(Debug)]
79+
#[derive(Debug, TypeVisitable)]
7980
pub struct FulfillmentError<'tcx> {
8081
pub obligation: PredicateObligation<'tcx>,
8182
pub code: FulfillmentErrorCode<'tcx>,
@@ -107,7 +108,7 @@ impl<'tcx> FulfillmentError<'tcx> {
107108
}
108109
}
109110

110-
#[derive(Clone)]
111+
#[derive(Clone, TypeVisitable)]
111112
pub enum FulfillmentErrorCode<'tcx> {
112113
/// Inherently impossible to fulfill; this trait is implemented if and only
113114
/// if it is already implemented.

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::core::builder::{
2929
};
3030
use crate::core::config::TargetSelection;
3131
use crate::core::config::flags::{Subcommand, get_completion, top_level_help};
32+
use crate::core::debuggers;
3233
use crate::utils::build_stamp::{self, BuildStamp};
3334
use crate::utils::exec::{BootstrapCommand, command};
3435
use crate::utils::helpers::{
@@ -38,8 +39,6 @@ use crate::utils::helpers::{
3839
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
3940
use crate::{CLang, CodegenBackendKind, DocTests, GitRepo, Mode, PathSet, envify};
4041

41-
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
42-
4342
/// Runs `cargo test` on various internal tools used by bootstrap.
4443
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4544
pub struct CrateBootstrap {
@@ -2078,27 +2077,24 @@ Please disable assertions with `rust.debug-assertions = false`.
20782077

20792078
cmd.arg("--python").arg(builder.python());
20802079

2081-
if let Some(ref gdb) = builder.config.gdb {
2082-
cmd.arg("--gdb").arg(gdb);
2083-
}
2084-
2085-
let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
2086-
let lldb_version = command(&lldb_exe)
2087-
.allow_failure()
2088-
.arg("--version")
2089-
.run_capture(builder)
2090-
.stdout_if_ok()
2091-
.and_then(|v| if v.trim().is_empty() { None } else { Some(v) });
2092-
if let Some(ref vers) = lldb_version {
2093-
cmd.arg("--lldb-version").arg(vers);
2094-
let lldb_python_dir = command(&lldb_exe)
2095-
.allow_failure()
2096-
.arg("-P")
2097-
.run_capture_stdout(builder)
2098-
.stdout_if_ok()
2099-
.map(|p| p.lines().next().expect("lldb Python dir not found").to_string());
2100-
if let Some(ref dir) = lldb_python_dir {
2101-
cmd.arg("--lldb-python-dir").arg(dir);
2080+
if mode == "debuginfo" {
2081+
if let Some(debuggers::Gdb { gdb }) = debuggers::discover_gdb(builder) {
2082+
cmd.arg("--gdb").arg(gdb);
2083+
}
2084+
2085+
if let Some(debuggers::Android { adb_path, adb_test_dir, android_cross_path }) =
2086+
debuggers::discover_android(builder, target)
2087+
{
2088+
cmd.arg("--adb-path").arg(adb_path);
2089+
cmd.arg("--adb-test-dir").arg(adb_test_dir);
2090+
cmd.arg("--android-cross-path").arg(android_cross_path);
2091+
}
2092+
2093+
if let Some(debuggers::Lldb { lldb_version, lldb_python_dir }) =
2094+
debuggers::discover_lldb(builder)
2095+
{
2096+
cmd.arg("--lldb-version").arg(lldb_version);
2097+
cmd.arg("--lldb-python-dir").arg(lldb_python_dir);
21022098
}
21032099
}
21042100

@@ -2332,16 +2328,6 @@ Please disable assertions with `rust.debug-assertions = false`.
23322328

23332329
cmd.env("RUST_TEST_TMPDIR", builder.tempdir());
23342330

2335-
cmd.arg("--adb-path").arg("adb");
2336-
cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
2337-
if target.contains("android") && !builder.config.dry_run() {
2338-
// Assume that cc for this target comes from the android sysroot
2339-
cmd.arg("--android-cross-path")
2340-
.arg(builder.cc(target).parent().unwrap().parent().unwrap());
2341-
} else {
2342-
cmd.arg("--android-cross-path").arg("");
2343-
}
2344-
23452331
if builder.config.cmd.rustfix_coverage() {
23462332
cmd.arg("--rustfix-coverage");
23472333
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::path::PathBuf;
2+
3+
use crate::core::builder::Builder;
4+
use crate::core::config::TargetSelection;
5+
6+
pub(crate) struct Android {
7+
pub(crate) adb_path: &'static str,
8+
pub(crate) adb_test_dir: &'static str,
9+
pub(crate) android_cross_path: PathBuf,
10+
}
11+
12+
pub(crate) fn discover_android(builder: &Builder<'_>, target: TargetSelection) -> Option<Android> {
13+
let adb_path = "adb";
14+
// See <https://github.com/rust-lang/rust/pull/102755>.
15+
let adb_test_dir = "/data/local/tmp/work";
16+
17+
let android_cross_path = if target.contains("android") && !builder.config.dry_run() {
18+
builder.cc(target).parent().unwrap().parent().unwrap().to_owned()
19+
} else {
20+
PathBuf::new()
21+
};
22+
23+
Some(Android { adb_path, adb_test_dir, android_cross_path })
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use std::path::Path;
2+
3+
use crate::core::builder::Builder;
4+
5+
pub(crate) struct Gdb<'a> {
6+
pub(crate) gdb: &'a Path,
7+
}
8+
9+
pub(crate) fn discover_gdb<'a>(builder: &'a Builder<'_>) -> Option<Gdb<'a>> {
10+
let gdb = builder.config.gdb.as_deref()?;
11+
12+
Some(Gdb { gdb })
13+
}

0 commit comments

Comments
 (0)