Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f72bf8b

Browse files
committedJul 25, 2024
rewrite panic-abort-eh_frame to rmake
1 parent 0d52289 commit f72bf8b

File tree

4 files changed

+66
-36
lines changed

4 files changed

+66
-36
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ run-make/native-link-modifier-bundle/Makefile
4141
run-make/native-link-modifier-whole-archive/Makefile
4242
run-make/no-alloc-shim/Makefile
4343
run-make/no-builtins-attribute/Makefile
44-
run-make/panic-abort-eh_frame/Makefile
4544
run-make/pdb-buildinfo-cl-cmd/Makefile
4645
run-make/pgo-gen-lto/Makefile
4746
run-make/pgo-indirect-call-promotion/Makefile

‎tests/run-make/dump-ice-to-disk/rmake.rs

+42-25
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,56 @@
66
// - Check that the ICE files contain some of the expected strings.
77
// See https://github.com/rust-lang/rust/pull/108714
88

9-
// FIXME(Oneirical): try it on Windows!
10-
11-
use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files};
9+
use run_make_support::{cwd, has_extension, has_prefix, rfs, rustc, shallow_find_files};
1210

1311
fn main() {
1412
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
15-
let ice_text = get_text_from_ice();
13+
let default = get_text_from_ice(".").lines().count();
14+
clear_ice_files();
15+
16+
rustc().env("RUSTC_ICE", cwd()).input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
17+
let ice_text = get_text_from_ice(cwd());
1618
let default_set = ice_text.lines().count();
1719
let content = ice_text;
18-
// Ensure that the ICE files don't contain `:` in their filename because
19-
// this causes problems on Windows.
20-
for file in shallow_find_files(cwd(), |path| {
20+
let ice_files = shallow_find_files(cwd(), |path| {
2121
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
22-
}) {
23-
assert!(!file.display().to_string().contains(":"));
24-
}
22+
});
23+
assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file.
24+
let ice_file_name =
25+
ice_files.first().and_then(|f| f.file_name()).and_then(|n| n.to_str()).unwrap();
26+
// Ensure that the ICE dump path doesn't contain `:`, because they cause problems on Windows.
27+
assert!(!ice_file_name.contains(":"), "{ice_file_name}");
2528

2629
clear_ice_files();
27-
rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail();
28-
let short = get_text_from_ice().lines().count();
30+
rustc()
31+
.env("RUSTC_ICE", cwd())
32+
.input("lib.rs")
33+
.env("RUST_BACKTRACE", "short")
34+
.arg("-Ztreat-err-as-bug=1")
35+
.run_fail();
36+
let short = get_text_from_ice(cwd()).lines().count();
2937
clear_ice_files();
30-
rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail();
31-
let full = get_text_from_ice().lines().count();
38+
rustc()
39+
.env("RUSTC_ICE", cwd())
40+
.input("lib.rs")
41+
.env("RUST_BACKTRACE", "full")
42+
.arg("-Ztreat-err-as-bug=1")
43+
.run_fail();
44+
let full = get_text_from_ice(cwd()).lines().count();
3245
clear_ice_files();
3346

34-
// The ICE dump is explicitely disabled. Therefore, this should produce no files.
47+
// The ICE dump is explicitly disabled. Therefore, this should produce no files.
3548
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
36-
assert!(get_text_from_ice().is_empty());
49+
let ice_files = shallow_find_files(cwd(), |path| {
50+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
51+
});
52+
assert!(ice_files.is_empty()); // There should be 0 ICE files.
3753

3854
// The line count should not change.
3955
assert_eq!(short, default_set);
56+
assert_eq!(short, default);
4057
assert_eq!(full, default_set);
58+
assert!(default > 0);
4159
// Some of the expected strings in an ICE file should appear.
4260
assert!(content.contains("thread 'rustc' panicked at"));
4361
assert!(content.contains("stack backtrace:"));
@@ -48,17 +66,16 @@ fn clear_ice_files() {
4866
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
4967
});
5068
for file in ice_files {
51-
fs_wrapper::remove_file(file);
69+
rfs::remove_file(file);
5270
}
5371
}
5472

55-
fn get_text_from_ice() -> String {
56-
let ice_files = shallow_find_files(cwd(), |path| {
57-
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
58-
});
59-
let mut output = String::new();
60-
for file in ice_files {
61-
output.push_str(&fs_wrapper::read_to_string(file));
62-
}
73+
#[track_caller]
74+
fn get_text_from_ice(dir: impl AsRef<std::path::Path>) -> String {
75+
let ice_files =
76+
shallow_find_files(dir, |path| has_prefix(path, "rustc-ice") && has_extension(path, "txt"));
77+
assert_eq!(ice_files.len(), 1); // There should only be 1 ICE file.
78+
let ice_file = ice_files.get(0).unwrap();
79+
let output = rfs::read_to_string(ice_file);
6380
output
6481
}

‎tests/run-make/panic-abort-eh_frame/Makefile

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate
2+
// being inserted, useful for determining whether or not unwinding is necessary.
3+
// This is useless when panics would NEVER unwind due to -C panic=abort. This section should
4+
// therefore never appear in the emit file of a -C panic=abort compilation, and this test
5+
// checks that this is respected.
6+
// See https://github.com/rust-lang/rust/pull/112403
7+
8+
//@ only-linux
9+
// FIXME(Oneirical): the DW_CFA symbol appears on Windows-gnu, because uwtable
10+
// is forced to true on Windows targets (see #128136).
11+
12+
use run_make_support::{llvm_objdump, rustc};
13+
14+
fn main() {
15+
rustc()
16+
.input("foo.rs")
17+
.crate_type("lib")
18+
.emit("obj=foo.o")
19+
.panic("abort")
20+
.edition("2021")
21+
.arg("-Zvalidate-mir")
22+
.run();
23+
llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA");
24+
}

0 commit comments

Comments
 (0)
Failed to load comments.