Skip to content

Commit dec1d75

Browse files
committed
ci: refactor ccpp workflow
Use dtolnay/rust-toolchain action to install rustc toolchain. Use a composite action for the various build/check on ubuntu. More cleanup possible (the 32/64bits builds could be simplified and only build 1 compiler and split the checks) ChangeLog: * .github/workflows/ccpp.yml: Refactor. * .github/actions/build-gcc/action.yml: New file. Signed-off-by: Marc Poulhiès <[email protected]>
1 parent f942905 commit dec1d75

File tree

2 files changed

+249
-419
lines changed

2 files changed

+249
-419
lines changed
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: 'Build GCC'
2+
description: 'Builds GCC with Rust enabled'
3+
inputs:
4+
extra-configure-env:
5+
description: 'Extra env for configure'
6+
default: ''
7+
8+
run_test_flags:
9+
description: 'Args for RUN_TEST_FLAGS'
10+
required: true
11+
12+
rustc_version:
13+
description: 'rustc version to install'
14+
default: "1.72.0"
15+
16+
use-old-gcc:
17+
description: 'Version to use for old GCC'
18+
default: ''
19+
20+
bootstrap:
21+
description: 'Set to true to bootstrap the compiler'
22+
default: false
23+
24+
warning_file:
25+
description: 'If set, checks compile log for extra warnings compared to provided file'
26+
default: ''
27+
28+
extra-configure-args:
29+
description: 'Extra configure args to use for ./configure step'
30+
default: ''
31+
32+
glibc_assertion:
33+
description: 'Enable GLIBC_ASSERTION for extra runtime checks'
34+
default: false
35+
36+
enable_multilib:
37+
description: 'Enable multilib'
38+
default: true
39+
40+
runs:
41+
using: "composite"
42+
steps:
43+
- name: Install dependencies
44+
run: |
45+
sudo apt-get update;
46+
sudo apt-get install -y \
47+
automake \
48+
autoconf \
49+
libtool \
50+
autogen \
51+
bison \
52+
flex \
53+
libgmp3-dev \
54+
libmpfr-dev \
55+
libmpc-dev \
56+
build-essential \
57+
gcc-multilib \
58+
g++-multilib \
59+
dejagnu;
60+
shell: bash
61+
62+
- uses: dtolnay/rust-toolchain@stable
63+
with:
64+
toolchain: ${{ inputs.rustc_version }}
65+
66+
- name: Make Source Read-Only
67+
run: chmod -R a-w ./*
68+
shell: bash
69+
70+
- name: Restore cached old gcc ${{ inputs.use-old-gcc }}
71+
if: inputs.use-old-gcc != ''
72+
id: restore-gcc5
73+
uses: actions/cache/restore@v4
74+
with:
75+
key: ce-tar-gcc-${{ inputs.use-old-gcc }}
76+
path: ~/gcc-${{ inputs.use-old-gcc }}/
77+
78+
- name: Download and install gcc ${{ inputs.use-old-gcc }}
79+
if: steps.restore-gcc5.outputs.cache-hit != 'true' && inputs.use-old-gcc != ''
80+
shell: bash
81+
run: |
82+
curl "https://s3.amazonaws.com/compiler-explorer/opt/gcc-${{ inputs.use-old-gcc }}.tar.xz" -o /tmp/gcc.tar.xz;
83+
cd ~;
84+
tar xvf /tmp/gcc.tar.xz
85+
86+
- name: Store gcc ${{ inputs.use-old-gcc }} to cache
87+
id: cache-gcc5
88+
if: always() && steps.restore-gcc5.outputs.cache-hit != 'true' && inputs.use-old-gcc != ''
89+
uses: actions/cache/save@v4
90+
with:
91+
key: ce-tar-gcc-${{ inputs.use-old-gcc }}
92+
path: ~/gcc-${{ inputs.use-old-gcc }}/
93+
94+
- name: Configure GCC
95+
shell: bash
96+
run: |
97+
mkdir -p gccrs-build;
98+
cd gccrs-build;
99+
if [ -n "${{ inputs.use-old-gcc }}" ]; then
100+
echo "Adjusting PATH for old gcc"
101+
export PATH=$HOME/gcc-${{ inputs.use-old-gcc }}/bin:$PATH
102+
fi
103+
104+
if ${{ inputs.glibc_assertion }}; then
105+
echo "Enabling GLIBCXX assertions"
106+
export CXXFLAGS="$CXXFLAGS -D_GLIBCXX_ASSERTIONS"
107+
fi
108+
109+
if ${{ inputs.enable_multilib }}; then
110+
echo "Enabling multilib"
111+
MULTILIB_FLG=--enable-multilib
112+
else
113+
echo "Disabling multilib"
114+
MULTILIB_FLG=--disable-multilib
115+
fi
116+
117+
if ${{ inputs.bootstrap }}; then
118+
echo "Enabling bootstrap"
119+
BOOTSTRAP_FLG=--enable-bootstrap
120+
else
121+
echo "Disabling bootstrap"
122+
BOOTSTRAP_FLG=--disable-bootstrap
123+
fi
124+
125+
if [ -n "${{ inputs.extra-configure-args }}" ]; then
126+
EXTRA_CONFIGURE_ARGS="${{ inputs.extra-configure-args }}"
127+
echo "Using extra configure args: $EXTRA_CONFIGURE_ARGS"
128+
else
129+
EXTRA_CONFIGURE_ARGS=""
130+
fi
131+
132+
../configure \
133+
--enable-languages=rust \
134+
$BOOTSTRAP_FLG \
135+
$MULTILIB_FLG \
136+
$EXTRA_CONFIGURE_ARGS
137+
138+
- name: Build GCC
139+
shell: bash
140+
run: |
141+
cd gccrs-build; \
142+
143+
if [ -n "${{ inputs.use-old-gcc }}" ]; then
144+
export PATH=$HOME/gcc-${{ inputs.use-old-gcc }}/bin:$PATH
145+
fi
146+
147+
# Build without network access
148+
unshare --net --ipc -r /bin/bash -c "\
149+
make -Otarget -j $(nproc) 2>&1 | \
150+
tee log; exit \${PIPESTATUS[0]}"
151+
wc -l log
152+
153+
- name: Check for new warnings
154+
if: inputs.warning_file != ''
155+
shell: bash
156+
run: |
157+
cd gccrs-build
158+
echo "Before"
159+
if grep 'warning: ' log | grep rust | sort > log_warnings; then
160+
echo yes
161+
else
162+
echo no
163+
fi
164+
165+
echo "After"
166+
167+
if diff -U0 ../.github/${{ inputs.warning_file }} log_warnings; then
168+
echo "No new warnings found"
169+
else
170+
echo 'See <https://github.com/Rust-GCC/gccrs/pull/1026>.'
171+
exit 1
172+
fi >&2
173+
174+
- name: Run Tests
175+
shell: bash
176+
run: |
177+
cd gccrs-build; \
178+
make check-rust RUNTESTFLAGS="${{ inputs.run_test_flags }}"
179+
180+
- name: Check regressions
181+
shell: bash
182+
run: |
183+
cd gccrs-build
184+
if grep -e "unexpected" -e "unresolved" -e "ERROR:" gcc/testsuite/rust/rust.sum;
185+
then
186+
echo "::error title=Regression test failed::some tests are not correct"
187+
perl -n ../.github/emit_test_errors.pl < gcc/testsuite/rust/rust.sum
188+
exit 1
189+
else
190+
exit 0
191+
fi

0 commit comments

Comments
 (0)