Skip to content

Commit 4f81879

Browse files
committed
Auto merge of rust-lang#124564 - jieyouxu:rollup-kuf5wlq, r=jieyouxu
Rollup of 4 pull requests Successful merges: - rust-lang#124280 (Port repr128-dwarf run-make test to rmake) - rust-lang#124299 (Add test for issue 106269) - rust-lang#124553 (Write `git-commit-{sha,info}` for Cargo in source tarballs) - rust-lang#124561 (Add `normalize()` in run-make `Diff` type) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 20aa2d8 + 7350a7f commit 4f81879

File tree

12 files changed

+164
-26
lines changed

12 files changed

+164
-26
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,6 +3318,7 @@ dependencies = [
33183318
name = "run_make_support"
33193319
version = "0.0.0"
33203320
dependencies = [
3321+
"gimli",
33213322
"object 0.34.0",
33223323
"regex",
33233324
"similar",

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::core::build_steps::llvm;
2525
use crate::core::build_steps::tool::{self, Tool};
2626
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2727
use crate::core::config::TargetSelection;
28-
use crate::utils::channel;
28+
use crate::utils::channel::{self, Info};
2929
use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit};
3030
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
3131
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
@@ -991,10 +991,17 @@ impl Step for PlainSourceTarball {
991991

992992
// Create the version file
993993
builder.create(&plain_dst_src.join("version"), &builder.rust_version());
994-
if let Some(info) = builder.rust_info().info() {
995-
channel::write_commit_hash_file(plain_dst_src, &info.sha);
996-
channel::write_commit_info_file(plain_dst_src, info);
997-
}
994+
995+
// Create the files containing git info, to ensure --version outputs the same.
996+
let write_git_info = |info: Option<&Info>, path: &Path| {
997+
if let Some(info) = info {
998+
t!(std::fs::create_dir_all(path));
999+
channel::write_commit_hash_file(path, &info.sha);
1000+
channel::write_commit_info_file(path, info);
1001+
}
1002+
};
1003+
write_git_info(builder.rust_info().info(), plain_dst_src);
1004+
write_git_info(builder.cargo_info.info(), &plain_dst_src.join("./src/tools/cargo"));
9981005

9991006
// If we're building from git or tarball sources, we need to vendor
10001007
// a complete distribution.

src/tools/compiletest/src/runtest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,6 +3825,7 @@ impl<'test> TestCx<'test> {
38253825
.arg(format!("-Ldependency={}", &support_lib_deps_deps.to_string_lossy()))
38263826
.arg("--extern")
38273827
.arg(format!("run_make_support={}", &support_lib_path.to_string_lossy()))
3828+
.arg("--edition=2021")
38283829
.arg(&self.testpaths.file.join("rmake.rs"))
38293830
.env("TARGET", &self.config.target)
38303831
.env("PYTHON", &self.config.python)

src/tools/run-make-support/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ object = "0.34.0"
88
similar = "2.5.0"
99
wasmparser = "0.118.2"
1010
regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
11+
gimli = "0.28.1"

src/tools/run-make-support/src/diff/mod.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use regex::Regex;
12
use similar::TextDiff;
23
use std::path::Path;
34

@@ -14,12 +15,19 @@ pub struct Diff {
1415
expected_name: Option<String>,
1516
actual: Option<String>,
1617
actual_name: Option<String>,
18+
normalizers: Vec<(String, String)>,
1719
}
1820

1921
impl Diff {
2022
/// Construct a bare `diff` invocation.
2123
pub fn new() -> Self {
22-
Self { expected: None, expected_name: None, actual: None, actual_name: None }
24+
Self {
25+
expected: None,
26+
expected_name: None,
27+
actual: None,
28+
actual_name: None,
29+
normalizers: Vec::new(),
30+
}
2331
}
2432

2533
/// Specify the expected output for the diff from a file.
@@ -58,15 +66,29 @@ impl Diff {
5866
self
5967
}
6068

69+
/// Specify a regex that should replace text in the "actual" text that will be compared.
70+
pub fn normalize<R: Into<String>, I: Into<String>>(
71+
&mut self,
72+
regex: R,
73+
replacement: I,
74+
) -> &mut Self {
75+
self.normalizers.push((regex.into(), replacement.into()));
76+
self
77+
}
78+
6179
/// Executes the diff process, prints any differences to the standard error.
6280
#[track_caller]
6381
pub fn run(&self) {
6482
let expected = self.expected.as_ref().expect("expected text not set");
65-
let actual = self.actual.as_ref().expect("actual text not set");
83+
let mut actual = self.actual.as_ref().expect("actual text not set").to_string();
6684
let expected_name = self.expected_name.as_ref().unwrap();
6785
let actual_name = self.actual_name.as_ref().unwrap();
86+
for (regex, replacement) in &self.normalizers {
87+
let re = Regex::new(regex).expect("bad regex in custom normalization rule");
88+
actual = re.replace_all(&actual, replacement).into_owned();
89+
}
6890

69-
let output = TextDiff::from_lines(expected, actual)
91+
let output = TextDiff::from_lines(expected, &actual)
7092
.unified_diff()
7193
.header(expected_name, actual_name)
7294
.to_string();

src/tools/run-make-support/src/diff/tests.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,26 @@ test failed: `EXPECTED_TEXT` is different from `ACTUAL_TEXT`
3636

3737
assert_eq!(output.downcast_ref::<String>().unwrap(), expected_output);
3838
}
39+
40+
#[test]
41+
fn test_normalize() {
42+
let expected = "
43+
running 2 tests
44+
..
45+
46+
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
47+
";
48+
let actual = "
49+
running 2 tests
50+
..
51+
52+
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
53+
";
54+
55+
diff()
56+
.expected_text("EXPECTED_TEXT", expected)
57+
.actual_text("ACTUAL_TEXT", actual)
58+
.normalize(r#"finished in \d+\.\d+s"#, "finished in $$TIME")
59+
.run();
60+
}
3961
}

src/tools/run-make-support/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::env;
1515
use std::path::{Path, PathBuf};
1616
use std::process::{Command, Output};
1717

18+
pub use gimli;
1819
pub use object;
1920
pub use regex;
2021
pub use wasmparser;

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ run-make/relocation-model/Makefile
235235
run-make/relro-levels/Makefile
236236
run-make/remap-path-prefix-dwarf/Makefile
237237
run-make/remap-path-prefix/Makefile
238-
run-make/repr128-dwarf/Makefile
239238
run-make/reproducible-build-2/Makefile
240239
run-make/reproducible-build/Makefile
241240
run-make/resolve-rename/Makefile

tests/assembly/manual-eq-efficient.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Regression test for #106269
2+
//@ assembly-output: emit-asm
3+
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
4+
//@ only-x86_64
5+
//@ ignore-sgx
6+
7+
pub struct S {
8+
a: u8,
9+
b: u8,
10+
c: u8,
11+
d: u8,
12+
}
13+
14+
// CHECK-LABEL: manual_eq:
15+
#[no_mangle]
16+
pub fn manual_eq(s1: &S, s2: &S) -> bool {
17+
// CHECK: mov [[REG:[a-z0-9]+]], dword ptr [{{[a-z0-9]+}}]
18+
// CHECK-NEXT: cmp [[REG]], dword ptr [{{[a-z0-9]+}}]
19+
// CHECK-NEXT: sete al
20+
// CHECK: ret
21+
s1.a == s2.a && s1.b == s2.b && s1.c == s2.c && s1.d == s2.d
22+
}

tests/run-make/repr128-dwarf/Makefile

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)