Skip to content

Fixes macOS arm 19 and 20 #80

Fixes macOS arm 19 and 20

Fixes macOS arm 19 and 20 #80

name: clang-tools-static-amd64
on:
push:
branches: [ master ]
pull_request:
workflow_dispatch:
jobs:
build:
concurrency:
group: >-
${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{
matrix.clang-version }}-${{ matrix.os }}-${{ matrix.runner }}
cancel-in-progress: true
strategy:
matrix:
clang-version: [ 3.9, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12.0.1, 13, 14, 15, 16, 17, 18, 19, 20 ]
os: [ linux, macosx, macos-arm, windows ]
include:
- clang-version: 3.9
release: llvm-project-3.9.1
- clang-version: 4
release: llvm-project-4.0.1
- clang-version: 5
release: llvm-project-5.0.2
- clang-version: 6
release: llvm-project-6.0.1
- clang-version: 7
release: llvm-project-7.1.0
- clang-version: 8
release: llvm-project-8.0.1
extra-cmake-args: '-DCLANG_ANALYZER_ENABLE_Z3_SOLVER=OFF'
- clang-version: 9
release: llvm-project-9.0.1
extra-cmake-args: '-DLLVM_ENABLE_Z3_SOLVER=OFF'
- clang-version: 10
release: llvm-project-10.0.1
extra-cmake-args: '-DLLVM_ENABLE_Z3_SOLVER=OFF'
- clang-version: 11
release: llvm-project-11.1.0.src
- clang-version: 12
release: llvm-project-12.0.0.src
- clang-version: 12.0.1
release: llvm-project-12.0.1.src
- clang-version: 13
release: llvm-project-13.0.0.src
- clang-version: 14
release: llvm-project-14.0.0.src
- clang-version: 15
release: llvm-project-15.0.2.src
- clang-version: 16
release: llvm-project-16.0.3.src
- clang-version: 17
release: llvm-project-17.0.4.src
- clang-version: 18
release: llvm-project-18.1.8.src
- clang-version: 19
release: llvm-project-19.1.0.src
- clang-version: 20
release: llvm-project-20.1.0.src
- os: linux
runner: ubuntu-22.04
os-cmake-args: '-DLLVM_BUILD_STATIC=ON -DCMAKE_CXX_FLAGS="-s -flto" ${POSIX_CMAKE_ARGS} ${LINUX_CMAKE_ARGS}'
build-args: '-j$(nproc)'
bindir: '/build/bin'
dotexe: ''
shacmd: 'sha512sum'
arch: 'amd64'
- os: macosx
# Uses a macOS amd image here
# https://github.com/actions/runner-images
runner: macos-13
os-cmake-args: '-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -flto -ffunction-sections -fdata-sections" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-dead_strip" ${POSIX_CMAKE_ARGS} ${MACOS_CMAKE_ARGS} -DLLVM_TARGETS_TO_BUILD=X86'
build-args: '-j$(sysctl -n hw.ncpu)'
bindir: '/build/bin'
dotexe: ''
shacmd: 'shasum -a512'
arch: 'amd64'
- os: macos-arm
# Uses a macOS arm image here
# https://github.com/actions/runner-images
runner: macos-14
os-cmake-args: '-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -flto -ffunction-sections -fdata-sections" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-dead_strip" ${POSIX_CMAKE_ARGS} ${MACOS_CMAKE_ARGS} -DLLVM_TARGETS_TO_BUILD=AArch64'
build-args: '-j$(sysctl -n hw.ncpu)'
bindir: '/build/bin'
dotexe: ''
shacmd: 'shasum -a512'
arch: 'arm64'
- os: windows
runner: windows-latest
os-cmake-args: '-Thost=x64 -DCMAKE_CXX_FLAGS="/MP /std:c++14" -DLLVM_USE_CRT_MINSIZEREL="MT"'
build-args: '--config MinSizeRel'
bindir: '/build/MinSizeRel/bin'
dotexe: '.exe'
shacmd: 'sha512sum.exe'
extra-tar-args: '--exclude=${RELEASE}/clang/test/Driver/Inputs/* --exclude=${RELEASE}/libcxx/test/std/input.output/filesystems/Inputs/static_test_env/* --exclude=${RELEASE}/libclc/amdgcn-mesa3d'
extra-tar-args-cfe: '--exclude=cfe-${version}.src/test/Driver/Inputs/*'
arch: 'amd64'
exclude:
# Clang 17 does not build on mac arm
# See: https://github.com/llvm/llvm-project/pull/78704
# https://github.com/llvm/llvm-project/issues/106521
- clang-version: 17
os: macos-arm
runs-on: ${{ matrix.runner }}
env:
COMMON_CMAKE_ARGS: '-DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"'
LINUX_CMAKE_ARGS: '-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_C_COMPILER=gcc-10'
MACOS_CMAKE_ARGS: '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_ZLIB=OFF'
POSIX_CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=MinSizeRel'
RELEASE: '${{ matrix.release }}'
suffix: '${{ matrix.clang-version }}_${{ matrix.os }}-${{ matrix.arch }}'
steps:
- name: print system info on macos and linux
run: |
uname -a || systeminfo
if: ${{ matrix.os != 'windows' }}
- name: download patches
# we download a tarball of this repo, as the presence of a .git directory leaks
# the commit hash of this repository into the clang binaries
shell: bash
run: curl -L https://github.com/${{ github.repository }}/archive/${{ github.ref }}.tar.gz | tar xvz --strip 1
- name: get llvm-project
if: ${{ matrix.clang-version < 7 }}
shell: bash
run: |
version=${RELEASE##llvm-project-}
curl -LO https://releases.llvm.org/${version}/llvm-${version}.src.tar.xz
curl -LO https://releases.llvm.org/${version}/cfe-${version}.src.tar.xz
curl -LO https://releases.llvm.org/${version}/clang-tools-extra-${version}.src.tar.xz
- name: get llvm-project
if: ${{ matrix.clang-version == 7 || matrix.clang-version == 8 }}
shell: bash
run: |
version=${RELEASE##llvm-project-}
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-${version}.src.tar.xz
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/cfe-${version}.src.tar.xz
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/clang-tools-extra-${version}.src.tar.xz
- name: get llvm-project
if: ${{ matrix.clang-version >= 9 || matrix.clang-version == '12.0.1' }}
shell: bash
run: |
version=${RELEASE##llvm-project-}; version=${version%.src}
curl -LO https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/${{ matrix.release }}.tar.xz
- name: unpack llvm-project
if: ${{ matrix.clang-version < 9 }}
shell: bash
run: |
version=${RELEASE##llvm-project-}
tar xf llvm-${version}.src.tar.xz
tar xf cfe-${version}.src.tar.xz ${{ matrix.extra-tar-args-cfe }}
tar xf clang-tools-extra-${version}.src.tar.xz
mkdir ${{ matrix.release }}
mv llvm-${version}.src ${{ matrix.release }}/llvm
mv cfe-${version}.src ${{ matrix.release }}/clang
mv clang-tools-extra-${version}.src ${{ matrix.release }}/clang-tools-extra
- name: move clang 3.9 sources
if: ${{ matrix.clang-version == 3.9 }}
run: |
mv ${{ matrix.release }}/clang ${{ matrix.release }}/llvm/tools/clang
mv ${{ matrix.release }}/clang-tools-extra ${{ matrix.release }}/llvm/tools/clang/tools/extra
- name: unpack llvm-project
if: ${{ matrix.clang-version >= 9 || matrix.clang-version == '12.0.1' }}
shell: bash
run: |
tar xf ${{ matrix.release }}.tar.xz ${{ matrix.extra-tar-args }}
- name: patch clang-3.9 constify operator
if: ${{ matrix.clang-version == 3.9 && matrix.os == 'windows' }}
shell: bash
run: patch ${{ matrix.release }}/llvm/utils/TableGen/AsmWriterEmitter.cpp windows-clang-3.9_constify-operator.patch
- name: patch clang-8 includes
if: ${{ matrix.clang-version == 8 }}
shell: bash
run: patch ${{ matrix.release }}/llvm/include/llvm/Demangle/MicrosoftDemangleNodes.h include-cstdint-string-prior-to-using-uint8_t.patch
- name: patch trivially-copyable clang 9/10
if: ${{ ( matrix.clang-version == 9 || matrix.clang-version == 10 ) && matrix.os == 'windows' }}
shell: bash
run: patch ${{ matrix.release }}/llvm/cmake/config-ix.cmake windows-clang-9-10-trivially-copyable-mismatch.patch
- name: Patch cmake implicit link libraries on macosx
if: ${{ matrix.os == 'macosx' || matrix.os == 'macos-arm' }}
shell: bash
run: |
BREW_PREFIX=$(brew --prefix)
FILES=$(find "$BREW_PREFIX" -name CMakeParseImplicitLinkInfo.cmake)
for file in $FILES; do
echo "Patching $file"
sed -i.backup 's/gcc_eh.*|/gcc_eh.*|gcc_ext.*|/g' "$file"
done
- name: cmake
run: cmake -S ${{ matrix.release }}/llvm -B ${{ matrix.release }}/build ${{ env.COMMON_CMAKE_ARGS }} ${{ matrix.os-cmake-args }} ${{ matrix.extra-cmake-args }}
- name: build
run: cmake --build ${{ matrix.release }}/build ${{ matrix.build-args }} --target clang-format clang-query clang-tidy clang-apply-replacements
- name: print dependencies
if: ${{ matrix.os == 'macosx' || matrix.os == 'macos-arm' }}
run: otool -L ${{ matrix.release }}/build/bin/clang-format
- name: smoke test clang-tools (macos, linux)
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' || matrix.os == 'macos-arm' }}
run: |
cd ${{ matrix.release }}/build/bin
./clang-format --version
./clang-query --version
./clang-tidy --version
./clang-apply-replacements --version
- name: smoke test clang-tools (windows)
if: ${{ matrix.os == 'windows' }}
run: |
cd ${{ matrix.release }}${{ matrix.bindir }}
clang-format${{ matrix.dotexe }} --version
clang-query${{ matrix.dotexe }} --version
clang-tidy${{ matrix.dotexe }} --version
clang-apply-replacements${{ matrix.dotexe }} --version
- name: rename output binary
run: |
cd ${{ matrix.release }}${{ matrix.bindir }}
mv clang-format${{ matrix.dotexe }} clang-format-${{ env.suffix }}${{ matrix.dotexe }}
mv clang-query${{ matrix.dotexe }} clang-query-${{ env.suffix }}${{ matrix.dotexe }}
mv clang-tidy${{ matrix.dotexe }} clang-tidy-${{ env.suffix }}${{ matrix.dotexe }}
mv clang-apply-replacements${{ matrix.dotexe }} clang-apply-replacements-${{ env.suffix }}${{ matrix.dotexe }}
- name: create and print sha512sum
shell: bash
run: |
cd ${{ matrix.release }}${{ matrix.bindir }}
${{ matrix.shacmd }} clang-format-${{ env.suffix }} > clang-format-${{ env.suffix }}.sha512sum
${{ matrix.shacmd }} clang-query-${{ env.suffix }} > clang-query-${{ env.suffix }}.sha512sum
${{ matrix.shacmd }} clang-tidy-${{ env.suffix }} > clang-tidy-${{ env.suffix }}.sha512sum
${{ matrix.shacmd }} clang-apply-replacements-${{ env.suffix }} > clang-apply-replacements-${{ env.suffix }}.sha512sum
echo "Checksums are: "
cat clang-format-${{ env.suffix }}.sha512sum
cat clang-query-${{ env.suffix }}.sha512sum
cat clang-tidy-${{ env.suffix }}.sha512sum
cat clang-apply-replacements-${{ env.suffix }}.sha512sum
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: clang-tools-${{ matrix.release }}-${{ env.suffix }}
path: "${{ matrix.release }}${{ matrix.bindir }}/clang-*-${{ env.suffix }}*"
retention-days: 1
test-release:
concurrency:
group: >-
${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}-${{
'' }}-${{ matrix.os }}-${{ matrix.runner }}
cancel-in-progress: true
strategy:
matrix:
os: [ linux, macosx, windows, macos-arm ]
include:
- os: linux
runner: ubuntu-22.04
arch: 'amd64'
- os: macosx
runner: macos-13 # Intel macOS runner test
arch: 'amd64'
- os: windows
runner: windows-latest
arch: 'amd64'
- os: macos-arm
runner: macos-14 # Apple silicon macOS runner test
arch: 'arm64'
runs-on: ${{ matrix.runner }}
needs: build
env:
suffix: '_${{ matrix.os }}-${{ matrix.arch }}'
steps:
- name: download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: '**/*${{ env.suffix }}'
- name: list files (macos, linux)
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' || matrix.os == 'macos-arm' }}
run: ls -laR artifacts/
- name: smoke test each clang tool (macos, linux)
if: ${{ matrix.os == 'macosx' || matrix.os == 'linux' || matrix.os == 'macos-arm' }}
run: |
cd artifacts
# From the artifacts directory, loop over each executable
# (not .sha512sum files) and
# invoke the --version command to verify
for tool in $(find . -type f); do
# Skip the sha512sum files
if [[ $tool == *.sha512sum ]]; then
continue
fi
chmod +x $tool
# Run the tool with --version and print the output
echo "Running $tool --version"
$tool --version
done
- name: List files (Windows)
if: ${{ matrix.os == 'windows' }}
run: |
Get-ChildItem -Recurse artifacts | Format-List
- name: Smoke test each clang tool (Windows)
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: |
Set-Location artifacts
# Find all files excluding *.sha512sum
$tools = Get-ChildItem -Recurse -File | Where-Object { $_.Name -notlike '*.sha512sum' }
foreach ($tool in $tools) {
# Ensure the file is executable
$toolPath = $tool.FullName
# Print which tool is being run
Write-Host "Running $toolPath --version"
try {
# Attempt to run the tool with --version
& $toolPath --version
} catch {
Write-Host "Failed to run $toolPath --version. Error: $_"
}
}
draft-release:
runs-on: ubuntu-22.04
if: ${{ github.ref == 'ref/head/master' }}
needs: [build, test-release]
steps:
- name: download artifacts
uses: actions/download-artifact@v4
- name: list files
run: ls -laR .
- name: Workaround - delete all files over 2G, above github release file upload limit
run: find . -type f -size +2G -exec rm -v {} \;
- name: draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
draft: true
file_glob: true
file: clang-*/**/*
check_duplicates: false