Skip to content

build-llvm-binaries #50

build-llvm-binaries

build-llvm-binaries #50

Workflow file for this run

name: build-llvm-binaries
on:
workflow_dispatch:
inputs:
llvm_version:
description: 'LLVM Version'
default: '17.0.6'
required: false
type: string
debug_info:
description: 'Emit PDBs (Debug Info)'
default: false
type: boolean
env:
SCCACHE_DIRECT: yes
jobs:
build_tools:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
include:
# Default valuies
- c_compiler: clang
- cxx_compiler: clang++
- executable_suffix:
# Overrides
- c_compiler: cl
os: windows-latest
- cxx_compiler: cl
os: windows-latest
- executable_suffix: .exe
os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ inputs.llvm_version }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: compnerd/gha-setup-vsdevenv@main
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: Setup sccache
uses: compnerd/[email protected]
with:
max-size: 100M
key: sccache-${{ matrix.os }}-build_tools
variant: sccache
- name: Configure Tools
run: >-
cmake -B ${{ github.workspace }}/BinaryCache/0
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }}
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_MT=mt
-G Ninja
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm
-D LLVM_ENABLE_ASSERTIONS=NO
-D LLVM_ENABLE_LIBEDIT=NO
-D LLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lldb"
-D LLDB_ENABLE_PYTHON=NO
-D LLDB_INCLUDE_TESTS=NO
- name: Build llvm-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-tblgen
- name: Build clang-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tblgen
- name: Build lldb-tblgen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target lldb-tblgen
- name: Build llvm-config
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target llvm-config
- name: Build clang-pseudo-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-pseudo-gen
- name: Build clang-tidy-confusable-chars-gen
run: cmake --build ${{ github.workspace }}/BinaryCache/0 --target clang-tidy-confusable-chars-gen
- uses: actions/upload-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: |
${{ github.workspace }}/BinaryCache/0/bin/llvm-tblgen${{ matrix.executable_suffix }}
${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${{ matrix.executable_suffix }}
${{ github.workspace }}/BinaryCache/0/bin/lldb-tblgen${{ matrix.executable_suffix }}
${{ github.workspace }}/BinaryCache/0/bin/llvm-config${{ matrix.executable_suffix }}
${{ github.workspace }}/BinaryCache/0/bin/clang-pseudo-gen${{ matrix.executable_suffix }}
${{ github.workspace }}/BinaryCache/0/bin/clang-tidy-confusable-chars-gen${{ matrix.executable_suffix }}
distribution:
needs: [build_tools]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
arch: [amd64, arm64]
include:
# Default values
- c_compiler: clang
- cxx_compiler: clang++
- toolset_suffix:
- cmake_system_name:
- cmake_system_processor:
- lldb_enable_libxml2:
- into_environment: '>> $GITHUB_ENV'
- executable_suffix:
- llvm_enable_projects: 'clang;lld'
# Overrides
- into_environment: '| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append'
os: windows-latest
- c_compiler: cl
os: windows-latest
- cxx_compiler: cl
os: windows-latest
- toolset_suffix: -msvc17
os: windows-latest
- cmake_system_processor: -D CMAKE_SYSTEM_PROCESSOR=ARM64
arch: arm64
- cmake_system_name: -D CMAKE_SYSTEM_NAME=Windows
arch: arm64
os: windows-latest
- cmake_system_name: -D CMAKE_SYSTEM_NAME=Darwin
arch: arm64
os: macos-latest
- lldb_enable_libxml2: -D LLDB_ENABLE_LIBXML2=NO
arch: arm64
- executable_suffix: .exe
os: windows-latest
- llvm_enable_projects: 'clang;lld;lldb'
os: windows-latest
# Extensions
- triple_cpu: x86_64
arch: amd64
- triple_cpu: arm64
arch: arm64
- triple_suffix: unknown-windows-msvc17
os: windows-latest
- triple_suffix: unknown-linux-gnu
os: ubuntu-latest
- triple_suffix: apple-darwin23.3.0
os: macos-latest
runs-on: ${{ matrix.os }}
env:
# Must be a full version string from https://www.nuget.org/packages/pythonarm64
PYTHON_VERSION: 3.12.2
TARGET_TRIPLE: ${{ matrix.triple_cpu }}-${{ matrix.triple_suffix }}
LLVM_CONFIG: llvm-${{ matrix.triple_cpu }}-${{ matrix.triple_suffix }}-release
steps:
- uses: actions/download-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0/bin
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ inputs.llvm_version }}
path: ${{ github.workspace }}/SourceCache/llvm-project
show-progress: false
- uses: actions/checkout@v4
with:
path: ${{ github.workspace }}/SourceCache/llvm-build
show-progress: false
- name: Install Python ${{ env.PYTHON_VERSION }} (Host)
uses: actions/setup-python@v5
id: python
with:
python-version: '${{ env.PYTHON_VERSION }}'
- name: Export Host Python Location
run: echo "TARGET_PYTHON_LOCATION=${{ env.pythonLocation }}" ${{ matrix.into_environment }}
# TODO(lxbndr) use actions/cache to improve this step timings
- name: Install Python ${{ env.PYTHON_VERSION }} (arm64)
if: ${{ matrix.arch == 'arm64' && matrix.os == 'windows-latest' }}
run: |
nuget install pythonarm64 -Version ${{ env.PYTHON_VERSION }}
echo "TARGET_PYTHON_LOCATION=${{ github.workspace }}/pythonarm64.${{ env.PYTHON_VERSION }}/tools" ${{ matrix.into_environment }}
- name: Setup sccache
uses: compnerd/[email protected]
with:
max-size: 500M
key: sccache-${{ matrix.os }}-${{ matrix.arch }}-distribution
variant: sccache
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: Fetch Python CMake Build System
if: ${{ matrix.arch == 'arm64' && matrix.os != 'windows-latest' && false }}
uses: actions/checkout@v4
with:
repository: python-cmake-buildsystem/python-cmake-buildsystem
ref: master
path: ${{ github.workspace }}/SourceCache/python-cmake-buildsystem
show-progress: false
- name: Build/Install Python ${{ env.PYTHON_VERSION }} (arm64)
if: ${{ matrix.arch == 'arm64' && matrix.os != 'windows-latest' && false }}
run: >-
cmake -GNinja ${{ matrix.cmake_system_name }} ${{ matrix.cmake_system_processor }}
-S ${{ github.workspace }}/SourceCache/python-cmake-buildsystem
-B ${{ github.workspace }}/BinaryCache/python
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_C_COMPILER=clang
-D CMAKE_CXX_COMPILER=clang++
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/python-${{ env.PYTHON_VERSION }}-${{ env.TARGET_TRIPLE }}
-D CMAKE_BUILD_TYPE=Release
cmake --build ${{ github.workspace }}/BinaryCache/python --target install
echo "PYTHON_LOCATION_arm64=${{ github.workspace }}/BuildRoot/python-${{ env.PYTHON_VERSION }}-${{ env.TARGET_TRIPLE }}/tools"
${{ matrix.into_environment }}
- uses: compnerd/gha-setup-vsdevenv@main
if: matrix.os == 'windows-latest'
with:
host_arch: amd64
toolset_version: 14.37.32822
components: 'Microsoft.VisualStudio.Component.VC.14.37.17.7.x86.x64;Microsoft.VisualStudio.Component.VC.14.37.17.7.ARM64'
arch: ${{ matrix.arch }}
- name: Workaround MSVC#10444970
if: ${{ matrix.arch == 'arm64' && matrix.os == 'windows-latest' }}
run: |
$clangTooling = "${{ github.workspace }}/SourceCache/llvm-project/clang/lib/Tooling/Inclusions/Stdlib/CMakeLists.txt"
Set-Content $clangTooling @"
$(Get-Content -Raw $clangTooling)
set_source_files_properties(StandardLibrary.cpp PROPERTIES
COMPILE_FLAGS "/Od /Gw /Oi /Oy /Gw /Ob2 /Ot /GF")
"@
$clangCodeGen = "${{ github.workspace }}/SourceCache/llvm-project/clang/lib/CodeGen/CMakeLists.txt"
Set-Content $clangCodeGen @"
$(Get-Content -Raw $clangCodeGen)
set_source_files_properties(CGBuiltin.cpp PROPERTIES
COMPILE_FLAGS "/Od /Gw /Oi /Oy /Gw /Ob2 /Ot /GF")
"@
- name: Configure LLVM
run: >-
cmake -GNinja ${{ matrix.cmake_system_name }} ${{ matrix.cmake_system_processor }} ${{ matrix.lldb_enable_libxml2 }}
-B ${{ github.workspace }}/BinaryCache/1
-C ${{ github.workspace }}/SourceCache/llvm-build/cmake/caches/LLVM.cmake
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }}
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D CMAKE_MT=mt
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/${{ env.LLVM_CONFIG }}
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm
-D CLANG_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/clang-tblgen${{ matrix.executable_suffix }}
-D CLANG_TIDY_CONFUSABLE_CHARS_GEN=${{ github.workspace }}/BinaryCache/0/bin/clang-tidy-confusable-chars-gen${{ matrix.executable_suffix }}
-D LLDB_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/lldb-tblgen${{ matrix.executable_suffix }}
-D LLVM_CONFIG_PATH=${{ github.workspace }}/BinaryCache/0/bin/llvm-config${{ matrix.executable_suffix }}
-D LLVM_NATIVE_TOOL_DIR=${{ github.workspace }}/BinaryCache/0/bin
-D LLVM_TABLEGEN=${{ github.workspace }}/BinaryCache/0/bin/llvm-tblgen${{ matrix.executable_suffix }}
-D LLVM_USE_HOST_TOOLS=NO
-D CLANG_VENDOR=hylo-lang.org
-D CLANG_VENDOR_UTI=org.hylo-lang.dt
-D PACKAGE_VENDOR=hylo-lang.org
-D LLVM_DEFAULT_TARGET_TRIPLE=${{ env.TARGET_TRIPLE }}
-D LLVM_ENABLE_PROJECTS="${{ matrix.llvm_enable_projects }}"
-D LLVM_PARALLEL_LINK_JOBS=2
-D LLVM_APPEND_VC_REV=NO
-D LLVM_VERSION_SUFFIX=""
-D LLDB_PYTHON_EXE_RELATIVE_PATH=python${{ matrix.executable_suffix }}
-D LLDB_PYTHON_EXT_SUFFIX=.pyd
-D LLDB_PYTHON_RELATIVE_PATH=lib/site-packages
-D Python3_EXECUTABLE=${{ steps.python.outputs.python-path }}
-D Python3_INCLUDE_DIR=${{ env.TARGET_PYTHON_LOCATION }}/include
-D Python3_LIBRARY=${{ env.TARGET_PYTHON_LOCATION }}/libs/python39.lib
-D Python3_ROOT_DIR=${{ env.pythonLocation }}
- name: Build LLVM
run: cmake --build ${{ github.workspace }}/BinaryCache/1
- name: Install LLVM
run: cmake --build ${{ github.workspace }}/BinaryCache/1 --target install
- name: Upload LLVM
uses: actions/upload-artifact@v4
with:
name: distribution-${{ matrix.arch }}
path: ${{ github.workspace }}/BuildRoot/
- name: Package LLVM
run: |
7z a -t7z ${{ env.LLVM_CONFIG }}.7z ${{ github.workspace }}\BuildRoot\${{ env.LLVM_CONFIG }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ env.LLVM_CONFIG }}.7z
# TODO(compnerd) this takes ~1h due to the size, see if we can compress first
- uses: actions/upload-artifact@v4
if: false # ${{ inputs.debug_info }}
with:
name: distribution-${{ matrix.arch }}-debug-info
path: |
${{ github.workspace }}/BinaryCache/1/**/*.pdb
- uses: microsoft/[email protected]
if: ${{ inputs.debug_info }}
with:
accountName: ${{ vars.SYMBOL_SERVER_ACCOUNT }}
personalAccessToken: ${{ secrets.SYMBOL_SERVER_PAT }}
symbolsFolder: ${{ github.workspace }}/BinaryCache/1