-
-
Notifications
You must be signed in to change notification settings - Fork 295
502 lines (467 loc) · 18.4 KB
/
Copy pathmain.yml
File metadata and controls
502 lines (467 loc) · 18.4 KB
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: Main
on:
pull_request:
push:
branches-ignore:
- 'merge-*' # don't run on pushes to merge-X.Y.Z branches, they are usually PRs
tags: # explicitly needed to run for all tags, due to the branches filter above
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
LLVM_VERSION: 22.1.8
CLANG_MAJOR: 22
jobs:
build-native:
strategy:
fail-fast: false
matrix:
include:
- job_name: Linux x86_64 multilib
os: ubuntu-22.04
arch: x86_64
# To improve portability of the generated binaries, link the C++ standard library statically.
extra_cmake_flags: >-
-DMULTILIB=ON
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: Linux aarch64
os: ubuntu-22.04-arm
arch: aarch64
extra_cmake_flags: >-
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DJITRT_EXTRA_LDFLAGS=-static-libstdc++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: Alpine musl x86_64
os: ubuntu-24.04
container_image: alpine:3.24
arch: x86_64
base_cmake_flags: >-
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=x86_64
-DLLVM_IS_SHARED=OFF
-DLDC_ENABLE_PLUGINS=OFF
-DLDC_DYNAMIC_COMPILE=OFF
-DLDC_BUNDLE_LLVM_TOOLS=OFF
# TSan and XRay do not work.
extra_cmake_flags: >-
-DTEST_COMPILER_RT_LIBRARIES="profile;lsan;asan;msan;fuzzer"
-DLDC_INSTALL_LTOPLUGIN=OFF
-DLDC_FULLY_STATIC=ON
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: Alpine musl aarch64
os: ubuntu-24.04-arm
container_image: alpine:3.24
arch: aarch64
base_cmake_flags: >-
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64
-DLLVM_IS_SHARED=OFF
-DLDC_ENABLE_PLUGINS=OFF
-DLDC_DYNAMIC_COMPILE=OFF
-DLDC_BUNDLE_LLVM_TOOLS=OFF
extra_cmake_flags: >-
-DTEST_COMPILER_RT_LIBRARIES="profile;lsan;asan;msan;fuzzer"
-DLDC_INSTALL_LTOPLUGIN=OFF
-DLDC_FULLY_STATIC=ON
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: macOS x86_64
os: macos-26-intel
arch: x86_64
# * CMAKE_OSX_SYSROOT: Homebrew clang apparently requires the Command Line Tools instead of Xcode: https://github.com/actions/runner-images/issues/10035#issue-2344536514
# * https://github.com/ldc-developers/ldc/issues/4462:
# When using LTO, we need to explicitly export ~all symbols for plugin support via `ld64 -exported_symbol '__*'`.
# Additionally `-w` to suppress resulting linker warnings.
extra_cmake_flags: >-
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
-DCMAKE_C_COMPILER=/usr/local/opt/llvm@${CLANG_MAJOR}/bin/clang
-DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@${CLANG_MAJOR}/bin/clang++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: macOS arm64
os: macos-26
arch: arm64
extra_cmake_flags: >-
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
-DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm@${CLANG_MAJOR}/bin/clang
-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@${CLANG_MAJOR}/bin/clang++
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: Windows x64
os: windows-2025
arch: x64
base_cmake_flags: >-
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
extra_cmake_flags: >-
"-DD_COMPILER_FLAGS=-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
- job_name: Windows x86
os: windows-2025
arch: x86
base_cmake_flags: >-
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
# `RT_CFLAGS=-m32` needed to make 64-bit clang-cl output 32-bit code for druntime integration tests
extra_cmake_flags: >-
-DRT_CFLAGS=-m32
# Undefined symbol errors with FullLTO; ThinLTO used to work, but apparently miscompiles a lexer.d:138 assertion since v1.33.
# "-DD_COMPILER_FLAGS=-O -flto=thin -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
# -DEXTRA_CXXFLAGS=-flto=thin
with_pgo: true
- job_name: FreeBSD x86_64
os: ubuntu-latest
vm_os: freebsd
vm_os_version: '14.4'
arch: x86_64
base_cmake_flags: >-
-DLLVM_ROOT_DIR=/usr/local/llvm19
extra_cmake_flags: >-
-DCMAKE_C_COMPILER=clang19
-DCMAKE_CXX_COMPILER=clang++19
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto"
-DEXTRA_CXXFLAGS=-flto=full
with_pgo: true
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.container_image }}
timeout-minutes: 120
env:
GHA_BASH_SHELL: ${{ matrix.vm_os && 'cpa.sh {0}' || 'bash' }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.arch == 'arm64' && '11.0' || '10.12' }}
steps:
- name: Start VM
if: matrix.vm_os
uses: cross-platform-actions/action@v1.3.0
with:
operating_system: ${{ matrix.vm_os }}
version: ${{ matrix.vm_os_version }}
architecture: ${{ matrix.arch }}
shell: bash
memory: 8G
cpu_count: 4
- name: 'Fix GitHub actions in Alpine aarch64 container'
if: startsWith(matrix.container_image, 'alpine') && matrix.arch == 'aarch64'
uses: laverdet/alpine-arm64@v1
- name: 'Set up Linux container'
if: matrix.container_image
run: |
set -eux
if type -P apt-get &>/dev/null; then
# Ubuntu: pre-install git and sudo
apt-get -q update
DEBIAN_FRONTEND=noninteractive apt-get -yq install git-core sudo
else
# set up Alpine container
apk add \
git cmake ninja-is-really-ninja g++ clang ldc lld llvm-dev llvm-static compiler-rt \
libxml2-static zstd-static zlib-static \
bash grep diffutils make curl 7zip perl
# make lld the default linker (note: /usr/bin/ld seems unused)
ln -sf /usr/bin/ld.lld /usr/${{ matrix.arch }}-alpine-linux-musl/bin/ld
# create ../llvm symlink to distro LLVM (no prebuilt LDC-LLVM for musl)
ln -s /usr/lib/llvm22 $(dirname $(pwd))/llvm
../llvm/bin/llvm-config --version
# see https://github.com/actions/runner/issues/801#issuecomment-2976165281
if [[ '${{ matrix.arch }}' == aarch64 ]]; then
sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release
apk add nodejs --update-cache
mkdir /opt/bin
ln -s /usr/bin/node /opt/bin/node
fi
fi
- uses: actions/checkout@v6
with:
submodules: true
- name: Install prerequisites
if: |
!startsWith(matrix.container_image, 'alpine') && !matrix.vm_os
uses: ./.github/actions/1-setup
with:
llvm_version: ${{ matrix.llvm_version || env.LLVM_VERSION }}
clang_major: ${{ env.CLANG_MAJOR }}
arch: ${{ matrix.arch }}
- name: Install prerequisites in FreeBSD VM
if: matrix.vm_os == 'freebsd'
shell: cpa.sh {0}
run: |
set -eux
sysctl -n hw.ncpu
sudo pkg install -y git cmake ninja gmake llvm19 bash 7-zip ldc python3 curl
python3 --version
python3 -m ensurepip
python3 -m pip install --user lit psutil
python3 -c "import lit.main; lit.main.main();" --version . | head -n 1
- name: 'Ubuntu 22: Build recent gdb from source' # see https://github.com/ldc-developers/ldc/issues/4389
if: startsWith(matrix.os, 'ubuntu-22.04')
uses: ./.github/actions/helper-build-gdb
with:
arch: ${{ matrix.arch }}
- name: Build bootstrap LDC
uses: ./.github/actions/2-build-bootstrap
with:
cmake_flags: -DBUILD_LTO_LIBS=ON ${{ matrix.base_cmake_flags }}
arch: ${{ matrix.arch }}
- name: Build LDC with PGO instrumentation & gather profile from compiling default libs
if: matrix.with_pgo
uses: ./.github/actions/2a-build-pgo
with:
cmake_flags: ${{ matrix.base_cmake_flags }}
arch: ${{ matrix.arch }}
- name: Build LDC & LDC D unittests & defaultlib unittest runners
uses: ./.github/actions/3-build-native
with:
cmake_flags: -DBUILD_LTO_LIBS=ON ${{ matrix.base_cmake_flags }} ${{ matrix.extra_cmake_flags }}
arch: ${{ matrix.arch }}
with_pgo: ${{ matrix.with_pgo }}
- name: Run LDC D unittests
if: success() || failure()
uses: ./.github/actions/4a-test-ldc2
- name: Run LIT testsuite
if: success() || failure()
uses: ./.github/actions/4b-test-lit
with:
arch: ${{ matrix.arch }}
- name: Run DMD testsuite
if: success() || failure()
uses: ./.github/actions/4c-test-dmd
with:
arch: ${{ matrix.arch }}
- name: Run defaultlib unittests & druntime integration tests
if: success() || failure()
uses: ./.github/actions/4d-test-libs
with:
arch: ${{ matrix.arch }}
- name: Install LDC
uses: ./.github/actions/5-install
with:
arch: ${{ matrix.arch }}
- name: 'macOS: Cross-compile iOS libraries, copy to install dir & extend ldc2.conf'
if: runner.os == 'macOS'
uses: ./.github/actions/5a-ios
with:
arch: ${{ matrix.arch }}
- name: Make portable
uses: ./.github/actions/5b-make-portable
- name: Run a few integration tests against the installed compiler
uses: ./.github/actions/6-integration-test
with:
arch: ${{ matrix.arch }}
- name: 'macOS: Run iOS cross-compilation integration test'
if: runner.os == 'macOS'
run: |
set -eux
cd ..
if [[ '${{matrix.arch}}' == 'arm64' ]]; then
triples=('arm64-apple-ios12.0' 'arm64-apple-ios12.0-simulator')
else
triples=('x86_64-apple-ios12.0-simulator')
fi
for triple in "${triples[@]}"; do
installed/bin/ldc2 -mtriple="$triple" hello.d -of=hello_ios
installed/bin/ldc2 -mtriple="$triple" hello.d -of=hello_ios_shared -link-defaultlib-shared
done
- name: Create package & upload artifact(s)
uses: ./.github/actions/7-package
with:
arch: ${{ matrix.arch }}
os: ${{ startsWith(matrix.container_image, 'alpine') && 'alpine' || (matrix.vm_os || '') }}
# Cross-compilation jobs for non-native targets.
# druntime/Phobos/LDC unittests aren't built; all test stages are skipped.
build-cross:
strategy:
fail-fast: false
matrix:
include:
- job_name: Android armv7a
host_os: ubuntu-22.04
os: android
arch: armv7a
android_x86_arch: i686
extra_cmake_flags: >-
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=arm-android
- job_name: Android aarch64
host_os: ubuntu-22.04
os: android
arch: aarch64
android_x86_arch: x86_64
extra_cmake_flags: >-
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64-android
name: ${{ matrix.job_name }}
runs-on: ${{ matrix.host_os }}
timeout-minutes: 60
env:
GHA_BASH_SHELL: bash
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Install prerequisites
uses: ./.github/actions/1-setup
with:
llvm_version: ${{ env.LLVM_VERSION }}
clang_major: ${{ env.CLANG_MAJOR }}
arch: x86_64
- name: Build bootstrap LDC
uses: ./.github/actions/2-build-bootstrap
- name: Build LDC with PGO instrumentation & gather profile from compiling default libs
if: matrix.with_pgo
uses: ./.github/actions/2a-build-pgo
- name: Cross-compile LDC to ${{ matrix.os }}-${{ matrix.arch }}
uses: ./.github/actions/3-build-cross
with:
arch: ${{ matrix.arch }}
os: ${{ matrix.os }}
llvm_version: ${{ env.LLVM_VERSION }}
cmake_flags: ${{ matrix.extra_cmake_flags }}
with_pgo: ${{ matrix.with_pgo }}
- name: Install LDC
uses: ./.github/actions/5-install
with:
cross_compiling: true
- name: 'Android: Cross-compile ${{ matrix.android_x86_arch }} libraries & copy to install dir'
if: matrix.os == 'android'
uses: ./.github/actions/5a-android-x86
with:
arch: ${{ matrix.android_x86_arch }}
- name: Make portable
uses: ./.github/actions/5b-make-portable
- name: Create package & upload artifact(s)
uses: ./.github/actions/7-package
with:
arch: ${{ matrix.arch }}
os: ${{ matrix.os }}
cross_target_triple: ${{ env.CROSS_TRIPLE }}
build-cross-libs-only:
strategy:
fail-fast: false
matrix:
include:
- job_name: WASI wasm32
arch: wasm32
name: ${{ matrix.job_name }}
runs-on: ubuntu-22.04-arm
timeout-minutes: 60
env:
GHA_BASH_SHELL: bash
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Install prerequisites
uses: ./.github/actions/1-setup
with:
llvm_version: ${{ env.LLVM_VERSION }}
clang_major: ${{ env.CLANG_MAJOR }}
arch: aarch64
- name: 'WASI: Install additional prerequisites'
uses: ./.github/actions/1a-setup-wasi
- name: Build bootstrap LDC
uses: ./.github/actions/2-build-bootstrap
- name: 'WASIp1: Cross-compile druntime incl. test runners & run druntime unittests'
uses: ./.github/actions/5a-wasi
with:
os: wasip1
arch: ${{ matrix.arch }}
- name: 'WASIp2: Cross-compile druntime incl. test runners & run druntime unittests'
uses: ./.github/actions/5a-wasi
with:
os: wasip2
arch: ${{ matrix.arch }}
- name: Make installed .conf files portable
uses: ./.github/actions/5b-make-portable
- name: Create addon package & upload artifact
uses: ./.github/actions/7-package
with:
arch: ${{ matrix.arch }}
os: wasi
is_addon: true
- name: Smoke-test add-on package
run: |
set -eux
# unpack addon archive into ../bootstrap-ldc
cd ../bootstrap-ldc
tar xf ${{ github.workspace }}/artifacts/*-addon-*.tar.xz
# generate hello.d
echo 'void main() { import core.stdc.stdio; printf("Hello world, %d bits\n", size_t.sizeof * 8); }' > hello.d
# put WASI-SDK clang onto PATH
export PATH="$PWD/../wasi-sdk/bin:$PATH"
# build & run hello-world
for os in wasip1 wasip2; do
# test LTO too
for args in "" "-O -flto=full -defaultlib=druntime-ldc-lto"; do
bin/ldc2 -mtriple=${{ matrix.arch }}-unknown-$os $args hello.d
ls -l hello.wasm
../wasmtime/wasmtime -W exceptions ./hello.wasm
done
done
merge-macos:
name: macOS universal
runs-on: macos-latest
timeout-minutes: 30
needs: build-native
steps:
- uses: actions/checkout@v6
- name: Merge x86_64 & arm64 packages to universal one
uses: ./.github/actions/merge-macos
merge-windows:
name: Windows multilib
runs-on: windows-2025
timeout-minutes: 30
needs: build-native
steps:
- uses: actions/checkout@v6
with:
submodules: true # Phobos needed for building arm64 libs
- name: Merge x64 & x86 packages to multilib one & build installer
uses: ./.github/actions/merge-windows
extract-addons:
name: Extract addon packages
runs-on: ubuntu-22.04
timeout-minutes: 30
needs:
- build-cross # Android
- merge-windows # Windows multilib
steps:
- uses: actions/checkout@v6
- name: Extract addon packages
uses: ./.github/actions/extract-addon-packages
upload-to-github:
name: Upload to GitHub
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 30
needs:
- build-native
- build-cross
- build-cross-libs-only
- merge-macos
- merge-windows
- extract-addons
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Upload all artifacts to GitHub release
uses: ./.github/actions/upload-to-github