Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for the libgccjit 12 CI #357

Merged
merged 1 commit into from
Oct 25, 2023
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
44 changes: 31 additions & 13 deletions .github/workflows/failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,33 @@ jobs:
fail-fast: false
matrix:
libgccjit_version:
- { gcc: "libgccjit.so", artifacts_branch: "master" }
- { gcc: "libgccjit_without_int128.so", artifacts_branch: "master-without-128bit-integers" }
- gcc: "libgccjit.so"
artifacts_branch: "master"
- gcc: "libgccjit_without_int128.so"
artifacts_branch: "master-without-128bit-integers"
- gcc: "libgccjit12.so"
artifacts_branch: "gcc12"
extra: "--no-default-features"
# 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.
env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/"

steps:
- uses: actions/checkout@v3

- name: Install packages
run: sudo apt-get install ninja-build ripgrep

- name: Install libgccjit12
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
run: sudo apt-get install libgccjit-12-dev

- name: Setup path to libgccjit
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
run: echo /usr/lib/gcc/x86_64-linux-gnu/12 > gcc_path

- name: Download artifact
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
uses: dawidd6/action-download-artifact@v2
with:
workflow: main.yml
Expand All @@ -40,6 +57,7 @@ jobs:
search_artifacts: true # Because, instead, the action only check the last job ran and that won't work since we want multiple artifacts.

- name: Setup path to libgccjit
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
run: |
sudo dpkg --force-overwrite -i gcc-13/gcc-13.deb
echo /usr/lib/ > gcc_path
Expand Down Expand Up @@ -81,18 +99,18 @@ jobs:
#path: rust
#key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }}

- name: Build
run: |
./y.sh prepare --only-libcore
./y.sh build
cargo test
./clean_all.sh

- name: Prepare dependencies
- name: Git config
run: |
git config --global user.email "[email protected]"
git config --global user.name "User"
./y.sh prepare

- name: Prepare dependencies
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
run: ./y.sh prepare --libgccjit12-patches

- name: Prepare dependencies
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
run: ./y.sh prepare

# Compile is a separate step, as the actions-rs/cargo action supports error annotations
- name: Compile
Expand All @@ -107,5 +125,5 @@ jobs:
- name: Run tests
id: tests
run: |
./test.sh --release --clean --build-sysroot --test-failing-rustc | tee output_log
rg "test result" output_log >> $GITHUB_STEP_SUMMARY
${{ matrix.libgccjit_version.env_extra }} ./test.sh --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY
37 changes: 18 additions & 19 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 @@ -21,17 +24,15 @@ jobs:
matrix:
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-failing-rustc",
"--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",
]

steps:
Expand Down Expand Up @@ -85,18 +86,16 @@ 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 prepare --only-libcore --libgccjit12-patches
./y.sh build --no-default-features --sysroot-panic-abort
cargo test --no-default-features
./clean_all.sh

- name: Prepare dependencies
run: |
git config --global user.email "[email protected]"
git config --global user.name "User"
./y.sh prepare
./y.sh prepare --libgccjit12-patches

# Compile is a separate step, as the actions-rs/cargo action supports error annotations
- name: Compile
Expand All @@ -108,9 +107,9 @@ jobs:
- name: Add more failing tests for GCC 12
run: cat failing-ui-tests12.txt >> failing-ui-tests.txt

- name: Add more failing tests because the sysroot is not compiled with LTO
run: cat failing-non-lto-tests.txt >> failing-ui-tests.txt

