Skip to content

Add new --test-codegen-backend bootstrap option #145256

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

Merged
merged 2 commits into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be cx.config.override_codegen_backend.unwrap_or(cx.config.default_codegen_backend)? That is the actual backend that will be used in the end for test suites other than run-make.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override_codegen_backend can be a path (and is supposed to be as well in your case iiuc), so it is supposed to be default_codegen_backend.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To extend a bit more on that, for cranelift, you will pass --default-codegen-backend cranelift --override-codegen-backend /path/to/cranelift.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't directly pass any arguments to compiletest for cg_clif, so only --default-codegen-backend cranelift would be passed for that. I was thinking about the case of testing cg_gcc though. If you do ./x.py test --test-codegen-backend gcc with codegen-backends = ["llvm", "gcc"] as I expect will happen when you want to test cg_gcc as end user, then --default-codegen-backend llvm --override-codegen-backend gcc would be passed to compiletest. This would result in -Zcodegen-backends=gcc, but with the current check here it would run tests that indicate they should run LLVM, but will run them with the GCC backend.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/rust-lang/rust/pull/145256/files#diff-675065335a90de4a4e1ac5bc0a078709f865ff2d357ba2650309f0ad8614b1d3R1854-R1857

So normally no. If you use --test-codegen-backend, it will pass both options correctly (but not the full path of the backend). Maybe I misunderstood how you were running compiletest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you two don't consider what I wrote above to be a valuable use-case, then I'd just modify --test-codegen-backend to also override the --default-codegen-backend option.

That would make sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I realized that bootstrap would then have to detect what kind of codegen backend we are using 🤔 Because you can pass --test-codegen-backend foobar.so, and bootstrap has no way of knowing whether it is cranelift, gcc, or something else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't pass the builder.config.enabled_codegen_backends(compiler.host).contains(codegen_backend) check, right? You can't add the foobar.so to the codegen-backends option in bootstrap.toml without getting an error about an unrecognized backend.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I assumed we'd remove the check, as I thought that you would like to pass --test-codegen-backend=<path>. If we don't have a use-case for passing a path, then it doesn't matter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing the rustc-clif wrapper with passing the path to --test-codegen-backend won't really work for now yet as I need to pass -Cpanic=abort -Zpanic-abort-tests too.

{
// 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
Loading