2024-06-15 20:47:27 -05:00
|
|
|
// Both GCC and Clang write by default a `.comment` section with compiler information.
|
|
|
|
// Rustc received a similar .comment section, so this tests checks that this section
|
|
|
|
// properly appears.
|
|
|
|
// See https://github.com/rust-lang/rust/commit/74b8d324eb77a8f337b35dc68ac91b0c2c06debc
|
|
|
|
|
|
|
|
//@ only-linux
|
|
|
|
// FIXME(jieyouxu): check cross-compile setup
|
|
|
|
//@ ignore-cross-compile
|
|
|
|
|
2024-08-10 13:06:10 -05:00
|
|
|
use run_make_support::{cwd, env_var, llvm_readobj, rfs, rustc};
|
2024-06-15 20:47:27 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let target = env_var("TARGET");
|
|
|
|
|
|
|
|
rustc()
|
|
|
|
.arg("-")
|
2024-09-04 19:02:32 -05:00
|
|
|
.stdin_buf("fn main() {}")
|
2024-06-15 20:47:27 -05:00
|
|
|
.emit("link,obj")
|
|
|
|
.arg("-Csave-temps")
|
2024-07-01 03:55:43 -05:00
|
|
|
.target(target)
|
2024-06-15 20:47:27 -05:00
|
|
|
.run();
|
|
|
|
|
|
|
|
// Check linked output has a `.comment` section with the expected content.
|
|
|
|
llvm_readobj()
|
|
|
|
.section(".comment")
|
|
|
|
.input("rust_out")
|
|
|
|
.run()
|
|
|
|
.assert_stdout_contains("rustc version 1.");
|
|
|
|
|
|
|
|
// Check all object files (including temporary outputs) have a `.comment`
|
|
|
|
// section with the expected content.
|
2024-07-17 07:42:06 -05:00
|
|
|
rfs::read_dir_entries(cwd(), |f| {
|
2024-06-15 20:47:27 -05:00
|
|
|
if !f.extension().is_some_and(|ext| ext == "o") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm_readobj()
|
|
|
|
.section(".comment")
|
|
|
|
.input(&f)
|
|
|
|
.run()
|
|
|
|
.assert_stdout_contains("rustc version 1.");
|
|
|
|
});
|
|
|
|
}
|