forked from ldc-developers/ldc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.cirrus.yml
343 lines (337 loc) · 13.2 KB
/
.cirrus.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# Installs lit, clones the git submodules, builds LDC and the test
# runners and runs the tests.
# Requires env variables CI_ARCH, CI_OS, EXTRA_CMAKE_FLAGS and PARALLELISM.
common_steps_template: &COMMON_STEPS_TEMPLATE
install_lit_script: |
# Install lit
rm -f /usr/lib/python3.12/EXTERNALLY-MANAGED # required for Ubuntu 24.04
python3 -m pip install --user lit
python3 -c "import lit.main; lit.main.main();" --version . | head -n 1
clone_submodules_script: |
cd $CIRRUS_WORKING_DIR
git submodule update --init --depth $CIRRUS_CLONE_DEPTH
build_script: |
# Build LDC & LDC D unittests & defaultlib unittest runners
cmake --version
ninja --version
cd $CIRRUS_WORKING_DIR/..
installDir=$PWD/install
mkdir build
cd build
IFS=$'\n' extraFlags=( $(xargs -n1 <<<"$EXTRA_CMAKE_FLAGS") )
cmake -G Ninja $CIRRUS_WORKING_DIR \
-DCMAKE_BUILD_TYPE=Release \
-DD_COMPILER=$PWD/../host-ldc/bin/ldmd2 \
-DCMAKE_INSTALL_PREFIX=$installDir \
-DINCLUDE_INSTALL_DIR=$installDir/import \
-DLDC_LINK_MANUALLY=OFF \
"${extraFlags[@]}"
ninja -j$PARALLELISM obj/ldc2.o all ldc2-unittest all-test-runners
bin/ldc2 -version
always:
run_compiler_unittests_script: |
cd $CIRRUS_WORKING_DIR/../build
ctest --output-on-failure -R ldc2-unittest
run_lit_testsuite_script: |
cd $CIRRUS_WORKING_DIR/../build/tests
if [[ "$CI_OS-$CI_ARCH" == "linux-aarch64" ]]; then
# FIXME: the following tests fail
rm $CIRRUS_WORKING_DIR/tests/debuginfo/nested_gdb.d
rm $CIRRUS_WORKING_DIR/tests/sanitizers/fuzz_basic.d
fi
python3 runlit.py -v -j $PARALLELISM .
run_dmd_testsuite_script: |
cd $CIRRUS_WORKING_DIR/../build
DMD_TESTSUITE_MAKE_ARGS=-j$PARALLELISM ctest -V -R dmd-testsuite
run_defaultlib_tests_script: |
# Run defaultlib unittests & druntime integration tests
cd $CIRRUS_WORKING_DIR/../build
excludes="dmd-testsuite|ldc2-unittest|lit-tests"
if [[ "$CI_OS-$CI_ARCH" == "linux-aarch64" ]]; then
# FIXME: failing unittest(s)
excludes+='|^std.internal.math.gammafunction'
# FIXME: failing unittest(s) with enabled optimizations
excludes+='|^std.math.exponential(-shared)?$'
# FIXME: subtest rt_trap_exceptions fails
excludes+='|^druntime-test-exceptions-debug$'
# std.path unittests apparently need HOME, which happens not to be set
export HOME=~
echo "Setting HOME to '$HOME'"
fi
ctest -j$PARALLELISM --output-on-failure -E "$excludes"
# Performs the extra packaging steps for jobs producing a prebuilt package.
# Requires env variables CI_ARCH, CI_OS, GITHUB_TOKEN and PARALLELISM (and CC for FreeBSD).
packaging_steps_template: &PACKAGING_STEPS_TEMPLATE
# Install LDC & make portable
install_script: |
cd $CIRRUS_WORKING_DIR/..
cd build
ninja install > /dev/null
cd ..
perl -pi -e s?$PWD/install/?%%ldcbinarypath%%/../?g install/etc/ldc2.conf
if [[ "$CI_OS" == "freebsd" ]]; then
perl -pi -e "s?,druntime-ldc\",?,druntime-ldc\", \"-gcc=$CC\",?" install/etc/ldc2.conf
fi
cp $CIRRUS_WORKING_DIR/{LICENSE,packaging/README} install
cat install/etc/ldc2.conf
# Now rename the installation dir to test portability
mv install installed
# Run hello-world integration test with shared libs
run_shared_libs_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
echo 'void main() { import std.stdio; writefln("Hello world, %d bits", size_t.sizeof * 8); }' > hello.d
installed/bin/ldc2 hello.d -of=hello -link-defaultlib-shared
./hello
# Run hello-world integration test with LTO
run_lto_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 hello.d -of=hello_thin -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_thin
installed/bin/ldc2 hello.d -of=hello_full -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto
./hello_full
# Run dynamic-compile integration test
run_dynamic_compile_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
# FIXME: disabled since LLVM 12, needs https://github.com/ldc-developers/ldc/pull/3184
if false; then
installed/bin/ldc2 -enable-dynamic-compile -run $CIRRUS_WORKING_DIR/tests/dynamiccompile/array.d
fi
# Run ImportC integration test
run_importC_integration_test_script: |
cd $CIRRUS_WORKING_DIR/..
installed/bin/ldc2 -run $CIRRUS_WORKING_DIR/tests/dmd/runnable/test22597.c
# Build & copy dub
build_dub_script: |
cd $CIRRUS_WORKING_DIR/..
export DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/dub.git
cd dub
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dub_version)"
$DMD -run build.d -O -w -linkonce-templates
cp bin/dub ../installed/bin
../installed/bin/dub --version
# Build & copy dlang tools
build_dlang_tools_script: |
cd $CIRRUS_WORKING_DIR/..
DMD=$PWD/installed/bin/ldmd2
git clone --recursive https://github.com/dlang/tools.git dlang-tools
cd dlang-tools
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/dlang-tools_version)"
mkdir bin
$DMD -w -de -dip1000 rdmd.d -of=bin/rdmd
$DMD -w -de -dip1000 ddemangle.d -of=bin/ddemangle
$DMD -w -de -dip1000 DustMite/dustmite.d DustMite/splitter.d DustMite/polyhash.d -of=bin/dustmite
cp bin/{rdmd,ddemangle,dustmite} ../installed/bin
# Build & copy reggae
build_reggae_script: |
cd $CIRRUS_WORKING_DIR/..
git clone --recursive https://github.com/kinke/reggae.git
cd reggae
git checkout "$(cat $CIRRUS_WORKING_DIR/packaging/reggae_version)"
# needs rdmd in PATH
PATH="$PWD/../installed/bin:$PATH" DFLAGS="-O -linkonce-templates" ../dub/bin/dub build -v --build-mode=allAtOnce --combined --compiler="$PWD/../installed/bin/ldc2"
cp bin/reggae ../installed/bin
../installed/bin/reggae --version -b ninja
# Pack artifact
pack_artifact_script: |
cd $CIRRUS_WORKING_DIR/..
mkdir artifacts
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
artifactID=${CIRRUS_TAG:1}
else
artifactID=${CIRRUS_CHANGE_IN_REPO:0:8}
fi
artifactName=ldc2-$artifactID-$CI_OS-$CI_ARCH
mv installed $artifactName
chmod -R go=rX $artifactName
tar=tar
if [[ "$CI_OS" == "freebsd" ]]; then
tar=gtar
fi
$tar -cf - --owner=0 --group=0 $artifactName | 7z a artifacts/$artifactName.tar.xz -si -txz -mx9 -mmt$PARALLELISM
ls -lh artifacts/ldc2-*.tar.xz
# Upload to GitHub release (only for commits on the master branch and tags)
upload_to_github_script: |
cd $CIRRUS_WORKING_DIR
if [[ "${CIRRUS_TAG:-}" == v* ]]; then
tools/upload-to-github.sh $CIRRUS_TAG ../artifacts/ldc2-*.tar.xz
elif [[ "${CIRRUS_TAG:-}" = "" && "$CIRRUS_PR" = "" && "$CIRRUS_BRANCH" = "master" ]]; then
tools/upload-to-github.sh CI ../artifacts/ldc2-*.tar.xz
fi
# Installs Ubuntu 20.04+ prerequisites.
# Requires env variables CI_ARCH, HOST_LDC_VERSION, EXTRA_APT_PACKAGES and EXTRA_CMAKE_FLAGS.
install_ubuntu_prerequisites_template: &INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
install_prerequisites_script: |
cd $CIRRUS_WORKING_DIR/..
nproc
export DEBIAN_FRONTEND=noninteractive
if [[ "$EXTRA_CMAKE_FLAGS" = *-DMULTILIB?ON* ]]; then
dpkg --add-architecture i386
gcc_pkg="g++-multilib"
libcurl_pkg="libcurl4 libcurl4:i386"
else
gcc_pkg="g++"
libcurl_pkg="libcurl4"
fi
apt-get -q update
apt-get -yq install \
git-core ninja-build $gcc_pkg \
zlib1g-dev $libcurl_pkg curl gdb python3 python3-pip tzdata unzip zip \
$EXTRA_APT_PACKAGES
python3 --version
# Download & extract CMake
curl -fL --retry 3 --max-time 300 -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-$CI_ARCH.tar.gz
mkdir cmake
tar -xf cmake.tar.gz --strip 1 -C cmake
rm cmake.tar.gz
# Download & extract custom Ninja on x86_64
if [[ "$CI_ARCH" == "x86_64" ]]; then
curl -fL --retry 3 --max-time 60 -O https://github.com/symmetryinvestments/ninja/releases/download/v1.11.1-sym1/ninja-linux.zip
mkdir ninja
unzip ninja-linux.zip -d ninja
rm ninja-linux.zip
fi
# Download & extract host LDC
curl -fL --retry 3 --max-time 300 -o ldc2.tar.xz https://github.com/ldc-developers/ldc/releases/download/v$HOST_LDC_VERSION/ldc2-$HOST_LDC_VERSION-linux-$CI_ARCH.tar.xz
mkdir host-ldc
tar -xf ldc2.tar.xz --strip 1 -C host-ldc
rm ldc2.tar.xz
environment:
CIRRUS_CLONE_DEPTH: 50
HOST_LDC_VERSION: 1.31.0
LLVM_VERSION: 18.1.8
GITHUB_TOKEN: ENCRYPTED[0955bd48c8d4e5391446fc0149d0719ad0b63df27ec9e6c180a5730a5b10dc7f28f09d1383423db158d21380ee2b022a]
task:
name: Ubuntu rolling x64 shared-libs-only gdmd
# allow failures - gdb v10 came with regressions
allow_failures: true
container:
image: ubuntu:rolling
cpu: 8
memory: 16G
timeout_in: 15m
environment:
CI_ARCH: x86_64
CI_OS: linux
EXTRA_APT_PACKAGES: "gdmd llvm-dev libclang-common-15-dev"
EXTRA_CMAKE_FLAGS: "-DBUILD_SHARED_LIBS=ON -DBUILD_LTO_LIBS=ON -DD_COMPILER=gdmd -DLDC_LINK_MANUALLY=ON"
PARALLELISM: 8
PATH: ${CIRRUS_WORKING_DIR}/../cmake/bin:${CIRRUS_WORKING_DIR}/../ninja:${PATH}
# for gdmd:
LANG: C.UTF-8
<< : *INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
<< : *COMMON_STEPS_TEMPLATE
task:
name: Ubuntu 20.04 aarch64
compute_engine_instance:
image_project: ubuntu-os-cloud
image: family/ubuntu-2004-lts-arm64
platform: linux
architecture: arm64
cpu: 4
memory: 8G
disk: 20
timeout_in: 60m
environment:
CI_ARCH: aarch64
CI_OS: linux
EXTRA_APT_PACKAGES: libxml2-dev libzstd-dev p7zip-full
EXTRA_CMAKE_FLAGS: >-
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
-DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu
-DLLVM_ROOT_DIR=$CIRRUS_WORKING_DIR/../llvm
-DD_COMPILER=$CIRRUS_WORKING_DIR/../bootstrap-ldc/bin/ldmd2
PARALLELISM: 4
PATH: ${CIRRUS_WORKING_DIR}/../cmake/bin:${PATH}
CLANG_VERSION: '15.0.3' # 15.0.6 requires a more recent libstdc++.so.6 than shipped with Ubuntu 20
CC: $CIRRUS_WORKING_DIR/../clang/bin/clang
CXX: $CIRRUS_WORKING_DIR/../clang/bin/clang++
<< : *INSTALL_UBUNTU_PREREQUISITES_TEMPLATE
# Download & extract LDC-flavoured LLVM
download_prebuilt_llvm_script: |
cd $CIRRUS_WORKING_DIR/..
assertsSuffix=""
if [[ "${CIRRUS_TAG:-}" == "" ]]; then
echo 'Using LLVM with enabled assertions'
assertsSuffix="-withAsserts"
fi
llvm_tag="CI"
if [[ "$LLVM_VERSION" = *.* ]]; then llvm_tag="ldc-v$LLVM_VERSION"; fi
llvm_url="https://github.com/ldc-developers/llvm-project/releases/download/$llvm_tag/llvm-$LLVM_VERSION-linux-$CI_ARCH$assertsSuffix.tar.xz"
curl -fL --retry 3 --max-time 300 -o llvm.tar.xz $llvm_url
mkdir -p llvm
tar -xf llvm.tar.xz --strip 1 -C llvm
rm llvm.tar.xz
# Make lld the default linker (likely with enabled assertions unfortunately)
ln -sf "$PWD/llvm/bin/ld.lld" /usr/bin/ld
ld --version
# Make sure to link libzstd statically
rm /usr/lib/aarch64-linux-gnu/libzstd.so
# Download & extract clang
download_prebuilt_clang_script: |
cd $CIRRUS_WORKING_DIR/..
curl -fL --retry 3 --max-time 300 -o clang.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-$CI_ARCH-linux-gnu.tar.xz
mkdir clang
tar -xf clang.tar.xz --strip 1 -C clang
rm clang.tar.xz
clone_submodules_early_script: |
cd $CIRRUS_WORKING_DIR
git submodule update --init --depth $CIRRUS_CLONE_DEPTH
# Build a first LDC as host compiler for the actual build
build_bootstrap_ldc_script: |
cd $CIRRUS_WORKING_DIR/..
mkdir bootstrap-ldc
cd bootstrap-ldc
cmake -G Ninja $CIRRUS_WORKING_DIR \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ROOT_DIR=$PWD/../llvm \
-DD_COMPILER=$PWD/../host-ldc/bin/ldmd2 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_LTO_LIBS=ON
ninja -j$PARALLELISM obj/ldc2.o all
bin/ldc2 -version
<< : *COMMON_STEPS_TEMPLATE
<< : *PACKAGING_STEPS_TEMPLATE
task:
name: FreeBSD 13.3 x64
freebsd_instance:
image_family: freebsd-13-3
cpu: 4
memory: 8G
timeout_in: 60m
environment:
CI_ARCH: x86_64
CI_OS: freebsd
EXTRA_CMAKE_FLAGS: >-
-DBUILD_LTO_LIBS=ON
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
PARALLELISM: 4
CC: clang
install_prerequisites_script: |
cd $CIRRUS_WORKING_DIR/..
sysctl -n hw.ncpu
pkg install -y git cmake ninja gmake llvm bash gtar 7-zip ldc
python3 --version
python3 -m ensurepip
clone_submodules_early_script: |
cd $CIRRUS_WORKING_DIR
git submodule update --init --depth $CIRRUS_CLONE_DEPTH
# Build a first LDC as host compiler for the actual build
build_bootstrap_ldc_script: |
cd $CIRRUS_WORKING_DIR/..
mkdir host-ldc
cd host-ldc
cmake -G Ninja $CIRRUS_WORKING_DIR \
-DCMAKE_BUILD_TYPE=Release \
-DD_COMPILER=ldmd2 \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_LTO_LIBS=ON
ninja -j$PARALLELISM
bin/ldc2 -version
<< : *COMMON_STEPS_TEMPLATE
<< : *PACKAGING_STEPS_TEMPLATE