Skip to content

Commit 339e4d8

Browse files
committed
Auto merge of #145658 - Zalathar:rollup-ccqb8hk, r=Zalathar
Rollup of 5 pull requests Successful merges: - #144915 (Defer tail call ret ty equality to check_tail_calls) - #145256 (Add new `--test-codegen-backend` bootstrap option) - #145415 (std_detect: RISC-V: implement implication to "C") - #145647 (miri subtree update) - #145650 (Fix JS search scripts path) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e8a792d + 141a1e8 commit 339e4d8

File tree

95 files changed

+401
-99
lines changed

Some content is hidden

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

95 files changed

+401
-99
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18951895
if !output_ty
18961896
.is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.infcx.param_env))
18971897
{
1898-
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
1898+
span_mirbug!(self, term, "call to non-diverging function {:?} w/o dest", sig);
18991899
}
19001900
} else {
19011901
let dest_ty = destination.ty(self.body, tcx).ty;

compiler/rustc_mir_build/src/check_tail_calls.rs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,30 +135,23 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
135135
self.report_abi_mismatch(expr.span, caller_sig.abi, callee_sig.abi);
136136
}
137137

138+
// FIXME(explicit_tail_calls): this currently fails for cases where opaques are used.
139+
// e.g.
140+
// ```
141+
// fn a() -> impl Sized { become b() } // ICE
142+
// fn b() -> u8 { 0 }
143+
// ```
144+
// we should think what is the expected behavior here.
145+
// (we should probably just accept this by revealing opaques?)
138146
if caller_sig.inputs_and_output != callee_sig.inputs_and_output {
139-
if caller_sig.inputs() != callee_sig.inputs() {
140-
self.report_arguments_mismatch(
141-
expr.span,
142-
self.tcx.liberate_late_bound_regions(
143-
CRATE_DEF_ID.to_def_id(),
144-
self.caller_ty.fn_sig(self.tcx),
145-
),
146-
self.tcx
147-
.liberate_late_bound_regions(CRATE_DEF_ID.to_def_id(), ty.fn_sig(self.tcx)),
148-
);
149-
}
150-
151-
// FIXME(explicit_tail_calls): this currently fails for cases where opaques are used.
152-
// e.g.
153-
// ```
154-
// fn a() -> impl Sized { become b() } // ICE
155-
// fn b() -> u8 { 0 }
156-
// ```
157-
// we should think what is the expected behavior here.
158-
// (we should probably just accept this by revealing opaques?)
159-
if caller_sig.output() != callee_sig.output() {
160-
span_bug!(expr.span, "hir typeck should have checked the return type already");
161-
}
147+
self.report_signature_mismatch(
148+
expr.span,
149+
self.tcx.liberate_late_bound_regions(
150+
CRATE_DEF_ID.to_def_id(),
151+
self.caller_ty.fn_sig(self.tcx),
152+
),
153+
self.tcx.liberate_late_bound_regions(CRATE_DEF_ID.to_def_id(), ty.fn_sig(self.tcx)),
154+
);
162155
}
163156

164157
{
@@ -365,7 +358,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> {
365358
self.found_errors = Err(err);
366359
}
367360

368-
fn report_arguments_mismatch(
361+
fn report_signature_mismatch(
369362
&mut self,
370363
sp: Span,
371364
caller_sig: ty::FnSig<'_>,

library/std_detect/src/detect/os/riscv.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,31 @@ pub(crate) fn imply_features(mut value: cache::Initializer) -> cache::Initialize
119119
imply!(d | zfhmin | zfa => f);
120120
imply!(zfbfmin => f); // and some of (not all) "Zfh" instructions.
121121

122-
// Relatively complex implication rules from the "C" extension.
122+
// Relatively complex implication rules around the "C" extension.
123+
// (from "C" and some others)
123124
imply!(c => zca);
124125
imply!(c & d => zcd);
125126
#[cfg(target_arch = "riscv32")]
126127
imply!(c & f => zcf);
128+
// (to "C"; defined as superset)
129+
cfg_select! {
130+
target_arch = "riscv32" => {
131+
if value.test(Feature::d as u32) {
132+
imply!(zcf & zcd => c);
133+
} else if value.test(Feature::f as u32) {
134+
imply!(zcf => c);
135+
} else {
136+
imply!(zca => c);
137+
}
138+
}
139+
_ => {
140+
if value.test(Feature::d as u32) {
141+
imply!(zcd => c);
142+
} else {
143+
imply!(zca => c);
144+
}
145+
}
146+
}
127147

128148
imply!(zicntr | zihpm | f | zfinx | zve32x => zicsr);
129149

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,10 +1830,27 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18301830
cmd.arg("--host").arg(&*compiler.host.triple);
18311831
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target));
18321832

1833-
if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host) {
1834-
// Tells compiletest which codegen backend is used by default by the compiler.
1833+
if let Some(codegen_backend) = builder.config.cmd.test_codegen_backend() {
1834+
if !builder.config.enabled_codegen_backends(compiler.host).contains(codegen_backend) {
1835+
eprintln!(
1836+
"\
1837+
ERROR: No configured backend named `{name}`
1838+
HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}]`",
1839+
name = codegen_backend.name(),
1840+
);
1841+
crate::exit!(1);
1842+
}
1843+
// Tells compiletest that we want to use this codegen in particular and to override
1844+
// the default one.
1845+
cmd.arg("--override-codegen-backend").arg(codegen_backend.name());
1846+
// Tells compiletest which codegen backend to use.
1847+
// It is used to e.g. ignore tests that don't support that codegen backend.
1848+
cmd.arg("--default-codegen-backend").arg(codegen_backend.name());
1849+
} else {
1850+
// Tells compiletest which codegen backend to use.
18351851
// It is used to e.g. ignore tests that don't support that codegen backend.
1836-
cmd.arg("--codegen-backend").arg(codegen_backend.name());
1852+
cmd.arg("--default-codegen-backend")
1853+
.arg(builder.config.default_codegen_backend(compiler.host).unwrap().name());
18371854
}
18381855

18391856
if builder.build.config.llvm_enzyme {

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,12 @@ impl Builder<'_> {
13261326

13271327
if let Some(limit) = limit
13281328
&& (build_compiler_stage == 0
1329-
|| self.config.default_codegen_backend(target).unwrap_or_default().is_llvm())
1329+
|| self
1330+
.config
1331+
.default_codegen_backend(target)
1332+
.cloned()
1333+
.unwrap_or_default()
1334+
.is_llvm())
13301335
{
13311336
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}"));
13321337
}

src/bootstrap/src/core/config/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,8 +1755,8 @@ impl Config {
17551755

17561756
/// Returns the codegen backend that should be configured as the *default* codegen backend
17571757
/// for a rustc compiled by bootstrap.
1758-
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<CodegenBackendKind> {
1759-
self.enabled_codegen_backends(target).first().cloned()
1758+
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<&CodegenBackendKind> {
1759+
self.enabled_codegen_backends(target).first()
17601760
}
17611761

17621762
pub fn jemalloc(&self, target: TargetSelection) -> bool {

src/bootstrap/src/core/config/flags.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::core::build_steps::setup::Profile;
1515
use crate::core::builder::{Builder, Kind};
1616
use crate::core::config::Config;
1717
use crate::core::config::target_selection::{TargetSelectionList, target_selection_list};
18-
use crate::{Build, DocTests};
18+
use crate::{Build, CodegenBackendKind, DocTests};
1919

2020
#[derive(Copy, Clone, Default, Debug, ValueEnum)]
2121
pub enum Color {
@@ -419,6 +419,9 @@ pub enum Subcommand {
419419
#[arg(long)]
420420
/// don't capture stdout/stderr of tests
421421
no_capture: bool,
422+
#[arg(long)]
423+
/// Use a different codegen backend when running tests.
424+
test_codegen_backend: Option<CodegenBackendKind>,
422425
},
423426
/// Build and run some test suites *in Miri*
424427
Miri {
@@ -658,6 +661,13 @@ impl Subcommand {
658661
_ => vec![],
659662
}
660663
}
664+
665+
pub fn test_codegen_backend(&self) -> Option<&CodegenBackendKind> {
666+
match self {
667+
Subcommand::Test { test_codegen_backend, .. } => test_codegen_backend.as_ref(),
668+
_ => None,
669+
}
670+
}
661671
}
662672

663673
/// Returns the shell completion for a given shell, if the result differs from the current

src/bootstrap/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,20 @@ impl CodegenBackendKind {
165165
}
166166
}
167167

168+
impl std::str::FromStr for CodegenBackendKind {
169+
type Err = &'static str;
170+
171+
fn from_str(s: &str) -> Result<Self, Self::Err> {
172+
match s.to_lowercase().as_str() {
173+
"" => Err("Invalid empty backend name"),
174+
"gcc" => Ok(Self::Gcc),
175+
"llvm" => Ok(Self::Llvm),
176+
"cranelift" => Ok(Self::Cranelift),
177+
_ => Ok(Self::Custom(s.to_string())),
178+
}
179+
}
180+
}
181+
168182
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
169183
pub enum DocTests {
170184
/// Run normal tests and doc tests (default).

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
506506
severity: ChangeSeverity::Warning,
507507
summary: "It is no longer possible to `x clippy` with stage 0. All clippy commands have to be on stage 1+.",
508508
},
509+
ChangeInfo {
510+
change_id: 145256,
511+
severity: ChangeSeverity::Info,
512+
summary: "Added `--test-codegen-backend` CLI option for tests",
513+
},
509514
ChangeInfo {
510515
change_id: 145379,
511516
severity: ChangeSeverity::Info,

src/etc/completions/x.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ complete -c x -n "__fish_x_using_subcommand test" -l extra-checks -d 'comma-sepa
305305
complete -c x -n "__fish_x_using_subcommand test" -l compare-mode -d 'mode describing what file the actual ui output will be compared to' -r
306306
complete -c x -n "__fish_x_using_subcommand test" -l pass -d 'force {check,build,run}-pass tests to this mode' -r
307307
complete -c x -n "__fish_x_using_subcommand test" -l run -d 'whether to execute run-* tests' -r
308+
complete -c x -n "__fish_x_using_subcommand test" -l test-codegen-backend -d 'Use a different codegen backend when running tests' -r
308309
complete -c x -n "__fish_x_using_subcommand test" -l config -d 'TOML configuration file for build' -r -F
309310
complete -c x -n "__fish_x_using_subcommand test" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"
310311
complete -c x -n "__fish_x_using_subcommand test" -l build -d 'host target of the stage0 compiler' -r -f

0 commit comments

Comments
 (0)