Skip to content

Commit 55f3022

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 55f3022

File tree

2 files changed

+255
-419
lines changed

2 files changed

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

0 commit comments

Comments
 (0)