rust/tests/run-make/comment-section/rmake.rs
Nicholas Nethercote 84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00

46 lines
1.3 KiB
Rust

// 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
use std::path::PathBuf;
use run_make_support::{cwd, env_var, llvm_readobj, rfs, run_in_tmpdir, rustc};
fn main() {
let target = env_var("TARGET");
rustc()
.arg("-")
.stdin("fn main() {}")
.emit("link,obj")
.arg("-Csave-temps")
.target(target)
.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.
rfs::read_dir_entries(cwd(), |f| {
if !f.extension().is_some_and(|ext| ext == "o") {
return;
}
llvm_readobj()
.section(".comment")
.input(&f)
.run()
.assert_stdout_contains("rustc version 1.");
});
}