Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3997b62

Browse files
authoredJun 12, 2024
Rollup merge of #126256 - ferrocene:lw-target-subst, r=albertlarsan68
Add {{target}} substitution to compiletest In ferrocene we have ui tests testing the cli interface of the compiler, one of which tests the `--target` flag. To be able to run this on all targets we require a way to specify a valid target in the `compile-flags` directive that is target independent, as otherwise we can only run the test against the one target we choose to supply in the flags. See https://github.com/ferrocene/ferrocene/blob/383cbc80f4e85859a4055f121f15dac329908346/tests/ui/ferrocene/compiler-arguments/target/target.rs We figured the project might be able to make use of this substitution as well in the future. try-job: dist-x86_64-msvc
2 parents 4de77b6 + 1462f3d commit 3997b62

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎src/tools/compiletest/src/header.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
12811281
const BUILD_BASE: &str = "{{build-base}}";
12821282
const SYSROOT_BASE: &str = "{{sysroot-base}}";
12831283
const TARGET_LINKER: &str = "{{target-linker}}";
1284+
const TARGET: &str = "{{target}}";
12841285

12851286
if value.contains(CWD) {
12861287
let cwd = env::current_dir().unwrap();
@@ -1303,6 +1304,10 @@ fn expand_variables(mut value: String, config: &Config) -> String {
13031304
value = value.replace(TARGET_LINKER, config.target_linker.as_deref().unwrap_or(""));
13041305
}
13051306

1307+
if value.contains(TARGET) {
1308+
value = value.replace(TARGET, &config.target);
1309+
}
1310+
13061311
value
13071312
}
13081313

‎src/tools/tidy/src/target_specific_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub fn check(path: &Path, bad: &mut bool) {
5353
} else if directive.starts_with(COMPILE_FLAGS_HEADER) {
5454
let compile_flags = &directive[COMPILE_FLAGS_HEADER.len()..];
5555
if let Some((_, v)) = compile_flags.split_once("--target") {
56-
if let Some((arch, _)) =
57-
v.trim_start_matches(|c| c == ' ' || c == '=').split_once("-")
58-
{
56+
let v = v.trim_start_matches(|c| c == ' ' || c == '=');
57+
let v = if v == "{{target}}" { Some((v, v)) } else { v.split_once("-") };
58+
if let Some((arch, _)) = v {
5959
let info = header_map.entry(revision).or_insert(RevisionInfo::default());
6060
info.target_arch.replace(arch);
6161
} else {

0 commit comments

Comments
 (0)
Failed to load comments.