rewrite panic-abort-eh_frame to rmake
This commit is contained in:
parent
0d52289b5e
commit
f72bf8ba34
@ -41,7 +41,6 @@ run-make/native-link-modifier-bundle/Makefile
|
||||
run-make/native-link-modifier-whole-archive/Makefile
|
||||
run-make/no-alloc-shim/Makefile
|
||||
run-make/no-builtins-attribute/Makefile
|
||||
run-make/panic-abort-eh_frame/Makefile
|
||||
run-make/pdb-buildinfo-cl-cmd/Makefile
|
||||
run-make/pgo-gen-lto/Makefile
|
||||
run-make/pgo-indirect-call-promotion/Makefile
|
||||
|
@ -6,38 +6,56 @@
|
||||
// - Check that the ICE files contain some of the expected strings.
|
||||
// See https://github.com/rust-lang/rust/pull/108714
|
||||
|
||||
// FIXME(Oneirical): try it on Windows!
|
||||
|
||||
use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files};
|
||||
use run_make_support::{cwd, has_extension, has_prefix, rfs, rustc, shallow_find_files};
|
||||
|
||||
fn main() {
|
||||
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||
let ice_text = get_text_from_ice();
|
||||
let default = get_text_from_ice(".").lines().count();
|
||||
clear_ice_files();
|
||||
|
||||
rustc().env("RUSTC_ICE", cwd()).input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||
let ice_text = get_text_from_ice(cwd());
|
||||
let default_set = ice_text.lines().count();
|
||||
let content = ice_text;
|
||||
// Ensure that the ICE files don't contain `:` in their filename because
|
||||
// this causes problems on Windows.
|
||||
for file in shallow_find_files(cwd(), |path| {
|
||||
let ice_files = shallow_find_files(cwd(), |path| {
|
||||
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
|
||||
}) {
|
||||
assert!(!file.display().to_string().contains(":"));
|
||||
}
|
||||
});
|
||||
assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file.
|
||||
let ice_file_name =
|
||||
ice_files.first().and_then(|f| f.file_name()).and_then(|n| n.to_str()).unwrap();
|
||||
// Ensure that the ICE dump path doesn't contain `:`, because they cause problems on Windows.
|
||||
assert!(!ice_file_name.contains(":"), "{ice_file_name}");
|
||||
|
||||
clear_ice_files();
|
||||
rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||
let short = get_text_from_ice().lines().count();
|
||||
rustc()
|
||||
.env("RUSTC_ICE", cwd())
|
||||
.input("lib.rs")
|
||||
.env("RUST_BACKTRACE", "short")
|
||||
.arg("-Ztreat-err-as-bug=1")
|
||||
.run_fail();
|
||||
let short = get_text_from_ice(cwd()).lines().count();
|
||||
clear_ice_files();
|
||||
rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||
let full = get_text_from_ice().lines().count();
|
||||
rustc()
|
||||
.env("RUSTC_ICE", cwd())
|
||||
.input("lib.rs")
|
||||
.env("RUST_BACKTRACE", "full")
|
||||
.arg("-Ztreat-err-as-bug=1")
|
||||
.run_fail();
|
||||
let full = get_text_from_ice(cwd()).lines().count();
|
||||
clear_ice_files();
|
||||
|
||||
// The ICE dump is explicitely disabled. Therefore, this should produce no files.
|
||||
// The ICE dump is explicitly disabled. Therefore, this should produce no files.
|
||||
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
|
||||
assert!(get_text_from_ice().is_empty());
|
||||
let ice_files = shallow_find_files(cwd(), |path| {
|
||||
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
|
||||
});
|
||||
assert!(ice_files.is_empty()); // There should be 0 ICE files.
|
||||
|
||||
// The line count should not change.
|
||||
assert_eq!(short, default_set);
|
||||
assert_eq!(short, default);
|
||||
assert_eq!(full, default_set);
|
||||
assert!(default > 0);
|
||||
// Some of the expected strings in an ICE file should appear.
|
||||
assert!(content.contains("thread 'rustc' panicked at"));
|
||||
assert!(content.contains("stack backtrace:"));
|
||||
@ -48,17 +66,16 @@ fn clear_ice_files() {
|
||||
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
|
||||
});
|
||||
for file in ice_files {
|
||||
fs_wrapper::remove_file(file);
|
||||
rfs::remove_file(file);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_text_from_ice() -> String {
|
||||
let ice_files = shallow_find_files(cwd(), |path| {
|
||||
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
|
||||
});
|
||||
let mut output = String::new();
|
||||
for file in ice_files {
|
||||
output.push_str(&fs_wrapper::read_to_string(file));
|
||||
}
|
||||
#[track_caller]
|
||||
fn get_text_from_ice(dir: impl AsRef<std::path::Path>) -> String {
|
||||
let ice_files =
|
||||
shallow_find_files(dir, |path| has_prefix(path, "rustc-ice") && has_extension(path, "txt"));
|
||||
assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file.
|
||||
let ice_file = ice_files.get(0).unwrap();
|
||||
let output = rfs::read_to_string(ice_file);
|
||||
output
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
# only-linux
|
||||
#
|
||||
# This test ensures that `panic=abort` code (without `C-unwind`, that is) should not have any
|
||||
# unwinding related `.eh_frame` sections emitted.
|
||||
|
||||
include ../tools.mk
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort --edition 2021 -Z validate-mir
|
||||
objdump --dwarf=frames $(TMPDIR)/foo.o | $(CGREP) -v 'DW_CFA'
|
24
tests/run-make/panic-abort-eh_frame/rmake.rs
Normal file
24
tests/run-make/panic-abort-eh_frame/rmake.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate
|
||||
// being inserted, useful for determining whether or not unwinding is necessary.
|
||||
// This is useless when panics would NEVER unwind due to -C panic=abort. This section should
|
||||
// therefore never appear in the emit file of a -C panic=abort compilation, and this test
|
||||
// checks that this is respected.
|
||||
// See https://github.com/rust-lang/rust/pull/112403
|
||||
|
||||
//@ only-linux
|
||||
// FIXME(Oneirical): the DW_CFA symbol appears on Windows-gnu, because uwtable
|
||||
// is forced to true on Windows targets (see #128136).
|
||||
|
||||
use run_make_support::{llvm_objdump, rustc};
|
||||
|
||||
fn main() {
|
||||
rustc()
|
||||
.input("foo.rs")
|
||||
.crate_type("lib")
|
||||
.emit("obj=foo.o")
|
||||
.panic("abort")
|
||||
.edition("2021")
|
||||
.arg("-Zvalidate-mir")
|
||||
.run();
|
||||
llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA");
|
||||
}
|
Loading…
Reference in New Issue
Block a user