[LDC] CI: Use new native macOS arm64 runners #32
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: LDC-specific release | |
on: | |
- pull_request | |
- push | |
- workflow_dispatch | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CLANG_VERSION: 15.0.6 | |
# Prevent dependencies on some purely optional libraries, and a dependency on clang | |
# for compiler-rt tests. | |
BASE_CMAKE_FLAGS: >- | |
-DLLVM_ENABLE_UNWIND_TABLES=OFF | |
-DLLVM_ENABLE_TERMINFO=OFF | |
-DLLVM_ENABLE_LIBEDIT=OFF | |
-DCOMPILER_RT_INCLUDE_TESTS=OFF | |
-DLLVM_INCLUDE_TESTS=OFF | |
-DCOMPILER_RT_USE_LIBCXX=OFF | |
jobs: | |
build-native: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- job_name: Windows x64 | |
os: windows-2022 | |
arch: x64 | |
with_asserts: false | |
- job_name: Windows x64 withAsserts | |
os: windows-2022 | |
arch: x64 | |
with_asserts: true | |
- job_name: Windows x86 | |
os: windows-2022 | |
arch: x86 | |
with_asserts: false | |
- job_name: Windows x86 withAsserts | |
os: windows-2022 | |
arch: x86 | |
with_asserts: true | |
- job_name: Linux x86_64 | |
os: ubuntu-20.04 | |
arch: x86_64 | |
with_asserts: false | |
- job_name: Linux x86_64 withAsserts | |
os: ubuntu-20.04 | |
arch: x86_64 | |
with_asserts: true | |
- job_name: macOS arm64 | |
os: macos-14 | |
arch: arm64 | |
with_asserts: false | |
- job_name: macOS arm64 withAsserts | |
os: macos-14 | |
arch: arm64 | |
with_asserts: true | |
- job_name: macOS x86_64 | |
os: macos-11 | |
arch: x86_64 | |
with_asserts: false | |
- job_name: macOS x86_64 withAsserts | |
os: macos-11 | |
arch: x86_64 | |
with_asserts: true | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 240 | |
env: | |
# 10.12 is the min version for BOLT | |
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.arch == 'arm64' && '11.0' || '10.12' }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 50 | |
- name: Install prerequisites | |
uses: ./.github/actions/1-setup | |
with: | |
# on Windows, the MSVC headers require clang 16+ | |
clang_version: ${{ runner.os == 'Windows' && '17.0.6' || env.CLANG_VERSION }} | |
arch: ${{ matrix.arch }} | |
- name: Build & install LLVM incl. LLD, compiler-rt, MLIR, BOLT | |
uses: ./.github/actions/2-build | |
with: | |
arch: ${{ matrix.arch }} | |
# exclude MLIR and BOLT on Windows | |
enable_projects: ${{ runner.os == 'Windows' && 'compiler-rt;lld' || 'bolt;compiler-rt;lld;mlir' }} | |
targets_to_build: all | |
experimental_targets_to_build: SPIRV | |
with_asserts: ${{ matrix.with_asserts }} | |
# - link C++ standard library statically for improved portability on Windows and Linux | |
# - on Linux, need LLVM_BINUTILS_INCDIR to generate LTO linker plugin | |
# - on macOS, need to disable libzstd (not found for LDC CI job) | |
extra_cmake_flags: >- | |
${{ env.BASE_CMAKE_FLAGS }} | |
${{ runner.os == 'Windows' && '-DLLVM_USE_CRT_RELEASE=MT' || '' }} | |
${{ runner.os == 'Linux' && '-DLLVM_BINUTILS_INCDIR=/usr/include -DLLVM_STATIC_LINK_CXX_STDLIB=ON' || '' }} | |
${{ runner.os == 'macOS' && '-DLLVM_ENABLE_ZSTD=OFF' || '' }} | |
- name: Create package & upload artifact | |
uses: ./.github/actions/3-package | |
with: | |
arch: ${{ matrix.arch }} | |
with_asserts: ${{ matrix.with_asserts }} | |
build-cross: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- job_name: Android armv7a | |
host_os: ubuntu-20.04 | |
os: android | |
arch: armv7a | |
targets_to_build: AArch64;ARM;WebAssembly;X86 | |
experimental_targets_to_build: SPIRV | |
- job_name: Android aarch64 | |
host_os: ubuntu-20.04 | |
os: android | |
arch: aarch64 | |
targets_to_build: AArch64;ARM;WebAssembly;X86 | |
experimental_targets_to_build: SPIRV | |
name: ${{ matrix.job_name }} | |
runs-on: ${{ matrix.host_os }} | |
timeout-minutes: 240 | |
env: | |
ANDROID_NDK_VERSION: r21e | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 50 | |
- name: Install prerequisites | |
uses: ./.github/actions/1-setup | |
with: | |
clang_version: ${{ env.CLANG_VERSION }} | |
arch: ${{ matrix.arch }} | |
- name: Build native llvm-tblgen | |
shell: bash | |
run: | | |
set -eux | |
cd .. | |
mkdir build-native | |
cd build-native | |
cmake -G Ninja ../llvm-project/llvm \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_TARGETS_TO_BUILD="${{ matrix.targets_to_build }}" \ | |
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${{ matrix.experimental_targets_to_build }}" \ | |
${{ env.BASE_CMAKE_FLAGS }} | |
ninja llvm-tblgen | |
- name: Set up cross-compilation | |
shell: bash | |
run: | | |
set -eux | |
os='${{ matrix.os }}' | |
arch='${{ matrix.arch }}' | |
if [[ "$os" == android ]]; then | |
# download & extract Android NDK | |
cd .. | |
curl -fL --retry 3 --max-time 300 -o android-ndk.zip \ | |
https://dl.google.com/android/repository/android-ndk-$ANDROID_NDK_VERSION-linux-x86_64.zip | |
unzip android-ndk.zip >/dev/null | |
mv "android-ndk-$ANDROID_NDK_VERSION" android-ndk | |
rm android-ndk.zip | |
# The NDK toolchain file enforces `-g` as base C[XX] flag - remove it to | |
# *significantly* reduce executable sizes | |
toolchainFile="$PWD/android-ndk/build/cmake/android.toolchain.cmake" | |
sed -i 's|^ -g$||' "$toolchainFile" | |
flags=( | |
-DCMAKE_TOOLCHAIN_FILE="$toolchainFile" | |
-DANDROID_NATIVE_API_LEVEL=21 | |
-DANDROID_STL=c++_static | |
-DCMAKE_CROSSCOMPILING=True | |
-DLLVM_ENABLE_PLUGINS=OFF | |
) | |
if [[ "$arch" == armv7a ]]; then | |
flags+=( | |
-DANDROID_ABI=armeabi-v7a | |
-DLLVM_TARGET_ARCH=ARM | |
-DLLVM_DEFAULT_TARGET_TRIPLE=armv7a--linux-androideabi | |
) | |
elif [[ "$arch" == aarch64 ]]; then | |
flags+=( | |
-DANDROID_ABI=arm64-v8a | |
-DLLVM_TARGET_ARCH=AArch64 | |
-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64--linux-android | |
-DSANITIZER_CXX_ABI=libc++ | |
-DCMAKE_CXX_FLAGS=-U_FORTIFY_SOURCE | |
) | |
fi | |
fi | |
echo "EXTRA_CMAKE_FLAGS_CROSS=${flags[*]}" >> $GITHUB_ENV | |
- name: Cross-build & install LLVM incl. LLD, compiler-rt, BOLT | |
uses: ./.github/actions/2-build | |
with: | |
# exclude MLIR - compile errors for ARM | |
enable_projects: bolt;compiler-rt;lld | |
targets_to_build: ${{ matrix.targets_to_build }} | |
experimental_targets_to_build: ${{ matrix.experimental_targets_to_build }} | |
with_asserts: ${{ matrix.with_asserts }} | |
extra_cmake_flags: >- | |
${{ env.BASE_CMAKE_FLAGS }} | |
-DLLVM_TABLEGEN="${{ github.workspace }}/../build-native/bin/llvm-tblgen" | |
-DLLVM_CONFIG_PATH="${{ github.workspace }}/../build-native/bin/llvm-config" | |
${{ env.EXTRA_CMAKE_FLAGS_CROSS }} | |
- name: Create package & upload artifact | |
uses: ./.github/actions/3-package | |
with: | |
arch: ${{ matrix.arch }} | |
os: ${{ matrix.os }} | |
with_asserts: ${{ matrix.with_asserts }} | |
upload-to-github: | |
name: Upload to GitHub | |
# only run for branches and tags, no PRs | |
if: startsWith(github.ref, 'refs/tags/ldc-v') || startsWith(github.ref, 'refs/heads/') | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: | |
- build-native | |
- build-cross | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Upload all artifacts to GitHub release | |
uses: ./.github/actions/upload-to-github |