Merge pull request #357 from rust-lang/fix/gcc-12

Fix for the libgccjit 12 CI
This commit is contained in:
antoyo 2023-10-25 17:55:34 -04:00 committed by GitHub
commit 47bac1f679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 167 additions and 69 deletions

View File

@ -19,8 +19,16 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
libgccjit_version: libgccjit_version:
- { gcc: "libgccjit.so", artifacts_branch: "master" } - gcc: "libgccjit.so"
- { gcc: "libgccjit_without_int128.so", artifacts_branch: "master-without-128bit-integers" } 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: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -28,7 +36,16 @@ jobs:
- name: Install packages - name: Install packages
run: sudo apt-get install ninja-build ripgrep 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 - name: Download artifact
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
uses: dawidd6/action-download-artifact@v2 uses: dawidd6/action-download-artifact@v2
with: with:
workflow: main.yml workflow: main.yml
@ -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. 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 - name: Setup path to libgccjit
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
run: | run: |
sudo dpkg --force-overwrite -i gcc-13/gcc-13.deb sudo dpkg --force-overwrite -i gcc-13/gcc-13.deb
echo /usr/lib/ > gcc_path echo /usr/lib/ > gcc_path
@ -81,18 +99,18 @@ jobs:
#path: rust #path: rust
#key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }}
- name: Build - name: Git config
run: |
./y.sh prepare --only-libcore
./y.sh build
cargo test
./clean_all.sh
- name: Prepare dependencies
run: | run: |
git config --global user.email "user@example.com" git config --global user.email "user@example.com"
git config --global user.name "User" 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 # Compile is a separate step, as the actions-rs/cargo action supports error annotations
- name: Compile - name: Compile
@ -107,5 +125,5 @@ jobs:
- name: Run tests - name: Run tests
id: tests id: tests
run: | run: |
./test.sh --release --clean --build-sysroot --test-failing-rustc | tee output_log ${{ matrix.libgccjit_version.env_extra }} ./test.sh --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
rg "test result" output_log >> $GITHUB_STEP_SUMMARY rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY

View File

@ -11,6 +11,9 @@ env:
# Enable backtraces for easier debugging # Enable backtraces for easier debugging
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
TEST_FLAGS: "-Cpanic=abort -Zpanic-abort-tests" 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: jobs:
build: build:
@ -21,17 +24,15 @@ jobs:
matrix: matrix:
commands: [ commands: [
"--mini-tests", "--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. # FIXME: re-enable asm tests when GCC can emit in the right syntax.
# "--asm-tests", # "--asm-tests",
#"--test-libcore", "--test-libcore",
#"--extended-rand-tests", "--extended-rand-tests",
#"--extended-regex-example-tests", "--extended-regex-example-tests",
#"--extended-regex-tests", "--extended-regex-tests",
#"--test-successful-rustc --nb-parts 2 --current-part 0", "--test-successful-rustc --nb-parts 2 --current-part 0",
#"--test-successful-rustc --nb-parts 2 --current-part 1", "--test-successful-rustc --nb-parts 2 --current-part 1",
#"--test-failing-rustc",
] ]
steps: steps:
@ -85,18 +86,16 @@ jobs:
- name: Build - name: Build
run: | run: |
./y.sh prepare --only-libcore ./y.sh prepare --only-libcore --libgccjit12-patches
# TODO(antoyo): build the sysroot when the build with libgccjit 12 is fixed. ./y.sh build --no-default-features --sysroot-panic-abort
#./y.sh build --no-default-features cargo test --no-default-features
# TODO(antoyo): run the tests when we can build the sysroot with libgccjit 12.
#cargo test --no-default-features
./clean_all.sh ./clean_all.sh
- name: Prepare dependencies - name: Prepare dependencies
run: | run: |
git config --global user.email "user@example.com" git config --global user.email "user@example.com"
git config --global user.name "User" 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 # Compile is a separate step, as the actions-rs/cargo action supports error annotations
- name: Compile - name: Compile
@ -108,9 +107,9 @@ jobs:
- name: Add more failing tests for GCC 12 - name: Add more failing tests for GCC 12
run: cat failing-ui-tests12.txt >> failing-ui-tests.txt 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 - name: Run tests
run: | run: |
# TODO(antoyo): add --build-sysroot when the build with libgccjit 12 is fixed. ./test.sh --release --clean --build-sysroot ${{ matrix.commands }} --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.
GCC_EXEC_PREFIX=/usr/lib/gcc/ ./test.sh --release --clean ${{ matrix.commands }} --no-default-features

View File

