Skip to content

Commit 524abb3

Browse files
committed
Build the sysroot and run more tests
1 parent 3d9c8af commit 524abb3

File tree

9 files changed

+159
-66
lines changed

9 files changed

+159
-66
lines changed

.github/workflows/failures.yml

+23-10
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,26 @@ jobs:
2121
libgccjit_version:
2222
- { gcc: "libgccjit.so", artifacts_branch: "master" }
2323
- { gcc: "libgccjit_without_int128.so", artifacts_branch: "master-without-128bit-integers" }
24+
# FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin.
25+
# Not sure why it's not found otherwise.
26+
- { gcc: "libgccjit12.so", extra: "--no-default-features", env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/", artifacts_branch: "gcc12" }
2427

2528
steps:
2629
- uses: actions/checkout@v3
2730

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

34+
- name: Install libgccjit12
35+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
36+
run: sudo apt-get install libgccjit-12-dev
37+
38+
- name: Setup path to libgccjit
39+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
40+
run: echo /usr/lib/gcc/x86_64-linux-gnu/12 > gcc_path
41+
3142
- name: Download artifact
43+
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
3244
uses: dawidd6/action-download-artifact@v2
3345
with:
3446
workflow: main.yml
@@ -40,6 +52,7 @@ jobs:
4052
search_artifacts: true # Because, instead, the action only check the last job ran and that won't work since we want multiple artifacts.
4153

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

84-
- name: Build
85-
run: |
86-
./y.sh prepare --only-libcore
87-
./y.sh build
88-
cargo test
89-
./clean_all.sh
90-
91-
- name: Prepare dependencies
97+
- name: Git config
9298
run: |
9399
git config --global user.email "[email protected]"
94100
git config --global user.name "User"
95-
./y.sh prepare
101+
102+
- name: Prepare dependencies
103+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
104+
run: ./y.sh prepare --libgccjit12-patches
105+
106+
- name: Prepare dependencies
107+
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
108+
run: ./y.sh prepare
96109

97110
# Compile is a separate step, as the actions-rs/cargo action supports error annotations
98111
- name: Compile
@@ -107,5 +120,5 @@ jobs:
107120
- name: Run tests
108121
id: tests
109122
run: |
110-
./test.sh --release --clean --build-sysroot --test-failing-rustc | tee output_log
123+
${{ matrix.libgccjit_version.env_extra }} ./test.sh --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
111124
rg "test result" output_log >> $GITHUB_STEP_SUMMARY

.github/workflows/gcc12.yml

+18-19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ env:
1111
# Enable backtraces for easier debugging
1212
RUST_BACKTRACE: 1
1313
TEST_FLAGS: "-Cpanic=abort -Zpanic-abort-tests"
14+
# FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin.
15+
# Not sure why it's not found otherwise.
16+
GCC_EXEC_PREFIX: /usr/lib/gcc/
1417

1518
jobs:
1619
build:
@@ -21,17 +24,15 @@ jobs:
2124
matrix:
2225
commands: [
2326
"--mini-tests",
24-
# TODO(antoyo): re-enable those commands when the build with libgccjit 12 is fixed.
25-
#"--std-tests",
27+
"--std-tests",
2628
# FIXME: re-enable asm tests when GCC can emit in the right syntax.
2729
# "--asm-tests",
28-
#"--test-libcore",
29-
#"--extended-rand-tests",
30-
#"--extended-regex-example-tests",
31-
#"--extended-regex-tests",
32-
#"--test-successful-rustc --nb-parts 2 --current-part 0",
33-
#"--test-successful-rustc --nb-parts 2 --current-part 1",
34-
#"--test-failing-rustc",
30+
"--test-libcore",
31+
"--extended-rand-tests",
32+
"--extended-regex-example-tests",
33+
"--extended-regex-tests",
34+
"--test-successful-rustc --nb-parts 2 --current-part 0",
35+
"--test-successful-rustc --nb-parts 2 --current-part 1",
3536
]
3637

3738
steps:
@@ -85,18 +86,16 @@ jobs:
8586

8687
- name: Build
8788
run: |
88-
./y.sh prepare --only-libcore
89-
# TODO(antoyo): build the sysroot when the build with libgccjit 12 is fixed.
90-
#./y.sh build --no-default-features
91-
# TODO(antoyo): run the tests when we can build the sysroot with libgccjit 12.
92-
#cargo test --no-default-features
89+
./y.sh prepare --only-libcore --libgccjit12-patches
90+
./y.sh build --no-default-features --sysroot-panic-abort
91+
cargo test --no-default-features
9392
./clean_all.sh
9493
9594
- name: Prepare dependencies
9695
run: |
9796
git config --global user.email "[email protected]"
9897
git config --global user.name "User"
99-
./y.sh prepare
98+
./y.sh prepare --libgccjit12-patches
10099
101100
# Compile is a separate step, as the actions-rs/cargo action supports error annotations
102101
- name: Compile
@@ -108,9 +107,9 @@ jobs:
108107
- name: Add more failing tests for GCC 12
109108
run: cat failing-ui-tests12.txt >> failing-ui-tests.txt
110109

110+
- name: Add more failing tests because the sysroot is not compiled with LTO
111+
run: cat failing-non-lto-tests.txt >> failing-ui-tests.txt
112+
111113
- name: Run tests
112114
run: |
113-
# TODO(antoyo): add --build-sysroot when the build with libgccjit 12 is fixed.
114-
# FIXME(antoyo): we need to set GCC_EXEC_PREFIX so that the linker can find the linker plugin.
115-
# Not sure why it's not found otherwise.
116-
GCC_EXEC_PREFIX=/usr/lib/gcc/ ./test.sh --release --clean ${{ matrix.commands }} --no-default-features
115+
./test.sh --release --clean --build-sysroot ${{ matrix.commands }} --no-default-features

build_system/src/build.rs

+19-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::path::Path;
1111
struct BuildArg {
1212
codegen_release_channel: bool,
1313
sysroot_release_channel: bool,
14+
sysroot_panic_abort: bool,
1415
flags: Vec<String>,
1516
gcc_path: String,
1617
}
@@ -32,6 +33,9 @@ impl BuildArg {
3233
"--no-default-features" => {
3334
build_arg.flags.push("--no-default-features".to_string());
3435
}
36+
"--sysroot-panic-abort" => {
37+
build_arg.sysroot_panic_abort = true;
38+
},
3539
"--features" => {
3640
if let Some(arg) = args.next() {
3741
build_arg.flags.push("--features".to_string());
@@ -77,6 +81,7 @@ impl BuildArg {
7781
7882
--release : Build codegen in release mode
7983
--release-sysroot : Build sysroot in release mode
84+
--sysroot-panic-abort : Build the sysroot without unwinding support.
8085
--no-default-features : Add `--no-default-features` flag
8186
--features [arg] : Add a new feature [arg]
8287
--target-triple [arg] : Set the target triple to [arg]
@@ -88,7 +93,7 @@ impl BuildArg {
8893

8994
fn build_sysroot(
9095
env: &mut HashMap<String, String>,
91-
release_mode: bool,
96+
args: &BuildArg,
9297
config: &ConfigInfo,
9398
) -> Result<(), String> {
9499
std::env::set_current_dir("build_sysroot")
@@ -138,15 +143,18 @@ fn build_sysroot(
138143
let _ = fs::remove_dir_all("sysroot");
139144

140145
// Builds libs
141-
let channel = if release_mode {
142-
let rustflags = env
143-
.get("RUSTFLAGS")
144-
.cloned()
145-
.unwrap_or_default();
146-
env.insert(
147-
"RUSTFLAGS".to_string(),
148-
format!("{} -Zmir-opt-level=3", rustflags),
149-
);
146+
let mut rustflags = env
147+
.get("RUSTFLAGS")
148+
.cloned()
149+
.unwrap_or_default();
150+
if args.sysroot_panic_abort {
151+
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests");
152+
}
153+
env.insert(
154+
"RUSTFLAGS".to_string(),
155+
format!("{} -Zmir-opt-level=3", rustflags),
156+
);
157+
let channel = if args.sysroot_release_channel {
150158
run_command_with_output_and_env(
151159
&[
152160
&"cargo",
@@ -224,7 +232,7 @@ fn build_codegen(args: &BuildArg) -> Result<(), String> {
224232
println!("[BUILD] sysroot");
225233
build_sysroot(
226234
&mut env,
227-
args.sysroot_release_channel,
235+
args,
228236
&config,
229237
)?;
230238
Ok(())

build_system/src/prepare.rs

+20-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::utils::{cargo_install, git_clone, run_command, run_command_with_outpu
44
use std::fs;
55
use std::path::Path;
66

7-
fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), String> {
7+
fn prepare_libcore(sysroot_path: &Path, libgccjit12_patches: bool, cross_compile: bool) -> Result<(), String> {
88
let rustc_path = match get_rustc_path() {
99
Some(path) => path,
1010
None => return Err("`rustc` path not found".to_string()),
@@ -93,6 +93,16 @@ fn prepare_libcore(sysroot_path: &Path, cross_compile: bool) -> Result<(), Strin
9393
Ok(())
9494
})?;
9595
}
96+
if libgccjit12_patches {
97+
walk_dir(
98+
"patches/libgccjit12",
99+
|_| Ok(()),
100+
|file_path: &Path| {
101+
patches.push(file_path.to_path_buf());
102+
Ok(())
103+
},
104+
)?;
105+
}
96106
patches.sort();
97107
for file_path in patches {
98108
println!("[GIT] apply `{}`", file_path.display());
@@ -164,17 +174,20 @@ where
164174
struct PrepareArg {
165175
cross_compile: bool,
166176
only_libcore: bool,
177+
libgccjit12_patches: bool,
167178
}
168179

169180
impl PrepareArg {
170181
fn new() -> Result<Option<Self>, String> {
171182
let mut only_libcore = false;
172183
let mut cross_compile = false;
184+
let mut libgccjit12_patches = false;
173185

174186
for arg in std::env::args().skip(2) {
175187
match arg.as_str() {
176188
"--only-libcore" => only_libcore = true,
177189
"--cross" => cross_compile = true,
190+
"--libgccjit12-patches" => libgccjit12_patches = true,
178191
"--help" => {
179192
Self::usage();
180193
return Ok(None);
@@ -185,6 +198,7 @@ impl PrepareArg {
185198
Ok(Some(Self {
186199
cross_compile,
187200
only_libcore,
201+
libgccjit12_patches,
188202
}))
189203
}
190204

@@ -193,9 +207,10 @@ impl PrepareArg {
193207
r#"
194208
`prepare` command help:
195209
196-
--only-libcore : Only setup libcore and don't clone other repositories
197-
--cross : Apply the patches needed to do cross-compilation
198-
--help : Show this help
210+
--only-libcore : Only setup libcore and don't clone other repositories
211+
--cross : Apply the patches needed to do cross-compilation
212+
--libgccjit12-patches : Apply patches needed for libgccjit12
213+
--help : Show this help
199214
"#
200215
)
201216
}
@@ -207,7 +222,7 @@ pub fn run() -> Result<(), String> {
207222
None => return Ok(()),
208223
};
209224
let sysroot_path = Path::new("build_sysroot");
210-
prepare_libcore(sysroot_path, args.cross_compile)?;
225+
prepare_libcore(sysroot_path, args.libgccjit12_patches, args.cross_compile)?;
211226

212227
if !args.only_libcore {
213228
cargo_install("hyperfine")?;

failing-ui-tests12.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ tests/ui/simd/intrinsic/generic-reduction-pass.rs
1919
tests/ui/simd/intrinsic/generic-select-pass.rs
2020
tests/ui/simd/intrinsic/inlining-issue67557-ice.rs
2121
tests/ui/simd/intrinsic/inlining-issue67557.rs
22-
tests/ui/simd/monomorphize-shuffle-index.rs
2322
tests/ui/simd/shuffle.rs
2423
tests/ui/simd/simd-bitmask.rs
25-
tests/ui/generator/resume-after-return.rs
2624
tests/ui/iterators/iter-step-overflow-debug.rs
27-
tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
2825
tests/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
2926
tests/ui/privacy/reachable-unnameable-items.rs
30-
tests/ui/rfc-1937-termination-trait/termination-trait-in-test.rs
27+
tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs
3128
tests/ui/async-await/async-fn-size-moved-locals.rs
3229
tests/ui/async-await/async-fn-size-uninit-locals.rs
3330
tests/ui/cfg/cfg-panic.rs
@@ -38,3 +35,6 @@ tests/ui/simd/issue-85915-simd-ptrs.rs
3835
tests/ui/issues/issue-68010-large-zst-consts.rs
3936
tests/ui/rust-2018/proc-macro-crate-in-paths.rs
4037
tests/ui/target-feature/missing-plusminus.rs
38+
tests/ui/sse2.rs
39+
tests/ui/codegen/issue-79865-llvm-miscompile.rs
40+
tests/ui/intrinsics/intrinsics-integer.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 7bcd24ec6d4a96121874cb1ae5a23ea274aeff34 Mon Sep 17 00:00:00 2001
2+
From: None <[email protected]>
3+
Date: Thu, 19 Oct 2023 13:12:51 -0400
4+
Subject: [PATCH] [core] Disable portable-simd test
5+
6+
---
7+
library/core/tests/lib.rs | 2 --
8+
1 file changed, 2 deletions(-)
9+
10+
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
11+
index 5814ed4..194ad4c 100644
12+
--- a/library/core/tests/lib.rs
13+
+++ b/library/core/tests/lib.rs
14+
@@ -90,7 +90,6 @@
15+
#![feature(unwrap_infallible)]
16+
#![feature(pointer_byte_offsets)]
17+
#![feature(pointer_is_aligned)]
18+
-#![feature(portable_simd)]
19+
#![feature(ptr_metadata)]
20+
#![feature(lazy_cell)]
21+
#![feature(unsized_tuple_coercion)]
22+
@@ -157,7 +156,6 @@ mod pin;
23+
mod pin_macro;
24+
mod ptr;
25+
mod result;
26+
-mod simd;
27+
mod slice;
28+
mod str;
29+
mod str_lossy;
30+
--
31+
2.42.0
32+

src/intrinsic/llvm.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -432,15 +432,21 @@ pub fn ignore_arg_cast(func_name: &str, index: usize, args_len: usize) -> bool {
432432

433433
#[cfg(not(feature="master"))]
434434
pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function<'gcc> {
435-
match name {
436-
"llvm.x86.xgetbv" | "llvm.x86.sse2.pause" => {
437-
let gcc_name = "__builtin_trap";
438-
let func = cx.context.get_builtin_function(gcc_name);
439-
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
440-
return func;
441-
},
442-
_ => unimplemented!("unsupported LLVM intrinsic {}", name),
443-
}
435+
let gcc_name =
436+
match name {
437+
"llvm.x86.sse2.pause" => {
438+
// NOTE: pause is only a hint, so we use a dummy built-in because target built-ins
439+
// are not supported in libgccjit 12.
440+
"__builtin_inff"
441+
},
442+
"llvm.x86.xgetbv" => {
443+
"__builtin_trap"
444+
},
445+
_ => unimplemented!("unsupported LLVM intrinsic {}", name),
446+
};
447+
let func = cx.context.get_builtin_function(gcc_name);
448+
cx.functions.borrow_mut().insert(gcc_name.to_string(), func);
449+
return func;
444450
}
445451

446452
#[cfg(feature="master")]

0 commit comments

Comments
 (0)