Skip to content

Commit f8285e3

Browse files
committed
Attempt to fix CI
1 parent c8d7c04 commit f8285e3

File tree

13 files changed

+102
-26
lines changed

13 files changed

+102
-26
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ jobs:
4646

4747
- name: Install packages
4848
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
49-
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
49+
run: |
50+
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
51+
sudo apt update
52+
sudo apt-get install ninja-build ripgrep llvm-14-tools gcc-13 gcc-multilib
5053
5154
- name: Install libgccjit12
5255
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
@@ -71,9 +74,39 @@ jobs:
7174
- name: Setup path to libgccjit
7275
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
7376
run: |
74-
echo $(readlink -f gcc-build) > gcc_path
77+
78+
echo stddef.h
79+
find / -name stddef.h 2> /dev/null || true
80+
echo "************"
81+
82+
echo lto1
83+
find / -name lto1 2> /dev/null || true
84+
echo "************"
85+
86+
echo lto-wrapper
87+
find / -name lto-wrapper 2> /dev/null || true
88+
echo "************"
89+
90+
echo gcc
91+
find / -name gcc 2> /dev/null || true
92+
echo "************"
93+
94+
echo liblto_plugin.so
95+
find / -name liblto_plugin.so 2> /dev/null || true
96+
echo "************"
97+
98+
echo $(readlink -f gcc-build/build/gcc) > gcc_path
7599
# NOTE: the filename is still libgccjit.so even when the artifact name is different.
76-
ln gcc-build/libgccjit.so gcc-build/libgccjit.so.0
100+
ln gcc-build/build/gcc/libgccjit.so gcc-build/build/gcc/libgccjit.so.0
101+
mkdir -p /opt/gcc/libexec/gcc/x86_64-linux-gnu/13 /opt/gcc/libexec/x86_64-linux-gnu/13/
102+
cd gcc-build/build/gcc
103+
chmod +x lto-wrapper lto1
104+
cp *lto* /opt/gcc/libexec/gcc/x86_64-linux-gnu/13/
105+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc_s.so /opt/gcc/libexec/x86_64-linux-gnu/13/
106+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a /opt/gcc/libexec/
107+
cp /usr/libexec/gcc/x86_64-linux-gnu/13/cc1 /opt/gcc/libexec/gcc/cc1
108+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
109+
sudo update-alternatives --all
77110
78111
- name: Set env
79112
run: |

.github/workflows/release.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ jobs:
3434
path: llvm
3535

3636
- name: Install packages
37-
run: sudo apt-get install ninja-build ripgrep
37+
run: |
38+
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
39+
sudo apt update
40+
sudo apt-get install ninja-build ripgrep gcc-13 gcc-multilib
3841
3942
- name: Download artifact
4043
uses: dawidd6/action-download-artifact@v2
@@ -49,9 +52,22 @@ jobs:
4952

5053
- name: Setup path to libgccjit
5154
run: |
52-
echo $(readlink -f gcc-build) > gcc_path
55+
echo $(readlink -f gcc-build/build/gcc) > gcc_path
5356
# NOTE: the filename is still libgccjit.so even when the artifact name is different.
54-
ln gcc-build/libgccjit.so gcc-build/libgccjit.so.0
57+
ln gcc-build/build/gcc/libgccjit.so gcc-build/build/gcc/libgccjit.so.0
58+
mkdir -p /opt/gcc/libexec/gcc/x86_64-linux-gnu/13 /opt/gcc/libexec/x86_64-linux-gnu/13/ /opt/gcc/bin
59+
cp gcc-build/install/bin/gcc /opt/gcc/bin/gcc
60+
cd gcc-build/build/gcc
61+
chmod +x lto-wrapper lto1 /opt/gcc/bin/gcc
62+
cp *lto* /opt/gcc/libexec/gcc/x86_64-linux-gnu/
63+
#cp crt*.o /opt/gcc/libexec/x86_64-linux-gnu/13/
64+
cp crt*.o /opt/gcc/libexec/x86_64-linux-gnu/
65+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc_s.so /opt/gcc/libexec/x86_64-linux-gnu/
66+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a /opt/gcc/libexec/
67+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
68+
# TODO: add comment if this fixes the -fno-inline errors.
69+
# TODO: do some tests locally to know which binary needs to be copied from the system installation.
70+
#cp /usr/libexec/gcc/x86_64-linux-gnu/13/lto1 /opt/gcc/libexec/gcc/x86_64-linux-gnu/13/
5571
5672
- name: Set env
5773
run: |
@@ -90,7 +106,7 @@ jobs:
90106
run: |
91107
./prepare_build.sh
92108
./build.sh --release --release-sysroot
93-
cargo test
109+
GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu cargo test
94110
./clean_all.sh
95111
96112
- name: Prepare dependencies

