From 2453a68ad4d679788ad87f96f8219d4980e8d4e7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 17 Jul 2026 17:49:21 -0400 Subject: [PATCH 1/2] Add command to run specified UI tests --- build_system/src/test.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index c7f104ca4ca..fcbc09b2708 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -28,6 +28,7 @@ fn get_runners() -> Runners { ("Run failing ui pattern tests", test_failing_ui_pattern_tests), ); runners.insert("--test-failing-rustc", ("Run failing rustc tests", test_failing_rustc)); + runners.insert("--run-ui-tests", ("Run specified rustc UI tests", run_ui_tests)); runners.insert("--projects", ("Run the tests of popular crates", test_projects)); runners.insert("--test-libcore", ("Run libcore tests", test_libcore)); runners.insert("--alloc-tests", ("Run alloc tests", test_alloc)); @@ -1218,6 +1219,45 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String ) } +fn run_ui_tests(env: &Env, args: &TestArg) -> Result<(), String> { + let mut env = env.clone(); + let rust_path = setup_rustc(&mut env, args)?; + + let extra = + if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" }; + + let rustc_args = format!( + "{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}", + test_flags = env.get("TEST_FLAGS").unwrap_or(&String::new()), + backend = args.config_info.cg_backend_path, + sysroot = args.config_info.sysroot_path, + extra = extra, + ); + + env.get_mut("RUSTFLAGS").unwrap().clear(); + + let mut command: Vec<&dyn AsRef> = vec![ + &"./x.py", + &"test", + &"--run", + &"always", + &"--stage", + &"0", + &"--set", + &"build.compiletest-allow-stage0=true", + &"--compiletest-rustc-args", + &rustc_args, + &"--bypass-ignore-backends", + ]; + + for test_name in &args.test_args { + command.push(test_name); + } + + run_command_with_output_and_env(&command, Some(&rust_path), Some(&env))?; + Ok(()) +} + fn retain_files_callback<'a>( file_path: &'a str, test_type: &'a str, From d5ed2d4b20de839b4fe7bf9924151629be36826d Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 17 Jul 2026 17:49:54 -0400 Subject: [PATCH 2/2] Implement stack protector --- src/gcc_util.rs | 9 ++++++++- tests/failing-ui-tests.txt | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gcc_util.rs b/src/gcc_util.rs index 2615d93e427..79bbb8a72df 100644 --- a/src/gcc_util.rs +++ b/src/gcc_util.rs @@ -7,7 +7,7 @@ use gccjit::Version; use rustc_codegen_ssa::target_features; use rustc_data_structures::smallvec::{SmallVec, smallvec}; use rustc_session::Session; -use rustc_target::spec::{Arch, RelocModel}; +use rustc_target::spec::{Arch, RelocModel, StackProtector}; fn gcc_features_by_flags(sess: &Session, features: &mut Vec) { target_features::retpoline_features_by_flags(sess, features); @@ -204,6 +204,13 @@ pub fn new_context<'gcc>(sess: &Session) -> Context<'gcc> { }); } + match sess.stack_protector() { + StackProtector::All => context.add_command_line_option("-fstack-protector-all"), + StackProtector::Strong => context.add_command_line_option("-fstack-protector-strong"), + StackProtector::Basic => context.add_command_line_option("-fstack-protector"), + StackProtector::None => (), + } + add_pic_option(&context, sess.relocation_model()); let target_cpu = target_cpu(sess); diff --git a/tests/failing-ui-tests.txt b/tests/failing-ui-tests.txt index 5d55ad31d1e..97a58cc89af 100644 --- a/tests/failing-ui-tests.txt +++ b/tests/failing-ui-tests.txt @@ -106,6 +106,5 @@ tests/ui/eii/static/default_cross_crate_explicit.rs tests/ui/explicit-tail-calls/tailcc-no-signature-restriction.rs tests/ui/abi/rust-tail-cc.rs tests/ui/abi/rust-preserve-none-cc.rs -tests/ui/abi/stack-protector.rs tests/ui/extern/extern-types-field-offset.rs tests/ui/abi/stack-probes-lto.rs