Skip to content

Commit 9d6863e

Browse files
committed
Migrate run-make/comment-section to rmake.rs
1 parent 0909080 commit 9d6863e

File tree

4 files changed

+45
-19
lines changed

4 files changed

+45
-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.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
8+
use std::path::PathBuf;
9+
10+
use run_make_support::llvm_readobj;
11+
use run_make_support::rustc;
12+
use run_make_support::{cwd, env_var, read_dir, run_in_tmpdir};
13+
14+
fn main() {
15+
let target = env_var("TARGET");
16+
17+
run_in_tmpdir(|| {
18+
let p = cwd();
19+
20+
rustc().input("main.rs").emit("link,obj").arg("-Csave-temps").target(&target).run();
21+
22+
// Check linked output has a `.comment` section with the expected content.
23+
llvm_readobj()
24+
.gnu_elf_style()
25+
.section(".comment")
26+
.arg(PathBuf::from(&p).join("main"))
27+
.run()
28+
.assert_stdout_contains("rustc version 1.");
29+
30+
// Check all object files (including temporary outputs) have a `.comment`
31+
// section with the expected content.
32+
read_dir(p, |f| {
33+
if f.extension() != Some(".o".as_ref()) {
34+
return;
35+
}
36+
llvm_readobj()
37+
.gnu_elf_style()
38+
.section(".comment")
39+
.arg(&f)
40+
.run()
41+
.assert_stdout_contains("rustc version 1.");
42+
});
43+
})
44+
}

0 commit comments

Comments
 (0)