Skip to content

Commit

Permalink
Migrate run-make/comment-section to rmake.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rejyr committed Jun 16, 2024
1 parent 0909080 commit 9d6863e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/cdylib-fewer-symbols/Makefile
run-make/comment-section/Makefile
run-make/compiler-lookup-paths-2/Makefile
run-make/compiler-lookup-paths/Makefile
run-make/compiler-rt-works-on-mingw/Makefile
Expand Down
18 changes: 0 additions & 18 deletions tests/run-make/comment-section/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions tests/run-make/comment-section/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
44 changes: 44 additions & 0 deletions tests/run-make/comment-section/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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

use std::path::PathBuf;

use run_make_support::llvm_readobj;
use run_make_support::rustc;
use run_make_support::{cwd, env_var, read_dir, run_in_tmpdir};

fn main() {
let target = env_var("TARGET");

run_in_tmpdir(|| {
let p = cwd();

rustc().input("main.rs").emit("link,obj").arg("-Csave-temps").target(&target).run();

// Check linked output has a `.comment` section with the expected content.
llvm_readobj()
.gnu_elf_style()
.section(".comment")
.arg(PathBuf::from(&p).join("main"))
.run()
.assert_stdout_contains("rustc version 1.");

// Check all object files (including temporary outputs) have a `.comment`
// section with the expected content.
read_dir(p, |f| {
if f.extension() != Some(".o".as_ref()) {
return;
}
llvm_readobj()
.gnu_elf_style()
.section(".comment")
.arg(&f)
.run()
.assert_stdout_contains("rustc version 1.");
});
})
}

0 comments on commit 9d6863e

Please sign in to comment.