CI: Bump Alpine image to v3.21 #2800
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
name: Main | |
on: | |
- pull_request | |
- push | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
LLVM_VERSION: 19.1.7 | |
jobs: | |
build-native: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- job_name: Linux x86_64 multilib | |
os: ubuntu-20.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 # Ubuntu 20 not natively supported | |
container_image: ubuntu:20.04 | |
arch: aarch64 | |
base_cmake_flags: >- | |
-DCOMPILER_RT_LIBDIR_OS=aarch64-unknown-linux-gnu | |
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-latest | |
container_image: alpine:3.21 | |
arch: x86_64 | |
base_cmake_flags: >- | |
-DCOMPILER_RT_LIBDIR_OS=linux | |
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=x86_64 | |
-DLLVM_IS_SHARED=OFF | |
-DLDC_ENABLE_PLUGINS=OFF | |
-DLDC_DYNAMIC_COMPILE=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" | |
-DEXTRA_CXXFLAGS=-flto=full | |
# FIXME: -defaultlib=phobos2-ldc-lto,druntime-ldc-lto | |
with_pgo: true | |
- job_name: macOS x86_64 | |
os: macos-13 | |
arch: x86_64 | |
# 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. | |
# | |
# We also need to work around issues with the used LDC v1.35.0 host/bootstrap compiler: | |
# * Specify a macOS triple with OS version. And exclude LTO-able host druntime/Phobos because precompiled without OS version. | |
# * Manually specify the path to the bundled libLTO.dylib (broken for *universal* packages for LDC <= v1.40.0). | |
extra_cmake_flags: >- | |
-DD_COMPILER_FLAGS="-O -flto=full -L-exported_symbol '-L__*' -L-w -flto-binary=$PWD/../bootstrap-ldc/lib-x86_64/libLTO.dylib -mtriple=x86_64-apple-macos$MACOSX_DEPLOYMENT_TARGET" | |
-DEXTRA_CXXFLAGS=-flto=full | |
with_pgo: true | |
- job_name: macOS arm64 | |
os: macos-15 | |
arch: arm64 | |
extra_cmake_flags: >- | |
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w -flto-binary=$PWD/../bootstrap-ldc/lib-arm64/libLTO.dylib" | |
-DEXTRA_CXXFLAGS=-flto=full | |
with_pgo: true | |
- job_name: Windows x64 | |
os: windows-2022 | |
arch: x64 | |
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-2022 | |
arch: x86 | |
# `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 | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.os }} | |
container: ${{ matrix.container_image }} | |
timeout-minutes: 90 | |
env: | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.arch == 'arm64' && '11.0' || '10.12' }} | |
steps: | |
- 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 | |
# create missing 7za symlink | |
ln -s 7z /usr/bin/7za | |
# make lld the default linker | |
ln -sf ld.lld /usr/bin/ld | |
ld --version | |
# create ../llvm symlink to distro LLVM (no prebuilt LDC-LLVM for musl) | |
ln -s /usr/lib/llvm19 $(dirname $(pwd))/llvm | |
../llvm/bin/llvm-config --version | |
fi | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 50 | |
- name: Install prerequisites | |
if: | | |
!startsWith(matrix.container_image, 'alpine') | |
uses: ./.github/actions/1-setup | |
with: | |
llvm_version: ${{ matrix.llvm_version || env.LLVM_VERSION }} | |
arch: ${{ matrix.arch }} | |
- name: Build bootstrap LDC | |
if: runner.os != 'macOS' | |
uses: ./.github/actions/2-build-bootstrap | |
with: | |
cmake_flags: -DBUILD_LTO_LIBS=ON ${{ matrix.base_cmake_flags }} | |
arch: ${{ matrix.arch }} | |
# FIXME: on macOS, mixing newer LLVM from bootstrap LDC with older LLVM from Xcode clang is problematic, | |
# leading to sporadic 'libc++abi: Pure virtual function called!' compiler crashes etc. | |
- name: 'macOS: Use host LDC (with Xcode-compatible LLVM version) as bootstrap LDC' | |
if: runner.os == 'macOS' | |
run: | | |
ln -s $(dirname $(dirname $(which ldmd2))) ../bootstrap-ldc | |
# work around a v1.35.0 bug - need to rename libLTO-ldc.dylib to make it loadable | |
if [[ '${{ matrix.arch }}' == 'x86_64' ]]; then | |
mv ../bootstrap-ldc/lib-x86_64/libLTO-ldc.dylib ../bootstrap-ldc/lib-x86_64/libLTO.dylib | |
fi | |
- 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 & make portable | |
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: 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 .. | |
triple='${{ matrix.arch }}-apple-ios12.0${{ matrix.arch == 'x86_64' && '-simulator' || '' }}' | |
installed/bin/ldc2 -mtriple="$triple" hello.d -of=hello_ios | |
installed/bin/ldc2 -mtriple="$triple" hello.d -of=hello_ios_shared -link-defaultlib-shared | |
- name: Create package & upload artifact(s) | |
uses: ./.github/actions/7-package | |
with: | |
arch: ${{ matrix.arch }} | |
os: ${{ startsWith(matrix.container_image, 'alpine') && 'alpine' || '' }} | |
# 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-20.04 | |
os: android | |
arch: armv7a | |
android_x86_arch: i686 | |
- job_name: Android aarch64 | |
host_os: ubuntu-20.04 | |
os: android | |
arch: aarch64 | |
android_x86_arch: x86_64 | |
extra_cmake_flags: >- | |
-DCOMPILER_RT_LIBDIR_OS=linux | |
-DLDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64-android | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.host_os }} | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 50 | |
- name: Install prerequisites | |
uses: ./.github/actions/1-setup | |
with: | |
llvm_version: ${{ env.LLVM_VERSION }} | |
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 & make portable | |
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: Create package & upload artifact(s) | |
uses: ./.github/actions/7-package | |
with: | |
arch: ${{ matrix.arch }} | |
os: ${{ matrix.os }} | |
cross_target_triple: ${{ env.CROSS_TRIPLE }} | |
merge-macos: | |
name: macOS universal | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
needs: build-native | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Merge x86_64 & arm64 packages to universal one | |
uses: ./.github/actions/merge-macos | |
merge-windows: | |
name: Windows multilib | |
runs-on: windows-2022 | |
timeout-minutes: 30 | |
needs: build-native | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 50 | |
- name: Merge x64 & x86 packages to multilib one & build installer | |
uses: ./.github/actions/merge-windows | |
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 | |
- merge-macos | |
- merge-windows | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Upload all artifacts to GitHub release | |
uses: ./.github/actions/upload-to-github |