mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Migrate run-make/comment-section
to rmake.rs
This commit is contained in:
parent
5c8459f1ec
commit
f44494cb3a
@ -10,7 +10,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
|
||||
|
@ -1,18 +0,0 @@
|
||||
# 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
|
||||
|
||||
include ../tools.mk
|
||||
|
||||
# only-linux
|
||||
|
||||
all:
|
||||
echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps --target=$(TARGET)
|
||||
|
||||
# Check linked output has a `.comment` section with the expected content.
|
||||
readelf -p '.comment' $(TMPDIR)/rust_out | $(CGREP) -F 'rustc version 1.'
|
||||
|
||||
# Check all object files (including temporary outputs) have a `.comment`
|
||||
# section with the expected content.
|
||||
set -e; for f in $(TMPDIR)/*.o; do \
|
||||
readelf -p '.comment' $$f | $(CGREP) -F 'rustc version 1.'; \
|
||||
done
|
47
tests/run-make/comment-section/rmake.rs
Normal file
47
tests/run-make/comment-section/rmake.rs
Normal file
@ -0,0 +1,47 @@
|
||||
// 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::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");
|
||||
|
||||
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.
|
||||
read_dir(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.");
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user