Skip to content

Verbose build to get some insight into Windows Debug failures. #135

Verbose build to get some insight into Windows Debug failures.

Verbose build to get some insight into Windows Debug failures. #135

Workflow file for this run

name: build-llvm-binaries
on:
push:
branches: [ main ]
paths-ignore:
- "**.md"
- "LICENSE"
- ".gitignore"
workflow_dispatch:
inputs:
llvm_version:
description: 'LLVM Version'
default: '17.0.6'
required: false
type: string
env:
SCCACHE_DIRECT: yes
llvm_version: ${{ github.event.inputs.llvm_version || '17.0.6' }}
jobs:
create_tag:
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.timestamp.outputs.time }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: Capture time
uses: Kaven-Universe/github-action-current-date-time@v1
id: timestamp
with:
format: "YYYYMMDD-HHmmss"
- name: Create the tag.
uses: EndBug/latest-tag@latest
with:
ref: ${{ steps.timestamp.outputs.time }}
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
- os: windows-latest
c_compiler: cl
cxx_compiler: cl
executable_suffix: .exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ env.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]
id: sccache
with:
max-size: 100M
key: ${{ matrix.os }}-build_tools
variant: sccache
append-timestamp: false
- name: Configure Tools
run: >-
cmake -B ${{ github.workspace }}/BinaryCache/0
-D CMAKE_BUILD_TYPE=MinSizeRel
-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=""
- name: Build tools
run: >-
cmake --build ${{ github.workspace }}/BinaryCache/0
--target llvm-tblgen
--target llvm-config
- name: Archive tools
run: tar cf tools.tar bin
working-directory: ${{ github.workspace }}/BinaryCache/0
- uses: actions/upload-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0/tools.tar
- name: Clear old sccache
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete sccache-${{ matrix.os }}-build_tools- --confirm -R ${{ github.repository }}
continue-on-error: true
distribution:
needs: [build_tools, create_tag]
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
arch: [x86_64, arm64]
configuration: [Debug, MinSizeRel]
include:
# Default values
- c_compiler: clang
- cmake_c_cxx_flags_option:
- cmake_find_root_path_option:
- cmake_system_processor_option:
- compile_cache_max_size: 1G
- cxx_compiler: clang++
- executable_suffix:
- into_environment: '>> $GITHUB_ENV'
- llvm_target_arch_option:
- package_command: tar --zstd -cf
- package_suffix: .tar.zst
- static_lib_suffix: .a
- toolset_suffix:
- triple_cpu:
- install_target: install-distribution-stripped
- llvm_distribution_tools: addr2line;ar;c++filt;dsymutil;dwp;lld;llvm-ar;llvm-config;llvm-cov;llvm-cvtres;llvm-cxxfilt;llvm-dlltool;llvm-dwarfdump;llvm-dwp;llvm-lib;llvm-lipo;llvm-mt;llvm-nm;llvm-objcopy;llvm-objdump;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-size;llvm-strings;llvm-strip;llvm-symbolizer;llvm-undname;nm;objcopy;objdump;ranlib;readelf;size;strings
- zstd_root_option:
# Overrides
- configuration: Debug
compile_cache_max_size: 2G
install_target: install-distribution
llvm_distribution_tools: lld;llvm-config
- os: windows-latest
c_compiler: cl
# Swift's runtime is compiled this way, and can't be
# linked to a C++ binary other settings.
cmake_c_cxx_flags_option: >-
-D "CMAKE_CXX_FLAGS=-D_ITERATOR_DEBUG_LEVEL=0 /MD"
-D "CMAKE_C_FLAGS=/MD"
cxx_compiler: cl
executable_suffix: .exe
into_environment: '| Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append'
package_command: 7z a -t7z
package_suffix: .7z
static_lib_suffix: .lib
toolset_suffix: -msvc17
- arch: x86_64
triple_cpu: x86_64
- arch: arm64
cmake_find_root_path_option: >-
-D CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
-D CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
-D CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
-D CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
cmake_system_processor_option: -D CMAKE_SYSTEM_PROCESSOR=arm64
llvm_target_arch_option: -D LLVM_TARGET_ARCH=arm64
triple_cpu: arm64
- arch: arm64
os: ubuntu-latest
cmake_system_processor_option: -D CMAKE_SYSTEM_PROCESSOR=aarch64
c_compiler: aarch64-linux-gnu-gcc
cxx_compiler: aarch64-linux-gnu-g++
triple_cpu: aarch64
- arch: arm64
os: macos-latest
zstd_root_option: -D zstd_ROOT=/opt/local
# Extensions
- arch: arm64
llvm_backend_libs: 'LLVMAArch64AsmParser;LLVMAArch64CodeGen;LLVMAArch64Desc;LLVMAArch64Disassembler;LLVMAArch64Info;LLVMAArch64Utils'
- arch: x86_64
llvm_backend_libs: 'LLVMX86AsmParser;LLVMX86CodeGen;LLVMX86Desc;LLVMX86Disassembler;LLVMX86Info;LLVMX86TargetMCA'
- os: windows-latest
cmake_system_name: Windows
triple_suffix: unknown-windows-msvc17
- os: ubuntu-latest
cmake_system_name: Linux
triple_suffix: unknown-linux-gnu
- os: macos-latest
cmake_system_name: Darwin
triple_suffix: apple-darwin23.3.0
runs-on: ${{ matrix.os }}
env:
cmake_c_compiler_target_option: ${{ matrix.arch != 'x86_64' && format('-D CMAKE_C_COMPILER_TARGET={0}-{1}', matrix.triple_cpu, matrix.triple_suffix) || '' }}
cmake_cxx_compiler_target_option: ${{ matrix.arch != 'x86_64' && format('-D CMAKE_CXX_COMPILER_TARGET={0}-{1}', matrix.triple_cpu, matrix.triple_suffix) || '' }}
cmake_system_name_option: ${{ matrix.arch != 'x86_64' && format('-D CMAKE_SYSTEM_NAME={0}', matrix.cmake_system_name) || '' }}
llvm_host_triple_option: ${{ matrix.arch != 'x86_64' && format('-D LLVM_HOST_TRIPLE={0}-{1}', matrix.triple_cpu, matrix.triple_suffix) || '' }}
PACKAGE_NAME: llvm-${{ github.event.inputs.llvm_version || '17.0.6' }}-${{ matrix.triple_cpu }}-${{ matrix.triple_suffix }}-${{ matrix.configuration }}
steps:
# https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
- name: Free up disk space for debug builds
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/download-artifact@v4
with:
name: build-tools-${{ matrix.os }}
path: ${{ github.workspace }}/BinaryCache/0
- name: Extract tools
run: tar xf tools.tar
working-directory: ${{ github.workspace }}/BinaryCache/0
- name: Clean up artifact
run: ${{ matrix.os == 'windows-latest' && 'Remove-Item' || 'rm' }} tools.tar
working-directory: ${{ github.workspace }}/BinaryCache/0
- uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: llvmorg-${{ env.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: Patch LLVM
run: git apply ${{ github.workspace }}/SourceCache/llvm-build/llvm.patch
working-directory: ${{ github.workspace }}/SourceCache/llvm-project
- uses: seanmiddleditch/gha-setup-ninja@master
with:
version: 1.11.1
- name: Setup sccache
id: sccache
uses: compnerd/[email protected]
with:
max-size: ${{ matrix.compile_cache_max_size }}
key: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-package
variant: sccache
append-timestamp: false
- uses: compnerd/gha-setup-vsdevenv@main
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 == 'arm64' && 'arm64' || 'amd64' }}
- 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: Native prerequisites (macOS)
if: ${{ matrix.os == 'macos-latest' && matrix.arch == 'x86_64' }}
run: brew install zstd
- name: Cross-build prerequisites (macOS)
if: ${{ matrix.os == 'macos-latest' && matrix.arch != 'x86_64' }}
uses: melusina-org/setup-macports@v1
with:
parameters: ${{ github.workspace }}/SourceCache/llvm-build/.github/parameters/setup-macports.yaml
- name: Cross-build prerequisites (ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.arch != 'x86_64' }}
run: |
sudo dpkg --add-architecture arm64
# See answer #4 at https://answers.launchpad.net/ubuntu/+source/apt/+question/661407
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -E \
-e 's#^deb[[:space:]]+([^[:space:]]+)[[:space:]]+(.*)#deb [arch=amd64,i386] \1 \2\ndeb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ \2#g' \
-e 's/^# deb-src /deb-src /' \
-e 'w /etc/apt/sources.list' \
/etc/apt/sources.list.bak
sudo apt-get update
sudo apt-get build-dep -a arm64 llvm
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Configure LLVM
run: >-
cmake -GNinja
-D CMAKE_BUILD_TYPE=${{ matrix.configuration }}
-S ${{ github.workspace }}/SourceCache/llvm-project/llvm
-B ${{ github.workspace }}/BinaryCache/1
-C ${{ github.workspace }}/SourceCache/llvm-build/cmake/caches/LLVM.cmake
-D CMAKE_C_COMPILER=${{ matrix.c_compiler }}
-D CMAKE_C_COMPILER_LAUNCHER=sccache
${{ env.cmake_c_compiler_target_option }}
-D CMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }}
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
${{ env.cmake_cxx_compiler_target_option }}
${{ matrix.cmake_find_root_path_option }}
-D CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
-D CMAKE_MT=mt
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/${{ env.PACKAGE_NAME }}
${{ env.cmake_system_name_option }}
${{ matrix.cmake_c_cxx_flags_option }}
${{ matrix.cmake_system_processor_option }}
-D LLVM_DISTRIBUTION_COMPONENTS="${{ matrix.llvm_backend_libs }};LLVMAggressiveInstCombine;LLVMAnalysis;LLVMAsmParser;LLVMAsmPrinter;LLVMBinaryFormat;LLVMBitReader;LLVMBitWriter;LLVMBitstreamReader;LLVMCFGuard;LLVMCodeGen;LLVMCodeGenTypes;LLVMCore;LLVMCoroutines;LLVMDebugInfoBTF;LLVMDebugInfoCodeView;LLVMDebugInfoDWARF;LLVMDebugInfoMSF;LLVMDebugInfoPDB;LLVMDemangle;LLVMFrontendOpenMP;LLVMGlobalISel;LLVMIRPrinter;LLVMIRReader;LLVMInstCombine;LLVMInstrumentation;LLVMLinker;LLVMMC;LLVMMCA;LLVMMCDisassembler;LLVMMCParser;LLVMObjCARCOpts;LLVMObject;LLVMPasses;LLVMProfileData;LLVMRemarks;LLVMScalarOpts;LLVMSelectionDAG;LLVMSupport;LLVMSymbolize;LLVMTarget;LLVMTargetParser;LLVMTextAPI;LLVMTransformUtils;LLVMVectorize;LLVMipo;llvm-headers;cmake-exports;lld-cmake-exports;${{ matrix.llvm_distribution_tools }}"
-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 PACKAGE_VENDOR=hylo-lang.org
-D LLVM_APPEND_VC_REV=NO
-D LLVM_ENABLE_PROJECTS="lld"
${{ env.llvm_host_triple_option }}
-D LLVM_PARALLEL_LINK_JOBS=2
${{ matrix.llvm_target_arch_option }}
-D LLVM_VERSION_SUFFIX=""
${{ matrix.zstd_root_option }}
- name: Build LLVM
run: cmake --build ${{ matrix.os == 'windows-latest' && matrix.configuration == 'Debug' && '--verbose' || '' }} ${{ github.workspace }}/BinaryCache/1 --target distribution
- name: Reclaim disk space
if: ${{ matrix.os != 'windows-latest' }}
run: find ${{ github.workspace }}/BinaryCache/ -name '*.o' -print0 | xargs -0 rm
- name: Install LLVM
run: cmake --build ${{ github.workspace }}/BinaryCache/1 --target ${{ matrix.install_target }}
- name: Package LLVM
working-directory: ${{ github.workspace }}/BuildRoot/
run: >-
${{ matrix.package_command }} ${{ github.workspace }}/${{ env.PACKAGE_NAME }}${{ matrix.package_suffix }} ${{ env.PACKAGE_NAME }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PACKAGE_NAME }}${{ matrix.package_suffix }}
tag_name: ${{ needs.create_tag.outputs.tag_name }}
- name: Clear old sccache
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete sccache-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.configuration }}-package- --confirm -R ${{ github.repository }}
continue-on-error: true