From 48c5208b6c222515707753aa625b655fe7f7ff69 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 19 Oct 2023 07:48:42 -0400 Subject: [PATCH] Build the sysroot and run more tests --- .github/workflows/gcc12.yml | 29 ++++++++++++++--------------- build_system/src/build.rs | 30 +++++++++++++++++++----------- src/type_.rs | 6 ++++++ tests/lang_tests_common.rs | 24 ++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 28 deletions(-) diff --git a/.github/workflows/gcc12.yml b/.github/workflows/gcc12.yml index 59e0c5ad234..6642c9b55d6 100644 --- a/.github/workflows/gcc12.yml +++ b/.github/workflows/gcc12.yml @@ -11,6 +11,9 @@ env: # Enable backtraces for easier debugging RUST_BACKTRACE: 1 TEST_FLAGS: "-Cpanic=abort -Zpanic-abort-tests" + # FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin. + # Not sure why it's not found otherwise. + GCC_EXEC_PREFIX: /usr/lib/gcc/ jobs: build: @@ -22,15 +25,16 @@ jobs: commands: [ "--mini-tests", # TODO(antoyo): re-enable those commands when the build with libgccjit 12 is fixed. - #"--std-tests", + "--std-tests", # FIXME: re-enable asm tests when GCC can emit in the right syntax. # "--asm-tests", - #"--test-libcore", - #"--extended-rand-tests", - #"--extended-regex-example-tests", - #"--extended-regex-tests", - #"--test-successful-rustc --nb-parts 2 --current-part 0", - #"--test-successful-rustc --nb-parts 2 --current-part 1", + "--test-libcore", + "--extended-rand-tests", + "--extended-regex-example-tests", + "--extended-regex-tests", + "--test-successful-rustc --nb-parts 2 --current-part 0", + "--test-successful-rustc --nb-parts 2 --current-part 1", + # TODO: move to failures.yml. #"--test-failing-rustc", ] @@ -94,10 +98,8 @@ jobs: - name: Build run: | ./y.sh prepare --only-libcore - # TODO(antoyo): build the sysroot when the build with libgccjit 12 is fixed. - #./y.sh build --no-default-features - # TODO(antoyo): run the tests when we can build the sysroot with libgccjit 12. - #cargo test --no-default-features + ./y.sh build --no-default-features --sysroot-panic-abort + cargo test --no-default-features ./clean_all.sh - name: Prepare dependencies @@ -118,7 +120,4 @@ jobs: - name: Run tests run: | - # TODO(antoyo): add --build-sysroot when the build with libgccjit 12 is fixed. - # FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin. - # Not sure why it's not found otherwise. - GCC_EXEC_PREFIX=/usr/lib/gcc/ ./test.sh --release --clean ${{ matrix.commands }} --no-default-features + ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} --no-default-features diff --git a/build_system/src/build.rs b/build_system/src/build.rs index 0428c6b2cda..c2db11a7129 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -11,6 +11,7 @@ use std::path::Path; struct BuildArg { codegen_release_channel: bool, sysroot_release_channel: bool, + sysroot_panic_abort: bool, features: Vec, gcc_path: String, } @@ -32,6 +33,9 @@ impl BuildArg { "--no-default-features" => { build_arg.features.push("--no-default-features".to_string()); } + "--sysroot-panic-abort" => { + build_arg.sysroot_panic_abort = true; + }, "--features" => { if let Some(arg) = args.next() { build_arg.features.push("--features".to_string()); @@ -59,6 +63,7 @@ impl BuildArg { --release : Build codegen in release mode --release-sysroot : Build sysroot in release mode + --sysroot-panic-abort : Build the sysroot without unwinding support. --no-default-features : Add `--no-default-features` flag --features [arg] : Add a new feature [arg] --help : Show this help @@ -69,7 +74,7 @@ impl BuildArg { fn build_sysroot( env: &mut HashMap, - release_mode: bool, + args: &BuildArg, target_triple: &str, ) -> Result<(), String> { std::env::set_current_dir("build_sysroot") @@ -119,15 +124,18 @@ fn build_sysroot( let _ = fs::remove_dir_all("sysroot"); // Builds libs - let channel = if release_mode { - let rustflags = env - .get("RUSTFLAGS") - .cloned() - .unwrap_or_default(); - env.insert( - "RUSTFLAGS".to_string(), - format!("{} -Zmir-opt-level=3", rustflags), - ); + let mut rustflags = env + .get("RUSTFLAGS") + .cloned() + .unwrap_or_default(); + if args.sysroot_panic_abort { + rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests"); + } + env.insert( + "RUSTFLAGS".to_string(), + format!("{} -Zmir-opt-level=3", rustflags), + ); + let channel = if args.sysroot_release_channel { run_command_with_output_and_env( &[ &"cargo", @@ -217,7 +225,7 @@ fn build_codegen(args: &BuildArg) -> Result<(), String> { println!("[BUILD] sysroot"); build_sysroot( &mut env, - args.sysroot_release_channel, + args, &config.target_triple, )?; Ok(()) diff --git a/src/type_.rs b/src/type_.rs index 31899740514..3428df11f50 100644 --- a/src/type_.rs +++ b/src/type_.rs @@ -228,6 +228,12 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> { } }*/ + // NOTE: see note above. Some other test uses usize::MAX. + #[cfg(not(feature="master"))] + if len >= i32::MAX as u64 { + len = 0; + } + self.context.new_array_type(None, ty, len) } } diff --git a/tests/lang_tests_common.rs b/tests/lang_tests_common.rs index 06de26f7efc..fe74f6c6c4d 100644 --- a/tests/lang_tests_common.rs +++ b/tests/lang_tests_common.rs @@ -1,7 +1,7 @@ //! The common code for `tests/lang_tests_*.rs` use std::{ env::{self, current_dir}, - path::PathBuf, + path::{Path, PathBuf}, process::Command, }; @@ -23,9 +23,29 @@ pub fn main_inner(profile: Profile) { let gcc_path = include_str!("../gcc_path"); let gcc_path = gcc_path.trim(); env::set_var("LD_LIBRARY_PATH", gcc_path); + + fn rust_filter(filename: &Path) -> bool { + filename.extension().expect("extension").to_str().expect("to_str") == "rs" + } + + #[cfg(feature="master")] + fn filter(filename: &Path) -> bool { + rust_filter(filename) + } + + #[cfg(not(feature="master"))] + fn filter(filename: &Path) -> bool { + if let Some(filename) = filename.to_str() { + if filename.ends_with("gep.rs") { + return false; + } + } + rust_filter(filename) + } + LangTester::new() .test_dir("tests/run") - .test_file_filter(|path| path.extension().expect("extension").to_str().expect("to_str") == "rs") + .test_file_filter(filter) .test_extract(|source| { let lines = source.lines()