Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9370440
stabilize `const_array_each_ref`
fee1-dead Jul 3, 2025
f4b3415
[Doc] Add links to the various collections
QnJ1c2kNCg Jul 31, 2025
e13e1e4
fix(debuginfo): handle false positives in overflow check
adwinwhite Aug 12, 2025
be9cd3c
stdlib: Replace typedef -> type alias in doc comment
typesanitizer Aug 17, 2025
ee7627e
std_detect: RISC-V: implement implication to "C"
a4lg Aug 19, 2025
c2e16cb
UnsafePinned::raw_get: sync signature with get
RalfJung Aug 19, 2025
bfd5d59
Prevent impossible combinations in `ast::ModKind`.
nnethercote Aug 19, 2025
6a088fd
Defer tail call ret ty equality to check_tail_calls
compiler-errors Aug 19, 2025
555986d
Fix some doc typos
dns2utf8 Aug 19, 2025
5a451b8
Add new `--test-codegen-backend` bootstrap option
GuillaumeGomez Aug 11, 2025
e4cdc0f
Split compiletest `--codegen-backend` into two options `--default-cod…
GuillaumeGomez Aug 18, 2025
27e6726
Do not use effective_visibilities query for Adt types of a local trai…
xizheyin Aug 20, 2025
29f0d8b
Download CI GCC into the correct directory
Kobzol Aug 20, 2025
e1045c2
Fix JS search scripts path
GuillaumeGomez Aug 20, 2025
2da0ec3
Enforce correct number of arguments for `"x86-interrupt"` functions
GrigorenkoPV Aug 20, 2025
e57e5f0
Unconditionally-const supertraits are considered not dyn compatible
compiler-errors Aug 19, 2025
cadb56d
Add flock support for cygwin
Berrysoft Aug 20, 2025
992c025
Enable triagebot `[review-changes-since]` feature
Urgau Aug 20, 2025
f34fa22
fix: typo
ttajakka Aug 20, 2025
b65fab6
Move `IntoDiagArg` earlier in the dependency chains
joshtriplett Aug 14, 2025
f3c8b7a
Split `rustc_hir_id` out of `rustc_hir`
joshtriplett Aug 14, 2025
e46ec74
Update test output for change to number of crates
joshtriplett Aug 14, 2025
6cb9dd5
rustc_lint_defs: Use `DefPathHash` from `rustc_span` rather than `rus…
joshtriplett Aug 14, 2025
f0c8f70
rustc_lint_defs: Eliminate the dependency on `rustc_hir` for `Namespace`
joshtriplett Aug 14, 2025
bad4f5c
Eliminate unnecessary dependency from `rustc_mir_dataflow` to `rustc_…
joshtriplett Aug 14, 2025
0f0d702
Eliminate unnecessary dependency from `rustc_traits` to `rustc_hir`
joshtriplett Aug 14, 2025
2ea7e7d
rustc_hir_id: Add a comment explaining why the crate exists
joshtriplett Aug 18, 2025
8e62f0f
Rollup merge of #143383 - fee1-dead-contrib:push-mstmlwuskxyy, r=dtolnay
jhpratt Aug 21, 2025
32824b5
Rollup merge of #144758 - QnJ1c2kNCg:master, r=Noratrieb
jhpratt Aug 21, 2025
f1a7294
Rollup merge of #144915 - compiler-errors:tail-call-ret-ty-equality, …
jhpratt Aug 21, 2025
b0dd772
Rollup merge of #145256 - GuillaumeGomez:bootstrap-test-codegen-backe…
jhpratt Aug 21, 2025
537d5f4
Rollup merge of #145297 - adwinwhite:recursive-debuginfo, r=wesleywiser
jhpratt Aug 21, 2025
62582eb
Rollup merge of #145390 - joshtriplett:rustc-diag-value-earlier, r=lcnr
jhpratt Aug 21, 2025
03aa3b8
Rollup merge of #145415 - a4lg:riscv-implication-to-c, r=Amanieu
jhpratt Aug 21, 2025
d54aaed
Rollup merge of #145525 - typesanitizer:vg/doc, r=Mark-Simulacrum
jhpratt Aug 21, 2025
25b81bf
Rollup merge of #145590 - nnethercote:ModKind-Inline, r=petrochenkov
jhpratt Aug 21, 2025
1d02056
Rollup merge of #145593 - RalfJung:unsafepinned-raw_get, r=Mark-Simul…
jhpratt Aug 21, 2025
803456a
Rollup merge of #145621 - dns2utf8:fix_some_typos, r=petrochenkov
jhpratt Aug 21, 2025
64c43ed
Rollup merge of #145627 - compiler-errors:const-supertrait-dyn-compat…
jhpratt Aug 21, 2025
0af35f6
Rollup merge of #145642 - xizheyin:145611, r=lcnr
jhpratt Aug 21, 2025
5ea203a
Rollup merge of #145650 - GuillaumeGomez:fix-js-search-scripts-path, …
jhpratt Aug 21, 2025
2032ede
Rollup merge of #145654 - Kobzol:gcc-ci-root, r=jieyouxu
jhpratt Aug 21, 2025
99c647f
Rollup merge of #145662 - GrigorenkoPV:x86-interrupt, r=compiler-errors
jhpratt Aug 21, 2025
018568f
Rollup merge of #145673 - Berrysoft:cygwin-fix-flock, r=joshtriplett
jhpratt Aug 21, 2025
a060d60
Rollup merge of #145674 - Urgau:triagebot-review-changes-since, r=Kobzol
jhpratt Aug 21, 2025
49eb781
Rollup merge of #145678 - ttajakka:master, r=estebank
jhpratt Aug 21, 2025
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
23 changes: 20 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,10 +1830,27 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--host").arg(&*compiler.host.triple);
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target));

if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host) {
// Tells compiletest which codegen backend is used by default by the compiler.
if let Some(codegen_backend) = builder.config.cmd.test_codegen_backend() {
if !builder.config.enabled_codegen_backends(compiler.host).contains(codegen_backend) {
eprintln!(
"\
ERROR: No configured backend named `{name}`
HELP: You can add it into `bootstrap.toml` in `rust.codegen-backends = [{name:?}]`",
name = codegen_backend.name(),
);
crate::exit!(1);
}
// Tells compiletest that we want to use this codegen in particular and to override
// the default one.
cmd.arg("--override-codegen-backend").arg(codegen_backend.name());
// Tells compiletest which codegen backend to use.
// It is used to e.g. ignore tests that don't support that codegen backend.
cmd.arg("--default-codegen-backend").arg(codegen_backend.name());
} else {
// Tells compiletest which codegen backend to use.
// It is used to e.g. ignore tests that don't support that codegen backend.
cmd.arg("--codegen-backend").arg(codegen_backend.name());
cmd.arg("--default-codegen-backend")
.arg(builder.config.default_codegen_backend(compiler.host).unwrap().name());
}

if builder.build.config.llvm_enzyme {
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,12 @@ impl Builder<'_> {

if let Some(limit) = limit
&& (build_compiler_stage == 0
|| self.config.default_codegen_backend(target).unwrap_or_default().is_llvm())
|| self
.config
.default_codegen_backend(target)
.cloned()
.unwrap_or_default()
.is_llvm())
{
rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1755,8 +1755,8 @@ impl Config {

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

pub fn jemalloc(&self, target: TargetSelection) -> bool {
Expand Down
12 changes: 11 additions & 1 deletion src/bootstrap/src/core/config/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::core::build_steps::setup::Profile;
use crate::core::builder::{Builder, Kind};
use crate::core::config::Config;
use crate::core::config::target_selection::{TargetSelectionList, target_selection_list};
use crate::{Build, DocTests};
use crate::{Build, CodegenBackendKind, DocTests};

#[derive(Copy, Clone, Default, Debug, ValueEnum)]
pub enum Color {
Expand Down Expand Up @@ -419,6 +419,9 @@ pub enum Subcommand {
#[arg(long)]
/// don't capture stdout/stderr of tests
no_capture: bool,
#[arg(long)]
/// Use a different codegen backend when running tests.
test_codegen_backend: Option<CodegenBackendKind>,
},
/// Build and run some test suites *in Miri*
Miri {
Expand Down Expand Up @@ -658,6 +661,13 @@ impl Subcommand {
_ => vec![],
}
}

pub fn test_codegen_backend(&self) -> Option<&CodegenBackendKind> {
match self {
Subcommand::Test { test_codegen_backend, .. } => test_codegen_backend.as_ref(),
_ => None,
}
}
}

/// Returns the shell completion for a given shell, if the result differs from the current
Expand Down
14 changes: 14 additions & 0 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ impl CodegenBackendKind {
}
}

impl std::str::FromStr for CodegenBackendKind {
type Err = &'static str;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"" => Err("Invalid empty backend name"),
"gcc" => Ok(Self::Gcc),
"llvm" => Ok(Self::Llvm),
"cranelift" => Ok(Self::Cranelift),
_ => Ok(Self::Custom(s.to_string())),
}
}
}

#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum DocTests {
/// Run normal tests and doc tests (default).
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Warning,
summary: "It is no longer possible to `x clippy` with stage 0. All clippy commands have to be on stage 1+.",
},
ChangeInfo {
change_id: 145256,
severity: ChangeSeverity::Info,
summary: "Added `--test-codegen-backend` CLI option for tests",
},
ChangeInfo {
change_id: 145379,
severity: ChangeSeverity::Info,
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.fish
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ complete -c x -n "__fish_x_using_subcommand test" -l extra-checks -d 'comma-sepa
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
complete -c x -n "__fish_x_using_subcommand test" -l pass -d 'force {check,build,run}-pass tests to this mode' -r
complete -c x -n "__fish_x_using_subcommand test" -l run -d 'whether to execute run-* tests' -r
complete -c x -n "__fish_x_using_subcommand test" -l test-codegen-backend -d 'Use a different codegen backend when running tests' -r
complete -c x -n "__fish_x_using_subcommand test" -l config -d 'TOML configuration file for build' -r -F
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)"
complete -c x -n "__fish_x_using_subcommand test" -l build -d 'host target of the stage0 compiler' -r -f
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock {
[CompletionResult]::new('--compare-mode', '--compare-mode', [CompletionResultType]::ParameterName, 'mode describing what file the actual ui output will be compared to')
[CompletionResult]::new('--pass', '--pass', [CompletionResultType]::ParameterName, 'force {check,build,run}-pass tests to this mode')
[CompletionResult]::new('--run', '--run', [CompletionResultType]::ParameterName, 'whether to execute run-* tests')
[CompletionResult]::new('--test-codegen-backend', '--test-codegen-backend', [CompletionResultType]::ParameterName, 'Use a different codegen backend when running tests')
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')
[CompletionResult]::new('--build-dir', '--build-dir', [CompletionResultType]::ParameterName, 'Build directory, overrides `build.build-dir` in `bootstrap.toml`')
[CompletionResult]::new('--build', '--build', [CompletionResultType]::ParameterName, 'host target of the stage0 compiler')
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.py.fish
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand test" -l extra-checks -d 'comm
complete -c x.py -n "__fish_x.py_using_subcommand test" -l compare-mode -d 'mode describing what file the actual ui output will be compared to' -r
complete -c x.py -n "__fish_x.py_using_subcommand test" -l pass -d 'force {check,build,run}-pass tests to this mode' -r
complete -c x.py -n "__fish_x.py_using_subcommand test" -l run -d 'whether to execute run-* tests' -r
complete -c x.py -n "__fish_x.py_using_subcommand test" -l test-codegen-backend -d 'Use a different codegen backend when running tests' -r
complete -c x.py -n "__fish_x.py_using_subcommand test" -l config -d 'TOML configuration file for build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand test" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"
complete -c x.py -n "__fish_x.py_using_subcommand test" -l build -d 'host target of the stage0 compiler' -r -f
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.py.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
[CompletionResult]::new('--compare-mode', '--compare-mode', [CompletionResultType]::ParameterName, 'mode describing what file the actual ui output will be compared to')
[CompletionResult]::new('--pass', '--pass', [CompletionResultType]::ParameterName, 'force {check,build,run}-pass tests to this mode')
[CompletionResult]::new('--run', '--run', [CompletionResultType]::ParameterName, 'whether to execute run-* tests')
[CompletionResult]::new('--test-codegen-backend', '--test-codegen-backend', [CompletionResultType]::ParameterName, 'Use a different codegen backend when running tests')
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')
[CompletionResult]::new('--build-dir', '--build-dir', [CompletionResultType]::ParameterName, 'Build directory, overrides `build.build-dir` in `bootstrap.toml`')
[CompletionResult]::new('--build', '--build', [CompletionResultType]::ParameterName, 'host target of the stage0 compiler')
Expand Down
6 changes: 5 additions & 1 deletion src/etc/completions/x.py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3875,7 +3875,7 @@ _x.py() {
return 0
;;
x.py__test)
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --test-codegen-backend --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -3905,6 +3905,10 @@ _x.py() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--test-codegen-backend)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--config)
local oldifs
if [ -n "${IFS+x}" ]; then
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.py.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ _arguments "${_arguments_options[@]}" : \
'--compare-mode=[mode describing what file the actual ui output will be compared to]:COMPARE MODE:_default' \
'--pass=[force {check,build,run}-pass tests to this mode]:check | build | run:_default' \
'--run=[whether to execute run-* tests]:auto | always | never:_default' \
'--test-codegen-backend=[Use a different codegen backend when running tests]:TEST_CODEGEN_BACKEND:_default' \
'--config=[TOML configuration file for build]:FILE:_files' \
'--build-dir=[Build directory, overrides \`build.build-dir\` in \`bootstrap.toml\`]:DIR:_files -/' \
'--build=[host target of the stage0 compiler]:BUILD:' \
Expand Down
6 changes: 5 additions & 1 deletion src/etc/completions/x.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3875,7 +3875,7 @@ _x() {
return 0
;;
x__test)
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --test-codegen-backend --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -3905,6 +3905,10 @@ _x() {
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--test-codegen-backend)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--config)
local oldifs
if [ -n "${IFS+x}" ]; then
Expand Down
1 change: 1 addition & 0 deletions src/etc/completions/x.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ _arguments "${_arguments_options[@]}" : \
'--compare-mode=[mode describing what file the actual ui output will be compared to]:COMPARE MODE:_default' \
'--pass=[force {check,build,run}-pass tests to this mode]:check | build | run:_default' \
'--run=[whether to execute run-* tests]:auto | always | never:_default' \
'--test-codegen-backend=[Use a different codegen backend when running tests]:TEST_CODEGEN_BACKEND:_default' \
'--config=[TOML configuration file for build]:FILE:_files' \
'--build-dir=[Build directory, overrides \`build.build-dir\` in \`bootstrap.toml\`]:DIR:_files -/' \
'--build=[host target of the stage0 compiler]:BUILD:' \
Expand Down
7 changes: 5 additions & 2 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,9 @@ pub struct Config {
pub minicore_path: Utf8PathBuf,

/// Current codegen backend used.
pub codegen_backend: CodegenBackend,
pub default_codegen_backend: CodegenBackend,
/// Name/path of the backend to use instead of `default_codegen_backend`.
pub override_codegen_backend: Option<String>,
}

impl Config {
Expand Down Expand Up @@ -796,7 +798,8 @@ impl Config {
profiler_runtime: Default::default(),
diff_command: Default::default(),
minicore_path: Default::default(),
codegen_backend: CodegenBackend::Llvm,
default_codegen_backend: CodegenBackend::Llvm,
override_codegen_backend: None,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,7 @@ fn ignore_backends(
}
}
}) {
if config.codegen_backend == backend {
if config.default_codegen_backend == backend {
return IgnoreDecision::Ignore {
reason: format!("{} backend is marked as ignore", backend.as_str()),
};
Expand All @@ -1651,12 +1651,12 @@ fn needs_backends(
panic!("Invalid needs-backends value `{backend}` in `{path}`: {error}")
}
})
.any(|backend| config.codegen_backend == backend)
.any(|backend| config.default_codegen_backend == backend)
{
return IgnoreDecision::Ignore {
reason: format!(
"{} backend is not part of required backends",
config.codegen_backend.as_str()
config.default_codegen_backend.as_str()
),
};
}
Expand Down
22 changes: 16 additions & 6 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
)
.optopt(
"",
"codegen-backend",
"default-codegen-backend",
"the codegen backend currently used",
"CODEGEN BACKEND NAME",
)
.optopt(
"",
"override-codegen-backend",
"the codegen backend to use instead of the default one",
"CODEGEN BACKEND [NAME | PATH]",
);

let (argv0, args_) = args.split_first().unwrap();
Expand Down Expand Up @@ -276,14 +282,17 @@ pub fn parse_config(args: Vec<String>) -> Config {
|| directives::extract_llvm_version_from_binary(&matches.opt_str("llvm-filecheck")?),
);

let codegen_backend = match matches.opt_str("codegen-backend").as_deref() {
let default_codegen_backend = match matches.opt_str("default-codegen-backend").as_deref() {
Some(backend) => match CodegenBackend::try_from(backend) {
Ok(backend) => backend,
Err(error) => panic!("invalid value `{backend}` for `--codegen-backend`: {error}"),
Err(error) => {
panic!("invalid value `{backend}` for `--defalt-codegen-backend`: {error}")
}
},
// By default, it's always llvm.
None => CodegenBackend::Llvm,
};
let override_codegen_backend = matches.opt_str("override-codegen-backend");

let run_ignored = matches.opt_present("ignored");
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
Expand Down Expand Up @@ -472,7 +481,8 @@ pub fn parse_config(args: Vec<String>) -> Config {

minicore_path: opt_path(matches, "minicore-path"),

codegen_backend,
default_codegen_backend,
override_codegen_backend,
}
}

Expand Down Expand Up @@ -812,13 +822,13 @@ fn collect_tests_from_dir(
&& let Some(Utf8Component::Normal(parent)) = components.next()
&& parent == "tests"
&& let Ok(backend) = CodegenBackend::try_from(backend)
&& backend != cx.config.codegen_backend
&& backend != cx.config.default_codegen_backend
{
// We ignore asm tests which don't match the current codegen backend.
warning!(
"Ignoring tests in `{dir}` because they don't match the configured codegen \
backend (`{}`)",
cx.config.codegen_backend.as_str(),
cx.config.default_codegen_backend.as_str(),
);
return Ok(TestCollector::new());
}
Expand Down
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,11 @@ impl<'test> TestCx<'test> {
rustc.arg("--sysroot").arg(&self.config.sysroot_base);
}

// If the provided codegen backend is not LLVM, we need to pass it.
if let Some(ref backend) = self.config.override_codegen_backend {
rustc.arg(format!("-Zcodegen-backend={}", backend));
}

// Optionally prevent default --target if specified in test compile-flags.
let custom_target = self.props.compile_flags.iter().any(|x| x.starts_with("--target"));

Expand Down