.github/workflows/stdarch.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ jobs:
3434
path: llvm
3535

3636
- name: Install packages
37-
run: sudo apt-get install ninja-build ripgrep
37+
run: |
38+
sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
39+
sudo apt update
40+
sudo apt-get install ninja-build ripgrep gcc-13 gcc-multilib
3841
3942
- name: Install Intel Software Development Emulator
4043
if: ${{ matrix.cargo_runner }}
@@ -63,9 +66,21 @@ jobs:
6366

6467
- name: Setup path to libgccjit
6568
run: |
66-
echo $(readlink -f gcc-build) > gcc_path
69+
echo $(readlink -f gcc-build/build/gcc) > gcc_path
6770
# NOTE: the filename is still libgccjit.so even when the artifact name is different.
68-
ln gcc-build/libgccjit.so gcc-build/libgccjit.so.0
71+
# TODO: instead, overwrite the system gcc, lto1, …?
72+
ln gcc-build/build/gcc/libgccjit.so gcc-build/build/gcc/libgccjit.so.0
73+
mkdir -p /opt/gcc/libexec/gcc/x86_64-linux-gnu/13 /opt/gcc/libexec/x86_64-linux-gnu/13/ /opt/gcc/bin /opt/gcc/libexec/gcc/x86_64-linux-gnu/13.0.0
74+
cp gcc-build/install/bin/gcc /opt/gcc/bin/gcc
75+
cd gcc-build/build/gcc
76+
chmod +x lto-wrapper lto1 /opt/gcc/bin/gcc
77+
cp *lto* /opt/gcc/libexec/gcc/x86_64-linux-gnu/13/
78+
cp *lto* /opt/gcc/libexec/gcc/x86_64-linux-gnu/13.0.0/
79+
# TODO: instead of downloading the crt files from the GCC CI, copy them from the system.
80+
cp crt*.o /opt/gcc/libexec/x86_64-linux-gnu/13/
81+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc_s.so /opt/gcc/libexec/x86_64-linux-gnu/13/
82+
cp /usr/lib/gcc/x86_64-linux-gnu/12/libgcc.a /opt/gcc/libexec/
83+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
6984
7085
- name: Set env
7186
run: |
@@ -104,7 +119,7 @@ jobs:
104119
run: |
105120
./prepare_build.sh
106121
./build.sh --release --release-sysroot
107-
cargo test
122+
GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu cargo test
108123
109124
- name: Clean
110125
if: ${{ !matrix.cargo_runner }}

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ harness = false
2020
[features]
2121
default = ["master"]
2222
master = ["gccjit/master"]
23+
# TODO: add feature for LTO, given all the setup that is needed (having same versions of gcc, lto1, lto-wrapper, liblto_plugin.so)?
2324

2425
[dependencies]
2526
gccjit = { git = "https://github.com/antoyo/gccjit.rs" }

