@@ -0,0 +1,45 @@ |
|
|
|
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 |
+rustc() |
|
18 |
+.arg("-") |
|
19 |
+.stdin("fn main() {}") |
|
20 |
+.emit("link,obj") |
|
21 |
+.arg("-Csave-temps") |
|
22 |
+.target(&target) |
|
23 |
+.run(); |
|
24 |
+ |
|
25 |
+// Check linked output has a `.comment` section with the expected content. |
|
26 |
+llvm_readobj() |
|
27 |
+.section(".comment") |
|
28 |
+.input("rust_out") |
|
29 |
+.run() |
|
30 |
+.assert_stdout_contains("rustc version 1."); |
|
31 |
+ |
|
32 |
+// Check all object files (including temporary outputs) have a `.comment` |
|
33 |
+// section with the expected content. |
|
34 |
+read_dir(cwd(), |f |
|
35 |
+if !f.extension().is_some_and(|ext |
|
36 |
+return; |
|
37 |
+} |
|
38 |
+ |
|
39 |
+llvm_readobj() |
|
40 |
+.section(".comment") |
|
41 |
+.input(&f) |
|
42 |
+.run() |
|
43 |
+.assert_stdout_contains("rustc version 1."); |
|
44 |
+}); |
|
45 |
+} |