Skip to content

Commit 76a98e2

Browse files
authored
Unrolled build for rust-lang#127523
Rollup merge of rust-lang#127523 - Oneirical:treasure-test, r=jieyouxu Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: i686-mingw
2 parents 6ef11b8 + f72bf8b commit 76a98e2

File tree

7 files changed

+105
-86
lines changed

7 files changed

+105
-86
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ run-make/cross-lang-lto/Makefile
1010
run-make/dep-info-doesnt-run-much/Makefile
1111
run-make/dep-info-spaces/Makefile
1212
run-make/dep-info/Makefile
13-
run-make/dump-ice-to-disk/Makefile
1413
run-make/emit-to-stdout/Makefile
1514
run-make/export-executable-symbols/Makefile
1615
run-make/extern-flag-disambiguates/Makefile
@@ -42,7 +41,6 @@ run-make/native-link-modifier-bundle/Makefile
4241
run-make/native-link-modifier-whole-archive/Makefile
4342
run-make/no-alloc-shim/Makefile
4443
run-make/no-builtins-attribute/Makefile
45-
run-make/panic-abort-eh_frame/Makefile
4644
run-make/pdb-buildinfo-cl-cmd/Makefile
4745
run-make/pgo-gen-lto/Makefile
4846
run-make/pgo-indirect-call-promotion/Makefile

tests/run-make/dump-ice-to-disk/Makefile

-10
This file was deleted.

tests/run-make/dump-ice-to-disk/check.sh

-64
This file was deleted.
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This test checks if internal compilation error (ICE) log files work as expected.
2+
// - Get the number of lines from the log files without any configuration options,
3+
// then check that the line count doesn't change if the backtrace gets configured to be short
4+
// or full.
5+
// - Check that disabling ICE logging results in zero files created.
6+
// - Check that the ICE files contain some of the expected strings.
7+
// See https://github.com/rust-lang/rust/pull/108714
8+
9+
use run_make_support::{cwd, has_extension, has_prefix, rfs, rustc, shallow_find_files};
10+
11+
fn main() {
12+
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
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());
18+
let default_set = ice_text.lines().count();
19+
let content = ice_text;
20+
let ice_files = shallow_find_files(cwd(), |path| {
21+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
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}");
28+
29+
clear_ice_files();
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();
37+
clear_ice_files();
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();
45+
clear_ice_files();
46+
47+
// The ICE dump is explicitly disabled. Therefore, this should produce no files.
48+
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
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.
53+
54+
// The line count should not change.
55+
assert_eq!(short, default_set);
56+
assert_eq!(short, default);
57+
assert_eq!(full, default_set);
58+
assert!(default > 0);
59+
// Some of the expected strings in an ICE file should appear.
60+
assert!(content.contains("thread 'rustc' panicked at"));
61+
assert!(content.contains("stack backtrace:"));
62+
}
63+
64+
fn clear_ice_files() {
65+
let ice_files = shallow_find_files(cwd(), |path| {
66+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
67+
});
68+
for file in ice_files {
69+
rfs::remove_file(file);
70+
}
71+
}
72+
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);
80+
output
81+
}

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)