build_sysroot/build_sysroot.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ rm -r sysroot/ 2>/dev/null || true
1919
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
2020
if [[ "$1" == "--release" ]]; then
2121
sysroot_channel='release'
22-
LIBRARY_PATH=/home/bouanto/Ordinateur/Programmation/Projets/gcc-repo/gcc-build/build/gcc GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
22+
# To avoid the -fno-inline errors, use /opt/gcc/bin/gcc instead of cc.
23+
LIBRARY_PATH=gcc-build GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3 -Clinker=/opt/gcc/bin/gcc" cargo build --target $TARGET_TRIPLE --release
2324
#CG_GCCJIT_DUMP_TREE_ALL=1 CG_GCCJIT_KEEP_INTERMEDIATES=1 RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
2425
else
2526
sysroot_channel='debug'

cargo.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ cmd=$1
2121
shift
2222

2323
# TODO: remove LIBRARY_PATH and GCC_EXEC_PREFIX. Those are used to debug the LTO front-end.
24-
LIBRARY_PATH=/home/bouanto/Ordinateur/Programmation/Projets/gcc-repo/gcc-build/build/gcc GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu PATH=$PATH:/opt/gcc/bin RUSTDOCFLAGS="$RUSTFLAGS" cargo +${TOOLCHAIN} $cmd $@
24+
#LIBRARY_PATH=/home/bouanto/Ordinateur/Programmation/Projets/gcc-repo/gcc-build/build/gcc GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu
25+
PATH=$PATH:/opt/gcc/bin RUSTDOCFLAGS="$RUSTFLAGS" cargo +${TOOLCHAIN} $cmd $@

failing-ui-tests.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,11 @@ tests/ui/panics/nested_panic_caught.rs
7070
tests/ui/simd/intrinsic/generic-bswap-byte.rs
7171
tests/ui/const_prop/ice-issue-111353.rs
7272
tests/ui/process/println-with-broken-pipe.rs
73+
tests/ui/panic-runtime/lto-abort.rs
74+
tests/ui/lto/thin-lto-inlines2.rs
75+
tests/ui/lto/weak-works.rs
76+
tests/ui/lto/thin-lto-inlines.rs
77+
tests/ui/lto/thin-lto-global-allocator.rs
78+
tests/ui/lto/msvc-imp-present.rs
79+
tests/ui/lto/lto-thin-rustc-loads-linker-plugin.rs
80+
tests/ui/lto/all-crates.rs

src/back/lto.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use std::ffi::CString;
2424
use std::fs::{self, File};
2525
use std::path::{Path, PathBuf};
26-
use std::sync::atomic::Ordering;
2726

2827
use gccjit::{OutputKind, OptimizationLevel};
2928
use object::read::archive::ArchiveFile;

src/back/write.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::sync::atomic::Ordering;
21
use std::{env, fs};
32

43
use gccjit::OutputKind;

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::cell::{Cell, RefCell};
22

3-
use gccjit::{Block, CType, Context, Function, FunctionPtrType, FunctionType, LValue, RValue, Type, FnAttribute, ToRValue};
3+
use gccjit::{Block, CType, Context, Function, FunctionPtrType, FunctionType, LValue, RValue, Type};
44
use rustc_codegen_ssa::base::wants_msvc_seh;
55
use rustc_codegen_ssa::traits::{
66
BackendTypes,

src/declare.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, Type, FnAttribute, ToRValue};
1+
use gccjit::{Function, FunctionType, GlobalKind, LValue, RValue, Type};
2+
#[cfg(feature="master")]
3+
use gccjit::{FnAttribute, ToRValue};
24
use rustc_codegen_ssa::traits::BaseTypeMethods;
35
use rustc_middle::ty::Ty;
46
use rustc_span::Symbol;
@@ -115,6 +117,7 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
115117
let func = cx.context.new_function(None, cx.linkage.get(), return_type, &params, mangle_name(name), variadic);
116118
cx.functions.borrow_mut().insert(name.to_string(), func);
117119