- 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,
flags: Vec<String>,
gcc_path: String,
}
Expand All @@ -32,6 +33,9 @@ impl BuildArg {
"--no-default-features" => {
build_arg.flags.push("--no-default-features".to_string());
}
"--sysroot-panic-abort" => {
build_arg.sysroot_panic_abort = true;
},
"--features" => {
if let Some(arg) = args.next() {
build_arg.flags.push("--features".to_string());
Expand Down Expand Up @@ -77,6 +81,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]
--target-triple [arg] : Set the target triple to [arg]
Expand All @@ -88,7 +93,7 @@ impl BuildArg {

fn build_sysroot(
env: &mut HashMap<String, String>,
release_mode: bool,
args: &BuildArg,
config: &ConfigInfo,
) -> Result<(), String> {
std::env::set_current_dir("build_sysroot")
Expand Down Expand Up @@ -138,15 +143,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 @@ -224,7 +232,7 @@ fn build_codegen(args: &BuildArg) -> Result<(), String> {
println!("[BUILD] sysroot");
build_sysroot(
&mut env,
args.sysroot_release_channel,
args,
&config,
)?;
Ok(())
Expand Down
25 changes: 20 additions & 5 deletions build_system/src/prepare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::utils::{cargo_install, git_clone, run_command, run_command_with_outpu
use std::fs;
use std::path::Path;

fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), String> {
fn prepare_libcore(sysroot_path: &Path, libgccjit12_patches: bool, cross_compile: bool) -> Result<(), String> {
let rustc_path = match get_rustc_path() {
Some(path) => path,
None => return Err("`rustc` path not found".to_string()),
Expand Down Expand Up @@ -93,6 +93,16 @@ fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), Strin
Ok(())
})?;
}
if libgccjit12_patches {
walk_dir(
"patches/libgccjit12",
|_| Ok(()),
|file_path: &Path| {
patches.push(file_path.to_path_buf());
Ok(())
},
)?;
}
patches.sort();
for file_path in patches {
println!("[GIT] apply `{}`", file_path.display());
Expand Down Expand Up @@ -164,17 +174,20 @@ where
struct PrepareArg {
cross_compile: bool,
only_libcore: bool,
libgccjit12_patches: bool,
}

impl PrepareArg {
fn new() -> Result<Option<Self>, String> {
let mut only_libcore = false;
let mut cross_compile = false;
let mut libgccjit12_patches = false;

for arg in std::env::args().skip(2) {
match arg.as_str() {
"--only-libcore" => only_libcore = true,
"--cross" => cross_compile = true,
"--libgccjit12-patches" => libgccjit12_patches = true,
"--help" => {
Self::usage();
return Ok(None);
Expand All @@ -185,6 +198,7 @@ impl PrepareArg {
Ok(Some(Self {
cross_compile,
only_libcore,
libgccjit12_patches,
}))
}

Expand All @@ -193,9 +207,10 @@ impl PrepareArg {
r#"
`prepare` command help:

--only-libcore : Only setup libcore and don't clone other repositories
--cross : Apply the patches needed to do cross-compilation
--help : Show this help
--only-libcore : Only setup libcore and don't clone other repositories
--cross : Apply the patches needed to do cross-compilation
--libgccjit12-patches : Apply patches needed for libgccjit12
--help : Show this help
"#
)
}
Expand All @@ -207,7 +222,7 @@ pub fn run() -> Result<(), String> {
None => return Ok(()),
};
let sysroot_path = Path::new("build_sysroot");
prepare_libcore(sysroot_path, args.cross_compile)?;
prepare_libcore(sysroot_path, args.libgccjit12_patches, args.cross_compile)?;

if !args.only_libcore {
cargo_install("hyperfine")?;
Expand Down
8 changes: 4 additions & 4 deletions failing-ui-tests12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ tests/ui/simd/intrinsic/generic-reduction-pass.rs
tests/ui/simd/intrinsic/generic-select-pass.rs
tests/ui/simd/intrinsic/inlining-issue67557-ice.rs
tests/ui/simd/intrinsic/inlining-issue67557.rs
tests/ui/simd/monomorphize-shuffle-index.rs
tests/ui/simd/shuffle.rs
tests/ui/simd/simd-bitmask.rs
tests/ui/generator/resume-after-return.rs
tests/ui/iterators/iter-step-overflow-debug.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
tests/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
tests/ui/privacy/reachable-unnameable-items.rs
tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs
tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs
tests/ui/async-await/async-fn-size-moved-locals.rs
tests/ui/async-await/async-fn-size-uninit-locals.rs
tests/ui/cfg/cfg-panic.rs
Expand All @@ -38,3 +35,6 @@ tests/ui/simd/issue-85915-simd-ptrs.rs
tests/ui/issues/issue-68010-large-zst-consts.rs
tests/ui/rust-2018/proc-macro-crate-in-paths.rs
tests/ui/target-feature/missing-plusminus.rs
tests/ui/sse2.rs
tests/ui/codegen/issue-79865-llvm-miscompile.rs
tests/ui/intrinsics/intrinsics-integer.rs
32 changes: 32 additions & 0 deletions patches/libgccjit12/0001-core-Disable-portable-simd-test.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 7bcd24ec6d4a96121874cb1ae5a23ea274aeff34 Mon Sep 17 00:00:00 2001
From: None <[email protected]>
Date: Thu, 19 Oct 2023 13:12:51 -0400
Subject: [PATCH] [core] Disable portable-simd test

---
library/core/tests/lib.rs | 2 --
1 file changed, 2 deletions(-)

diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 5814ed4..194ad4c 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -90,7 +90,6 @@
#![feature(unwrap_infallible)]
#![feature(pointer_byte_offsets)]
#![feature(pointer_is_aligned)]
-#![feature(portable_simd)]
#![feature(ptr_metadata)]
#![feature(lazy_cell)]
#![feature(unsized_tuple_coercion)]
@@ -157,7 +156,6 @@ mod pin;
mod pin_macro;
mod ptr;
mod result;
-mod simd;
mod slice;
mod str;
mod str_lossy;
--
2.42.0

24 changes: 15 additions & 9 deletions src/intrinsic/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,21 @@ pub fn ignore_arg_cast(func_name: &str, index: usize, args_len: usize) -> bool {

#[cfg(not(feature="master"))]
pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> {
match name {
"llvm.x86.xgetbv" | "llvm.x86.sse2.pause" => {
let gcc_name = "__builtin_trap";
let func = cx.context.get_builtin_function(gcc_name);
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
return func;
},
_ => unimplemented!("unsupported LLVM intrinsic {}", name),
}
let gcc_name =
match name {
"llvm.x86.sse2.pause" => {
// NOTE: pause is only a hint, so we use a dummy built-in because target built-ins
// are not supported in libgccjit 12.
"__builtin_inff"
},
"llvm.x86.xgetbv" => {
"__builtin_trap"
},
_ => unimplemented!("unsupported LLVM intrinsic {}", name),
};
let func = cx.context.get_builtin_function(gcc_name);
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
return func;
}

#[cfg(feature="master")]
Expand Down
Loading
Loading