Skip to content

Build LLVM toolchain #34

Build LLVM toolchain

Build LLVM toolchain #34

Workflow file for this run

name: Build LLVM toolchain
on:
workflow_dispatch:
inputs:
llvm_tag:
required: true
jobs:
build_linux_x64:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt update && sudo apt install -yqq python3 git ninja-build cmake zstd
- name: Install ARM toolchain
run: sudo apt install -yqq gcc-arm-linux-gnueabi g++-arm-linux-gnueabi binutils-arm-linux-gnueabi
- name: Install AArch64 toolchain
run: sudo apt install -yqq gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Install RISC-V toolchain
run: sudo apt install -yqq gcc-riscv64-linux-gnu g++-riscv64-linux-gnu binutils-riscv64-linux-gnu
- name: Checkout code
uses: actions/checkout@v4
with:
repository: "llvm/llvm-project"
ref: ${{ inputs.llvm_tag }}
- name: Build and install
env:
CXXFLAGS: -w
CFLAGS: -w
run: |
export RT_TARGETS="x86_64-unknown-linux-gnu;aarch64-unknown-linux-gnu;riscv64-unknown-linux-gnu"
export TOOLS="dsymutil;llvm-ar;llvm-cxxfilt;llvm-cov;llvm-dwarfdump;llvm-nm;llvm-objdump;llvm-objcopy;llvm-profdata;llvm-ranlib;llvm-readobj;llvm-strip;llvm-size;llvm-symbolizer"
export COMPONENTS="clang;clang-format;clang-tidy;clang-resource-headers;bolt;runtimes;lld"
# FIXME: enable bolt once more powerful runners are available
# -DCLANG_BOLT_INSTRUMENT=ON -DCMAKE_EXE_LINKER_FLAGS="-Wl,--emit-relocs,-znow"
mkdir build && cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_LLD=OFF \
-DLLVM_TARGETS_TO_BUILD="X86;AArch64;NVPTX;AMDGPU;RISCV" \
-DLLVM_RUNTIME_TARGETS="$RT_TARGETS" \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_ENABLE_LTO=OFF \
-DLLVM_ENABLE_RUNTIMES="libunwind;compiler-rt;libcxx;libcxxabi;openmp" \
-DLLVM_ENABLE_PROJECTS="bolt;clang;clang-tools-extra;lld;pstl" \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
-DCMAKE_INSTALL_PREFIX=$PWD/install/${{ inputs.llvm_tag }}-linux-x86_64 \
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \
-DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=ON \
-DRUNTIMES_x86_64-unknown-linux-gnu_OPENMP_LIBDIR_SUFFIX="/x86_64-unknown-linux-gnu" -DRUNTIMES_x86_64-unknown-linux-gnu_OPENMP_STANDALONE_BUILD=ON \
-DRUNTIMES_aarch64-unknown-linux-gnu_OPENMP_LIBDIR_SUFFIX="/aarch64-unknown-linux-gnu" -DRUNTIMES_aarch64-unknown-linux-gnu_OPENMP_STANDALONE_BUILD=ON \
-DRUNTIMES_riscv64-unknown-linux-gnu_OPENMP_LIBDIR_SUFFIX="/riscv64-unknown-linux-gnu" -DRUNTIMES_riscv64-unknown-linux-gnu_OPENMP_STANDALONE_BUILD=ON \
-DRUNTIMES_x86_64-unknown-linux-gnu_OPENMP_LLVM_TOOLS_DIR="$PWD/bin" \
-DRUNTIMES_aarch64-unknown-linux-gnu_OPENMP_LLVM_TOOLS_DIR="$PWD/bin" \
-DRUNTIMES_aarch64-unknown-linux-gnu_OPENMP_ENABLE_LIBOMPTARGET=OFF \
-DRUNTIMES_aarch64-unknown-linux-gnu_LIBOMP_OMPD_GDB_SUPPORT=OFF \
-DRUNTIMES_riscv64-unknown-linux-gnu_OPENMP_LLVM_TOOLS_DIR="$PWD/bin" \
-DRUNTIMES_riscv64-unknown-linux-gnu_LIBOMP_OMPD_GDB_SUPPORT=OFF \
-DRUNTIMES_riscv64-unknown-linux-gnu_OPENMP_ENABLE_LIBOMPTARGET=OFF \
-DLLVM_TOOLCHAIN_TOOLS="$TOOLS" -DLLVM_DISTRIBUTION_COMPONENTS="$COMPONENTS;$TOOLS" \
../llvm
# FIXME: this requires too much RAM
# ninja clang-bolt
ninja install-distribution-stripped
ninja llvm-dwp
ninja install-pstl
cp ./bin/llvm-dwp ./install/${{inputs.llvm_tag}}-linux-x86_64/bin
cd install
tar --zstd -cf ${{ inputs.llvm_tag }}-linux-x86_64.tar.zst ${{ inputs.llvm_tag }}-linux-x86_64
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: build/install/${{ inputs.llvm_tag }}-linux-x86_64.tar.zst
name: linux-x86_64-toolchain
build_macos_x64:
runs-on: macos-13
steps:
- name: Install dependencies
run: brew install ninja zstd gnu-tar
- name: Checkout code
uses: actions/checkout@v4
with:
repository: "llvm/llvm-project"
ref: ${{ inputs.llvm_tag }}
- name: Build and install
env:
CXXFLAGS: -w
CFLAGS: -w
run: |
export RT_TARGETS="x86_64-apple-darwin"
export TOOLS="dsymutil;llvm-ar;llvm-cxxfilt;llvm-cov;llvm-dwarfdump;llvm-nm;llvm-objdump;llvm-objcopy;llvm-profdata;llvm-ranlib;llvm-readobj;llvm-strip;llvm-size;llvm-symbolizer"
export COMPONENTS="clang;clang-format;clang-tidy;clang-resource-headers;bolt;runtimes;lld"
# FIXME: enable bolt once more powerful runners are available
# -DCLANG_BOLT_INSTRUMENT=ON -DCMAKE_EXE_LINKER_FLAGS="-Wl,--emit-relocs,-znow"
mkdir build && cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_LLD=OFF \
-DLLVM_TARGETS_TO_BUILD="X86;AArch64" \
-DLLVM_RUNTIME_TARGETS="$RT_TARGETS" \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_LTO=ON \
-DLLVM_ENABLE_RUNTIMES="libunwind;compiler-rt;libcxx;libcxxabi;openmp" \
-DLLVM_ENABLE_PROJECTS="bolt;clang;clang-tools-extra;lld;pstl" \
-DLLVM_STATIC_LINK_CXX_STDLIB=ON -DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
-DCMAKE_INSTALL_PREFIX=$PWD/install/${{ inputs.llvm_tag }}-macos-x86_64 \
-DLIBCXX_HERMETIC_STATIC_LIBRARY=ON \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \
-DLIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY=ON \
-DRUNTIMES_x86_64-apple-darwin_OPENMP_LIBDIR_SUFFIX="/x86_64-apple-darwin" -DRUNTIMES_x86_64-apple-darwin_OPENMP_STANDALONE_BUILD=ON \
-DRUNTIMES_aarch64-apple-darwin_OPENMP_LIBDIR_SUFFIX="/aarch64-apple-darwin" -DRUNTIMES_aarch64-apple-darwin_OPENMP_STANDALONE_BUILD=ON \
-DRUNTIMES_x86_64-apple-darwin_OPENMP_LLVM_TOOLS_DIR="$PWD/bin" \
-DRUNTIMES_x86_64-apple-darwin_OPENMP_ENABLE_LIBOMPTARGET=OFF \
-DRUNTIMES_aarch64-apple-darwin_OPENMP_LLVM_TOOLS_DIR="$PWD/bin" \
-DRUNTIMES_aarch64-apple-darwin_OPENMP_ENABLE_LIBOMPTARGET=OFF \
-DRUNTIMES_aarch64-apple-darwin_LIBOMP_OMPD_GDB_SUPPORT=OFF \
-DLLVM_TOOLCHAIN_TOOLS="$TOOLS" -DLLVM_DISTRIBUTION_COMPONENTS="$COMPONENTS;$TOOLS" \
-DRUNTIMES_BUILD_ALLOW_DARWIN=ON \
-DRUNTIMES_x86_64-apple-darwin_BUILD_ALLOW_DARWIN=ON \
-DRUNTIMES_aarch64-apple-darwin_BUILD_ALLOW_DARWIN=ON \
../llvm
# FIXME: this requires too much RAM
# ninja clang-bolt
ninja install-distribution-stripped
ninja llvm-dwp
ninja install-pstl
cp ./bin/llvm-dwp ./install/${{inputs.llvm_tag}}-macos-x86_64/bin
cp ./lib/libclang*.dylib ./install/${{inputs.llvm_tag}}-macos-x86_64/lib || true
cp ./lib/libLLVM*.dylib ./install/${{inputs.llvm_tag}}-macos-x86_64/lib || true
cd install
tar --zstd -cf ${{ inputs.llvm_tag }}-macos-x86_64.tar.zst ${{ inputs.llvm_tag }}-macos-x86_64
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: build/install/${{ inputs.llvm_tag }}-macos-x86_64.tar.zst
name: macos-x86_64-toolchain
publish_release:
needs: ["build_linux_x64", "build_macos_x64"]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Collect sha256 checksums
run: |
touch RELASE.txt
sha256sum linux-x86_64-toolchain/${{ inputs.llvm_tag }}-linux-x86_64.tar.zst >> RELEASE.txt
sha256sum macos-x86_64-toolchain/${{ inputs.llvm_tag }}-macos-x86_64.tar.zst >> RELEASE.txt
- name: Create release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.RELEASE_TOKEN }}
body_path: RELEASE.txt
tag_name: ${{ inputs.llvm_tag }}-${{ github.sha }}
name: LLVM Toolchain ${{ inputs.llvm_tag }}
prerelease: true
files: |
linux-x86_64-toolchain/${{ inputs.llvm_tag }}-linux-x86_64.tar.zst
macos-x86_64-toolchain/${{ inputs.llvm_tag }}-macos-x86_64.tar.zst