Skip to content

Commit

Permalink
Build the sysroot and run more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Oct 19, 2023
1 parent a9f31ab commit 48c5208
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 28 deletions.
29 changes: 14 additions & 15 deletions .github/workflows/gcc12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
]

Expand Down Expand Up @@ -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
Expand All @@ -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
30 changes: 19 additions & 11 deletions build_system/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::path::Path;
struct BuildArg {
codegen_release_channel: bool,
sysroot_release_channel: bool,
sysroot_panic_abort: bool,
features: Vec<String>,
gcc_path: String,
}
Expand All @@ -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());
Expand Down Expand Up @@ -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
Expand All @@ -69,7 +74,7 @@ impl BuildArg {

fn build_sysroot(
env: &mut HashMap<String, String>,
release_mode: bool,
args: &BuildArg,
target_triple: &str,
) -> Result<(), String> {
std::env::set_current_dir("build_sysroot")
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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(())
Expand Down
6 changes: 6 additions & 0 deletions src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
24 changes: 22 additions & 2 deletions tests/lang_tests_common.rs
Original file line number Diff line number Diff line change
@@ -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,
};

Expand All @@ -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()
Expand Down

0 comments on commit 48c5208

Please sign in to comment.