120+
#[cfg(feature="master")]
118121
if name == "rust_eh_personality" {
119122
// NOTE: GCC will sometimes change the personality function set on a function from
120123
// rust_eh_personality to __gcc_personality_v0 as an optimization.

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ extern crate rustc_middle;
4242
extern crate rustc_session;
4343
extern crate rustc_span;
4444
extern crate rustc_target;
45-
extern crate tempfile;
4645
#[macro_use]
4746
extern crate tracing;
4847

@@ -74,6 +73,7 @@ mod type_of;
7473

7574
use std::any::Any;
7675
use std::sync::Arc;
76+
#[cfg(not(feature="master"))]
7777
use std::sync::atomic::AtomicBool;
7878
#[cfg(not(feature="master"))]
7979
use std::sync::atomic::Ordering;
@@ -140,7 +140,6 @@ impl TargetInfo {
140140
#[derive(Clone)]
141141
pub struct GccCodegenBackend {
142142
target_info: Arc<TargetInfo>,
143-
should_combine_object_files: Arc<AtomicBool>,
144143
// Temporary directory used by LTO. We keep it here so that it's not removed before linking.
145144
temp_dir: Option<String>,
146145
}
@@ -345,7 +344,6 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
345344

346345
Box::new(GccCodegenBackend {
347346
target_info,
348-
should_combine_object_files: Arc::new(AtomicBool::new(false)),
349347
temp_dir: None,
350348
})
351349
}

test.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function clean() {
151151

152152
function mini_tests() {
153153
echo "[BUILD] mini_core"
154-
$RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
154+
GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu $RUSTC example/mini_core.rs --crate-name mini_core --crate-type lib,dylib --target $TARGET_TRIPLE
155155

156156
echo "[BUILD] example"
157157
$RUSTC example/example.rs --crate-type lib --target $TARGET_TRIPLE
@@ -167,9 +167,9 @@ function build_sysroot() {
167167
}
168168

169169
function std_tests() {
170-
#echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
171-
#$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
172-
#$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
170+
echo "[AOT] arbitrary_self_types_pointers_and_wrappers"
171+
$RUSTC example/arbitrary_self_types_pointers_and_wrappers.rs --crate-name arbitrary_self_types_pointers_and_wrappers --crate-type bin --target $TARGET_TRIPLE
172+
$RUN_WRAPPER ./target/out/arbitrary_self_types_pointers_and_wrappers
173173

174174
echo "[AOT] alloc_system"
175175
$RUSTC example/alloc_system.rs --crate-type lib --target "$TARGET_TRIPLE"
@@ -178,7 +178,7 @@ function std_tests() {
178178
echo "[AOT] alloc_example"
179179
# TODO: -Clink-arg=-lgcc_s
180180
# TODO: -Cdefault-linker-libraries also fixes the issue.
181-
PATH="$PATH:/opt/gcc/bin/" $RUSTC -Clto=yes example/alloc_example.rs -v --crate-type bin --target $TARGET_TRIPLE
181+
PATH="$PATH:/opt/gcc/bin/" $RUSTC example/alloc_example.rs -v --crate-type bin --target $TARGET_TRIPLE
182182
$RUN_WRAPPER ./target/out/alloc_example
183183

184184
echo "[AOT] dst_field_align"
@@ -337,6 +337,7 @@ function extended_sysroot_tests() {
337337
}
338338

339339
function test_rustc() {
340+
# FIXME: LTO UI tests probably fail because GCC_EXEC_PREFIX is not set.
340341
echo
341342
echo "[TEST] rust-lang/rust"
342343

@@ -395,7 +396,8 @@ function test_rustc() {
395396
fi
396397

397398
echo "[TEST] rustc test suite"
398-
COMPILETEST_FORCE_STAGE0=1 ./x.py test --run always --stage 0 tests/ui/ --rustc-args "$RUSTC_ARGS"
399+
ls ../gcc-build/build/gcc
400+
LIBRARY_PATH=$(pwd)/../gcc-build/build/gcc GCC_EXEC_PREFIX=/opt/gcc/libexec/gcc/x86_64-pc-linux-gnu COMPILETEST_FORCE_STAGE0=1 strace -f ./x.py test --run always --stage 0 tests/ui/ --rustc-args "$RUSTC_ARGS"
399401
}
400402

401403
function test_failing_rustc() {

0 commit comments

Comments
 (0)