@ -11,6 +11,7 @@ use std::path::Path;
struct BuildArg { struct BuildArg {
codegen_release_channel: bool, codegen_release_channel: bool,
sysroot_release_channel: bool, sysroot_release_channel: bool,
sysroot_panic_abort: bool,
flags: Vec<String>, flags: Vec<String>,
gcc_path: String, gcc_path: String,
} }
@ -32,6 +33,9 @@ impl BuildArg {
"--no-default-features" => { "--no-default-features" => {
build_arg.flags.push("--no-default-features".to_string()); build_arg.flags.push("--no-default-features".to_string());
} }
"--sysroot-panic-abort" => {
build_arg.sysroot_panic_abort = true;
},
"--features" => { "--features" => {
if let Some(arg) = args.next() { if let Some(arg) = args.next() {
build_arg.flags.push("--features".to_string()); build_arg.flags.push("--features".to_string());
@ -77,6 +81,7 @@ impl BuildArg {
--release : Build codegen in release mode --release : Build codegen in release mode
--release-sysroot : Build sysroot 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 --no-default-features : Add `--no-default-features` flag
--features [arg] : Add a new feature [arg] --features [arg] : Add a new feature [arg]
--target-triple [arg] : Set the target triple to [arg] --target-triple [arg] : Set the target triple to [arg]
@ -88,7 +93,7 @@ impl BuildArg {
fn build_sysroot( fn build_sysroot(
env: &mut HashMap<String, String>, env: &mut HashMap<String, String>,
release_mode: bool, args: &BuildArg,
config: &ConfigInfo, config: &ConfigInfo,
) -> Result<(), String> { ) -> Result<(), String> {
std::env::set_current_dir("build_sysroot") std::env::set_current_dir("build_sysroot")
@ -138,15 +143,18 @@ fn build_sysroot(
let _ = fs::remove_dir_all("sysroot"); let _ = fs::remove_dir_all("sysroot");
// Builds libs // Builds libs
let channel = if release_mode { let mut rustflags = env
let rustflags = env .get("RUSTFLAGS")
.get("RUSTFLAGS") .cloned()
.cloned() .unwrap_or_default();
.unwrap_or_default(); if args.sysroot_panic_abort {
env.insert( rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests");
"RUSTFLAGS".to_string(), }
format!("{} -Zmir-opt-level=3", rustflags), env.insert(
); "RUSTFLAGS".to_string(),
format!("{} -Zmir-opt-level=3", rustflags),
);
let channel = if args.sysroot_release_channel {
run_command_with_output_and_env( run_command_with_output_and_env(
&[ &[
&"cargo", &"cargo",
@ -224,7 +232,7 @@ fn build_codegen(args: &BuildArg) -> Result<(), String> {
println!("[BUILD] sysroot"); println!("[BUILD] sysroot");
build_sysroot( build_sysroot(
&mut env, &mut env,
args.sysroot_release_channel, args,
&config, &config,
)?; )?;
Ok(()) Ok(())

View File

@ -4,7 +4,7 @@ use crate::utils::{cargo_install, git_clone, run_command, run_command_with_outpu
use std::fs; use std::fs;
use std::path::Path; 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() { let rustc_path = match get_rustc_path() {
Some(path) => path, Some(path) => path,
None => return Err("`rustc` path not found".to_string()), None => return Err("`rustc` path not found".to_string()),
@ -93,6 +93,16 @@ fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), Strin
Ok(()) Ok(())
})?; })?;
} }
if libgccjit12_patches {
walk_dir(
"patches/libgccjit12",
|_| Ok(()),
|file_path: &Path| {
patches.push(file_path.to_path_buf());
Ok(())
},
)?;
}
patches.sort(); patches.sort();
for file_path in patches { for file_path in patches {
println!("[GIT] apply `{}`", file_path.display()); println!("[GIT] apply `{}`", file_path.display());
@ -164,17 +174,20 @@ where
struct PrepareArg { struct PrepareArg {
cross_compile: bool, cross_compile: bool,
only_libcore: bool, only_libcore: bool,
libgccjit12_patches: bool,
} }
impl PrepareArg { impl PrepareArg {
fn new() -> Result<Option<Self>, String> { fn new() -> Result<Option<Self>, String> {
let mut only_libcore = false; let mut only_libcore = false;
let mut cross_compile = false; let mut cross_compile = false;
let mut libgccjit12_patches = false;
for arg in std::env::args().skip(2) { for arg in std::env::args().skip(2) {
match arg.as_str() { match arg.as_str() {
"--only-libcore" => only_libcore = true, "--only-libcore" => only_libcore = true,
"--cross" => cross_compile = true, "--cross" => cross_compile = true,
"--libgccjit12-patches" => libgccjit12_patches = true,
"--help" => { "--help" => {
Self::usage(); Self::usage();
return Ok(None); return Ok(None);
@ -185,6 +198,7 @@ impl PrepareArg {
Ok(Some(Self { Ok(Some(Self {
cross_compile, cross_compile,
only_libcore, only_libcore,
libgccjit12_patches,
})) }))
} }
@ -193,9 +207,10 @@ impl PrepareArg {
r#" r#"
`prepare` command help: `prepare` command help:
--only-libcore : Only setup libcore and don't clone other repositories --only-libcore : Only setup libcore and don't clone other repositories
--cross : Apply the patches needed to do cross-compilation --cross : Apply the patches needed to do cross-compilation
--help : Show this help --libgccjit12-patches : Apply patches needed for libgccjit12
--help : Show this help
"# "#
) )
} }
@ -207,7 +222,7 @@ pub fn run() -> Result<(), String> {
None => return Ok(()), None => return Ok(()),
}; };
let sysroot_path = Path::new("build_sysroot"); 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 { if !args.only_libcore {
cargo_install("hyperfine")?; cargo_install("hyperfine")?;

View File

@ -19,15 +19,12 @@ tests/ui/simd/intrinsic/generic-reduction-pass.rs
tests/ui/simd/intrinsic/generic-select-pass.rs tests/ui/simd/intrinsic/generic-select-pass.rs
tests/ui/simd/intrinsic/inlining-issue67557-ice.rs tests/ui/simd/intrinsic/inlining-issue67557-ice.rs
tests/ui/simd/intrinsic/inlining-issue67557.rs tests/ui/simd/intrinsic/inlining-issue67557.rs
tests/ui/simd/monomorphize-shuffle-index.rs
tests/ui/simd/shuffle.rs tests/ui/simd/shuffle.rs
tests/ui/simd/simd-bitmask.rs tests/ui/simd/simd-bitmask.rs
tests/ui/generator/resume-after-return.rs
tests/ui/iterators/iter-step-overflow-debug.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/numbers-arithmetic/next-power-of-two-overflow-debug.rs
tests/ui/privacy/reachable-unnameable-items.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-moved-locals.rs
tests/ui/async-await/async-fn-size-uninit-locals.rs tests/ui/async-await/async-fn-size-uninit-locals.rs
tests/ui/cfg/cfg-panic.rs tests/ui/cfg/cfg-panic.rs
@ -38,3 +35,6 @@ tests/ui/simd/issue-85915-simd-ptrs.rs
tests/ui/issues/issue-68010-large-zst-consts.rs tests/ui/issues/issue-68010-large-zst-consts.rs
tests/ui/rust-2018/proc-macro-crate-in-paths.rs tests/ui/rust-2018/proc-macro-crate-in-paths.rs
tests/ui/target-feature/missing-plusminus.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

View File

@ -0,0 +1,32 @@
From 7bcd24ec6d4a96121874cb1ae5a23ea274aeff34 Mon Sep 17 00:00:00 2001
From: None <none@example.com>
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

View File

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

View File

@ -216,17 +216,17 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
value.get_type() value.get_type()
} }
fn type_array(&self, ty: Type<'gcc>, len: u64) -> Type<'gcc> { #[cfg_attr(feature="master", allow(unused_mut))]
// TODO: remove this as well? fn type_array(&self, ty: Type<'gcc>, mut len: u64) -> Type<'gcc> {
/*if let Some(struct_type) = ty.is_struct() { #[cfg(not(feature="master"))]
if let Some(struct_type) = ty.is_struct() {
if struct_type.get_field_count() == 0 { if struct_type.get_field_count() == 0 {
// NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a // NOTE: since gccjit only supports i32 for the array size and libcore's tests uses a
// size of usize::MAX in test_binary_search, we workaround this by setting the size to // size of usize::MAX in test_binary_search, we workaround this by setting the size to
// zero for ZSTs. // zero for ZSTs.
// FIXME(antoyo): fix gccjit API.
len = 0; len = 0;
} }
}*/ }
self.context.new_array_type(None, ty, len) self.context.new_array_type(None, ty, len)
} }

View File

@ -1,8 +1,8 @@
//! The common code for `tests/lang_tests_*.rs` //! The common code for `tests/lang_tests_*.rs`
use std::{ use std::{
env::{self, current_dir}, env::{self, current_dir},
path::PathBuf, path::{Path, PathBuf},
process::{self, Command}, process::Command,
}; };
use lang_tester::LangTester; use lang_tester::LangTester;
@ -23,9 +23,29 @@ pub fn main_inner(profile: Profile) {
let gcc_path = include_str!("../gcc_path"); let gcc_path = include_str!("../gcc_path");
let gcc_path = gcc_path.trim(); let gcc_path = gcc_path.trim();
env::set_var("LD_LIBRARY_PATH", gcc_path); 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() LangTester::new()
.test_dir("tests/run") .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| { .test_extract(|source| {
let lines = let lines =
source.lines() source.lines()