Skip to content

WIP: Enable Windows static builds #47

WIP: Enable Windows static builds

WIP: Enable Windows static builds #47

Workflow file for this run

name: Build Release

Check failure on line 1 in .github/workflows/build-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-release.yml

Invalid workflow file

(Line: 190, Col: 11): Unexpected value 'LLVM_VERSION=22.1.8'
on:
workflow_dispatch:
jobs:
create-release:
runs-on: ubuntu-slim
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# fetch full history + tags
fetch-depth: 0
- name: Get version
id: get-version
run: |
VERSION=$(ci/git_version.sh | xargs)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.get-version.outputs.version }}
run: |
gh release create ${VERSION} \
--draft \
--title "mrbind ${VERSION}"
build-linux:
needs:
- create-release
runs-on: ${{ matrix.runner }}
container:
image: almalinux:8
strategy:
fail-fast: false
matrix:
arch: [x64, arm64]
include:
- arch: x64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- name: Install tools
run: |
dnf install -y epel-release
dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
dnf install -y --enablerepo powertools \
gcc-toolset-14 cmake ninja-build \
$(: CI requirements ) \
git gh unzip zip \
$(: test requirements ) \
gcc-c++ findutils python38-devel
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Fix git permissions
run: |
git config --global --add safe.directory '*'
- name: Download and unpack LLVM
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download llvm-22.1.8 --pattern "llvm-linux-$(uname -m).zip"
unzip "llvm-linux-$(uname -m).zip"
rm "llvm-linux-$(uname -m).zip"
- name: Build
run: |
source /opt/rh/gcc-toolset-14/enable
cmake -B build -G Ninja \
-D Clang_DIR=llvm/lib/cmake/clang \
-D CMAKE_BUILD_TYPE=Release \
-D MRBIND_STATIC_BUILD=ON \
-D CMAKE_CXX_FLAGS="-ffunction-sections -fdata-sections" \
-D CMAKE_EXE_LINKER_FLAGS="-Wl,--gc-sections -Wl,-s"
cmake --build build --parallel $(nproc)
- name: Verify binaries
run: |
ls -l build/mrbind*
ldd build/mrbind*
- name: Test
run: |
export CLANG_RESOURCE_DIR="$(pwd)/llvm/lib/clang/22"
source /opt/rh/gcc-toolset-14/enable
echo g++ > examples/cxx.txt
examples/c/run.sh
PYTHON=python3.8 examples/python/run.sh
- name: Create package
run: |
mkdir mrbind
mv build/mrbind{,_gen_c,_gen_csharp} mrbind/
mv llvm/lib/clang/22 mrbind/resource-dir
zip -r mrbind-linux-$(uname -m).zip mrbind/
- name: Upload package
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.create-release.outputs.version }}
run: |
gh release upload ${VERSION} mrbind-linux-$(uname -m).zip --clobber
build-macos:
needs:
- create-release
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
arch: [arm64, x64]
include:
- arch: arm64
runner: macos-15
- arch: x64
runner: macos-15-intel
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Build
run: |
export PATH="$(brew --prefix llvm@18)/bin:$PATH"
cmake -B build -G Ninja \
-D Clang_DIR=$(brew --prefix llvm@18)/lib/cmake/clang \
-D CMAKE_BUILD_TYPE=Release \
-D MRBIND_STATIC_BUILD=ON \
-D MRBIND_FORCE_LLVM_STATIC=ON \
-D CMAKE_PREFIX_PATH=$(brew --prefix zstd) \
-D CMAKE_OSX_DEPLOYMENT_TARGET=12.0
cmake --build build --parallel $(sysctl -n hw.logicalcpu)
- name: Verify build
run: |
ls -l build/mrbind*
otool -L build/mrbind*
ls -1 build/mrbind* | xargs -n1 vtool -show-build
- name: Test
run: |
export CLANG_RESOURCE_DIR=$(brew --prefix llvm@18)/lib/clang/18
echo clang++ > examples/cxx.txt
examples/c/run.sh
PYTHON=python3.11 examples/python/run.sh
- name: Create package
run: |
mkdir mrbind
mv build/mrbind{,_gen_c,_gen_csharp} mrbind/
cp -R $(brew --prefix llvm@18)/lib/clang/18 mrbind/resource-dir
zip -r mrbind-macos-$(uname -m).zip mrbind/
- name: Upload package
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.create-release.outputs.version }}
run: |
gh release upload ${VERSION} mrbind-macos-$(uname -m).zip --clobber
build-windows:
needs:
- create-release
runs-on: windows-2025
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Download and unpack LLVM
env:
LLVM_VERSION=22.1.8
run: |
curl.exe -fLO "https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-pc-windows-msvc.tar.xz"
tar -xf "clang+llvm-$LLVM_VERSION-x86_64-pc-windows-msvc.tar.xz"
mv "clang+llvm-$LLVM_VERSION-x86_64-pc-windows-msvc" C:\clang+llvm
echo "C:\clang+llvm\bin" >> $env:GITHUB_PATH
- name: Patch LLVM
if: false
shell: bash
run: |
# more info: https://github.com/jklappenbach/cajeta/commit/17811cfd922f0715c68eb3459cd153760bc890f8
expected="C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK/lib/amd64/diaguids.lib"
actual="C:/Program Files/Microsoft Visual Studio/18/Enterprise/DIA SDK/lib/amd64/diaguids.lib"
sed -i "s|${expected}|${actual}|" C:/clang+llvm/lib/cmake/llvm/LLVMExports.cmake
- name: Build
run: |
cmake -B build -G Ninja `
-D Clang_DIR=C:\clang+llvm\lib\cmake\clang `
-D CMAKE_BUILD_TYPE=Release `
-D MRBIND_STATIC_BUILD=ON `
-D CMAKE_C_COMPILER=clang `
-D CMAKE_CXX_COMPILER=clang++ `
-D CMAKE_RC_COMPILER=llvm-rc
cmake --build build --parallel $env:NUMBER_OF_PROCESSORS
- name: Verify build
run: |
ls build\mrbind*.exe
llvm-readobj --needed-libs build\mrbind*.exe