feat: add pre-commit hooks and fix build issues #58
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
name: Build amd64 | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- ".github/workflows/build-amd64.yml" | |
pull_request: | |
branches: [ master ] | |
paths: | |
- ".github/workflows/build-amd64.yml" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
clang-version: [ 19, 18, 17, 16, 15, 14, 13, 12.0.1, 12, 11, 10, 9, 8, 7 ] | |
os: [ linux, macosx, windows ] | |
include: | |
- clang-version: 19 | |
release: llvm-project-19.1.0.src | |
- clang-version: 18 | |
release: llvm-project-18.1.5.src | |
- clang-version: 17 | |
release: llvm-project-17.0.4.src | |
- clang-version: 16 | |
release: llvm-project-16.0.3.src | |
- clang-version: 15 | |
release: llvm-project-15.0.2.src | |
- clang-version: 14 | |
release: llvm-project-14.0.0.src | |
- clang-version: 13 | |
release: llvm-project-13.0.0.src | |
- clang-version: 12.0.1 | |
release: llvm-project-12.0.1.src | |
- clang-version: 12 | |
release: llvm-project-12.0.0.src | |
- clang-version: 11 | |
release: llvm-project-11.1.0.src | |
- clang-version: 10 | |
release: llvm-project-10.0.1 | |
extra-cmake-args: '-DLLVM_ENABLE_Z3_SOLVER=OFF' | |
- clang-version: 9 | |
release: llvm-project-9.0.1 | |
extra-cmake-args: '-DLLVM_ENABLE_Z3_SOLVER=OFF' | |
- clang-version: 8 | |
release: llvm-project-8.0.1 | |
extra-cmake-args: '-DCLANG_ANALYZER_ENABLE_Z3_SOLVER=OFF' | |
- clang-version: 7 | |
release: llvm-project-7.1.0 | |
- os: linux | |
runner: ubuntu-22.04 | |
os-cmake-args: '-DLLVM_BUILD_STATIC=ON -DCMAKE_CXX_FLAGS="-s -flto" ${LINUX_CMAKE_ARGS}' | |
build-args: '-j$(nproc)' | |
bindir: '/build/bin' | |
dotexe: '' | |
shacmd: 'sha512sum' | |
- os: macosx | |
runner: macos-14 | |
os-cmake-args: '-DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++ -flto" -DCMAKE_OSX_DEPLOYMENT_TARGET=11 ${MACOS_CMAKE_ARGS}' | |
build-args: '-j$(sysctl -n hw.ncpu)' | |
bindir: '/build/bin' | |
dotexe: '' | |
shacmd: 'shasum -a512' | |
- 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/*' | |
runs-on: ${{ matrix.runner }} | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
env: | |
COMMON_CMAKE_ARGS: '-DBUILD_SHARED_LIBS=OFF -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"' | |
MACOS_CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 -DZSTD_STATIC_LINKING_ONLY=1' | |
LINUX_CMAKE_ARGS: '-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_C_COMPILER=gcc-10' | |
RELEASE: '${{ matrix.release }}' | |
suffix: '${{ matrix.clang-version }}_${{ matrix.os }}-amd64' | |
steps: | |
- 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 || 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: 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-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.clang-version >= '18' | |
shell: bash | |
run: | | |
sed -i.backup 's/gcc_eh.\*|/gcc_eh.*|gcc_ext.*|/g' "$(find /opt/homebrew/Cellar -name CMakeParseImplicitLinkInfo.cmake)" | |
brew install gcc@11 | |
- name: update homebrew | |
if: ${{ matrix.os == 'macosx' }} | |
run: brew upgrade node | |
- 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' }} | |
run: otool -L ${{ matrix.release }}/build/bin/clang-format | |
- 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 | |
if: ${{ github.actor != 'dependabot[bot]' }} || github.event_name != 'pull_request' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: clang-tools | |
path: "${{ matrix.release }}${{ matrix.bindir }}/clang-*-${{ env.suffix }}*" | |
retention-days: 1 | |
draft-release: | |
runs-on: ubuntu-22.04 | |
if: ${{ github.actor != 'dependabot[bot]' }} || github.event_name != 'pull_request' | |
needs: build | |
steps: | |
- name: download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: clang-tools | |
- name: list files | |
run: ls -laR . | |
- name: draft release | |
uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
file: "clang-*" | |
draft: true |