Skip to content

Commit d6ff779

Browse files
committed
Migrate run-make/comment-section to rmake.rs
1 parent c349d08 commit d6ff779

File tree

3 files changed

+47
-19
lines changed

3 files changed

+47
-19
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
1111
run-make/cat-and-grep-sanity-check/Makefile
1212
run-make/cdylib-dylib-linkage/Makefile
1313
run-make/cdylib-fewer-symbols/Makefile
14-
run-make/comment-section/Makefile
1514
run-make/compiler-lookup-paths-2/Makefile
1615
run-make/compiler-lookup-paths/Makefile
1716
run-make/compiler-rt-works-on-mingw/Makefile

tests/run-make/comment-section/Makefile

-18
This file was deleted.
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Both GCC and Clang write by default a `.comment` section with compiler information.
2+
// Rustc received a similar .comment section, so this tests checks that this section
3+
// properly appears.
4+
// See https://github.com/rust-lang/rust/commit/74b8d324eb77a8f337b35dc68ac91b0c2c06debc
5+
6+
//@ only-linux
7+
// FIXME(jieyouxu): check cross-compile setup
8+
//@ ignore-cross-compile
9+
10+
use std::path::PathBuf;
11+
12+
use run_make_support::llvm_readobj;
13+
use run_make_support::rustc;
14+
use run_make_support::{cwd, env_var, read_dir, run_in_tmpdir};
15+
16+
fn main() {
17+
let target = env_var("TARGET");
18+
19+
rustc()
20+
.arg("-")
21+
.stdin("fn main() {}")
22+
.emit("link,obj")
23+
.arg("-Csave-temps")
24+
.target(&target)
25+
.run();
26+
27+
// Check linked output has a `.comment` section with the expected content.
28+
llvm_readobj()
29+
.section(".comment")
30+
.input("rust_out")
31+
.run()
32+
.assert_stdout_contains("rustc version 1.");
33+
34+
// Check all object files (including temporary outputs) have a `.comment`
35+
// section with the expected content.
36+
read_dir(cwd(), |f| {
37+
if !f.extension().is_some_and(|ext| ext == "o") {
38+
return;
39+
}
40+
41+
llvm_readobj()
42+
.section(".comment")
43+
.input(&f)
44+
.run()
45+
.assert_stdout_contains("rustc version 1.");
46+
});
47+
}

0 commit comments

Comments
 (0)