From 8ca549754a4878b3033b9930cf18d1cdd16fa527 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Sat, 31 Aug 2024 10:36:19 +0800 Subject: [PATCH 1/3] use parallel front end(-Zthreads=2) in ui tests --- src/tools/compiletest/src/command-list.rs | 1 + src/tools/compiletest/src/header.rs | 5 +++++ src/tools/compiletest/src/runtest.rs | 13 +++++++++---- tests/ui/fuel/optimization-fuel-0.rs | 2 +- tests/ui/fuel/optimization-fuel-1.rs | 2 +- tests/ui/fuel/print-fuel.rs | 1 + tests/ui/lint/issue-79546-fuel-ice.rs | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs index 50c909793f5e..b79c2c6d572d 100644 --- a/src/tools/compiletest/src/command-list.rs +++ b/src/tools/compiletest/src/command-list.rs @@ -227,6 +227,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "rustfix-only-machine-applicable", "should-fail", "should-ice", + "single-thread", "stderr-per-bitwidth", "test-mir-pass", "unique-doc-out-dir", diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 1fc24301c85e..82cc27c3b644 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -137,6 +137,8 @@ pub struct TestProps { pub dont_check_compiler_stdout: bool, // For UI tests, allows compiler to generate arbitrary output to stderr pub dont_check_compiler_stderr: bool, + // Use single thread for the rustc front end. + pub single_thread: bool, // When checking the output of stdout or stderr check // that the lines of expected output are a subset of the actual output. pub compare_output_lines_by_subset: bool, @@ -259,6 +261,7 @@ mod directives { pub const KNOWN_BUG: &'static str = "known-bug"; pub const TEST_MIR_PASS: &'static str = "test-mir-pass"; pub const REMAP_SRC_BASE: &'static str = "remap-src-base"; + pub const SINGLE_THREAD: &'static str = "single-thread"; pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset"; pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags"; pub const FILECHECK_FLAGS: &'static str = "filecheck-flags"; @@ -291,6 +294,7 @@ impl TestProps { build_aux_docs: false, unique_doc_out_dir: false, force_host: false, + single_thread: false, check_stdout: false, check_run_results: false, dont_check_compiler_stdout: false, @@ -582,6 +586,7 @@ impl TestProps { |s| s.trim().to_string(), ); config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base); + config.set_name_directive(ln, SINGLE_THREAD, &mut self.single_thread); config.set_name_directive( ln, COMPARE_OUTPUT_LINES_BY_SUBSET, diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 59fce44d1c72..166075c3b0c5 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2058,8 +2058,12 @@ impl<'test> TestCx<'test> { }; rustc.arg(input_file); - // Use a single thread for efficiency and a deterministic error message order - rustc.arg("-Zthreads=1"); + // Use parallel front end or not + if self.props.single_thread { + rustc.arg("-Zthreads=1"); + } else { + rustc.arg("-Zthreads=2"); + } // Hide libstd sources from ui tests to make sure we generate the stderr // output that users will see. @@ -4524,8 +4528,9 @@ impl<'test> TestCx<'test> { // provide extra output on failure, for example a WebAssembly runtime // might print the stack trace of an `unreachable` instruction by // default. - let compare_output_by_lines = - self.props.compare_output_lines_by_subset || self.config.runner.is_some(); + let compare_output_by_lines = !self.props.single_thread + || self.props.compare_output_lines_by_subset + || self.config.runner.is_some(); let tmp; let (expected, actual): (&str, &str) = if compare_output_by_lines { diff --git a/tests/ui/fuel/optimization-fuel-0.rs b/tests/ui/fuel/optimization-fuel-0.rs index cbcb1d329a3c..9ea312ce928b 100644 --- a/tests/ui/fuel/optimization-fuel-0.rs +++ b/tests/ui/fuel/optimization-fuel-0.rs @@ -5,7 +5,7 @@ use std::mem::size_of; //@ compile-flags: -Z fuel=foo=0 - +//@ single-thread #[allow(dead_code)] struct S1(u8, u16, u8); #[allow(dead_code)] diff --git a/tests/ui/fuel/optimization-fuel-1.rs b/tests/ui/fuel/optimization-fuel-1.rs index 97edb0bd2595..e0023e641cae 100644 --- a/tests/ui/fuel/optimization-fuel-1.rs +++ b/tests/ui/fuel/optimization-fuel-1.rs @@ -5,7 +5,7 @@ use std::mem::size_of; //@ compile-flags: -Z fuel=foo=1 - +//@ single-thread #[allow(dead_code)] struct S1(u8, u16, u8); #[allow(dead_code)] diff --git a/tests/ui/fuel/print-fuel.rs b/tests/ui/fuel/print-fuel.rs index fd7e568bea7a..99741b463521 100644 --- a/tests/ui/fuel/print-fuel.rs +++ b/tests/ui/fuel/print-fuel.rs @@ -3,6 +3,7 @@ // (#55495: The --error-format is to sidestep an issue in our test harness) //@ compile-flags: -C opt-level=0 --error-format human -Z print-fuel=foo +//@ single-thread //@ check-pass struct S1(u8, u16, u8); diff --git a/tests/ui/lint/issue-79546-fuel-ice.rs b/tests/ui/lint/issue-79546-fuel-ice.rs index dbee924d26e7..ef36b6326da3 100644 --- a/tests/ui/lint/issue-79546-fuel-ice.rs +++ b/tests/ui/lint/issue-79546-fuel-ice.rs @@ -1,6 +1,7 @@ // Regression test for the ICE described in #79546. //@ compile-flags: --cap-lints=allow -Zfuel=issue79546=0 +//@ single-thread //@ check-pass #![crate_name="issue79546"] From 24a1c6663937156849cb8533ca44d1030b5209bc Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Mon, 2 Sep 2024 16:14:29 +0800 Subject: [PATCH 2/3] disable global cache insert assert --- compiler/rustc_type_ir/src/search_graph/global_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_type_ir/src/search_graph/global_cache.rs b/compiler/rustc_type_ir/src/search_graph/global_cache.rs index 47f7cefac6ad..639176206e29 100644 --- a/compiler/rustc_type_ir/src/search_graph/global_cache.rs +++ b/compiler/rustc_type_ir/src/search_graph/global_cache.rs @@ -59,7 +59,7 @@ impl GlobalCache { assert!(prev.is_none()); } else { let prev = entry.success.replace(Success { additional_depth, nested_goals, result }); - assert!(prev.is_none()); + // assert!(prev.is_none()); } } From 57b7e1a9cae659b31a968b22e5a25c0381eb6a25 Mon Sep 17 00:00:00 2001 From: SparrowLii Date: Mon, 2 Sep 2024 16:24:50 +0800 Subject: [PATCH 3/3] test again --- compiler/rustc_type_ir/src/search_graph/global_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_type_ir/src/search_graph/global_cache.rs b/compiler/rustc_type_ir/src/search_graph/global_cache.rs index 639176206e29..3578ee3b8a87 100644 --- a/compiler/rustc_type_ir/src/search_graph/global_cache.rs +++ b/compiler/rustc_type_ir/src/search_graph/global_cache.rs @@ -58,7 +58,7 @@ impl GlobalCache { let prev = entry.with_overflow.insert(additional_depth, with_overflow); assert!(prev.is_none()); } else { - let prev = entry.success.replace(Success { additional_depth, nested_goals, result }); + let _prev = entry.success.replace(Success { additional_depth, nested_goals, result }); // assert!(prev.is_none()); } }