Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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<OsStr>> = 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,
Expand Down
9 changes: 8 additions & 1 deletion src/gcc_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) {
target_features::retpoline_features_by_flags(sess, features);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion tests/failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading