Skip to content

[0.0.23] Upgrade LLVM to 19.1.4 #202

[0.0.23] Upgrade LLVM to 19.1.4

[0.0.23] Upgrade LLVM to 19.1.4 #202

Workflow file for this run

name: Build RG3
on:
push:
branches:
- main
- dev/*
tags:
- "*"
jobs:
build_rg3:
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- {
name: "Windows MSVC",
os: windows-2022,
os_id: "windows",
cc: "cl",
cxx: "cl",
boost_toolset: msvc,
cmake_generator: "Visual Studio 17 2022",
llvm_tag: "llvmorg-19.1.4",
python_version: "3.10",
os_version: "2022",
artifact_id: "RG3_Windows"
}
- {
name: "Ubuntu Linux",
os: ubuntu-24.04,
os_id: "linux",
cc: "gcc-13",
cxx: "g++-13",
boost_toolset: gcc,
cmake_generator: "Ninja",
llvm_tag: "llvmorg-19.1.4",
python_version: "3.10",
os_version: "24.04",
artifact_id: "RG3_Linux"
}
- {
name: "macOS",
os: macos-13,
os_id: "macos",
cc: "clang",
cxx: "clang++",
boost_toolset: gcc,
cmake_generator: "Ninja",
llvm_tag: "llvmorg-19.1.4",
python_version: "3.10",
os_version: "13",
artifact_id: "RG3_macOS"
}
steps:
# Download repository with submodules
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
# Setup msbuild
- name: Add msbuild to PATH (Windows only)
if: matrix.config.os_id == 'windows'
uses: microsoft/[email protected]
with:
msbuild-architecture: x64
# Setup Ninja
- name: Setup Ninja (Linux)
if: matrix.config.os_id == 'linux'
run: |
sudo apt-get install -y ninja-build gcc-13 g++-13 libboost-all-dev
# Setup Python of specific version
- name: Install Python
if: matrix.config.os_id != 'macos'
id: install-python3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.python_version }}
- name: Setup PyENV and other tools (macOS)
if: matrix.config.os_id == 'macos'
env:
HOMEBREW_NO_AUTO_UPDATE: 1
run: |
brew install pyenv
brew install ninja
pyenv install 3.10-dev -s
echo "Python3_ROOT_DIR=$HOME/.pyenv/versions/3.10-dev" >> $GITHUB_ENV
# ---------------
# Boost
# ---------------
- name: Cache Boost binaries
id: cache-boost-binaries
uses: actions/cache@v3
with:
key: ${{ runner.os }}-boost_1_81_0
path: boost_1_81_0
- name: Download and build Boost (Linux)
if: steps.cache-boost-binaries.outputs.cache-hit != 'true' && matrix.config.os_id == 'linux'
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz
tar xzf boost_1_81_0.tar.gz
cd boost_1_81_0
./bootstrap.sh --with-libraries=system,filesystem,python --with-python=$(which python3)
./b2 link=static variant=release cxxflags=-fPIC cflags=-fPIC
- name: Download and build Boost (Windows)
if: steps.cache-boost-binaries.outputs.cache-hit != 'true' && matrix.config.os_id == 'windows'
run: |
Invoke-WebRequest -Uri "https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz" -OutFile "boost_1_81_0.tar.gz"
tar xzf boost_1_81_0.tar.gz
cd boost_1_81_0
.\bootstrap.bat --with-libraries=system,filesystem,python
.\b2 link=static variant=release
- name: Download and build Boost (macOS)
if: steps.cache-boost-binaries.outputs.cache-hit != 'true' && matrix.config.os_id == 'macos'
run: |
curl -L -O https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz
tar -xzf boost_1_81_0.tar.gz
cd boost_1_81_0
./bootstrap.sh --with-libraries=python,system,filesystem --with-python=$HOME/.pyenv/versions/3.10-dev/bin/python3 --with-python-version=3.10 --with-python-root=$HOME/.pyenv/versions/3.10-dev
./b2 link=static variant=release cxxflags=-fPIC cflags=-fPIC target-os=darwin architecture=arm+x86
# ---------------
# LLVM
# ---------------
- name: Cache LLVM binaries
id: cache-llvm-binaries
uses: actions/cache@v3
with:
key: "${{ runner.os }}-build-${{ matrix.config.llvm_tag }}"
path: |
llvm_repo/cmake
llvm_repo/build/cmake
llvm_repo/build/MinSizeRel
llvm_repo/build/include
llvm_repo/build/lib
llvm_repo/build/tools/clang/include
llvm_repo/llvm
llvm_repo/clang
# Checkout & Build LLVM (On cache miss - build from sources!)
- name: Checkout LLVM
if: steps.cache-llvm-binaries.outputs.cache-hit != 'true'
uses: actions/checkout@v3
with:
submodules: "recursive"
repository: "llvm/llvm-project"
ref: ${{ matrix.config.llvm_tag }}
path: "llvm_repo"
# Build LLVM
- name: Build LLVM
if: steps.cache-llvm-binaries.outputs.cache-hit != 'true'
working-directory: llvm_repo
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: |
mkdir build
cmake -DLLVM_ENABLE_PROJECTS="clang" -DCMAKE_BUILD_TYPE="MinSizeRel" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_ZSTD=OFF -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TOOLS=ON -DLLVM_TARGETS_TO_BUILD="host" -DLLVM_BUILD_32_BITS=OFF -DLLVM_ENABLE_BINDINGS=OFF -DLLVM_BUILD_DOCS=OFF -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -S llvm -B build -G "${{ matrix.config.cmake_generator }}"
cd build
cmake --build . --config MinSizeRel
# Save LLVM cache
- name: Save LLVM Cache
if: steps.cache-llvm-binaries.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
key: "${{ runner.os }}-build-${{ matrix.config.llvm_tag }}"
path: |
llvm_repo/cmake
llvm_repo/build/cmake
llvm_repo/build/MinSizeRel
llvm_repo/build/include
llvm_repo/build/lib
llvm_repo/build/tools/clang/include
llvm_repo/llvm
llvm_repo/clang
# Build our project
- name: Build RG3
env:
LLVM_DIR: ${{ github.workspace }}/llvm_repo/build/lib/cmake/llvm
CLANG_DIR: ${{ github.workspace }}/llvm_repo/build/lib/cmake/clang
Boost_ROOT: ${{ github.workspace }}/boost_1_81_0/stage/lib/cmake/Boost-1.81.0
Python3_USE_STATIC_LIBS: "TRUE"
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
run: |
mkdir build
cmake -DCMAKE_BUILD_TYPE="MinSizeRel" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -B build -G "${{ matrix.config.cmake_generator }}"
cd build
cmake --build . --config MinSizeRel
# Install Clang Latest (for testing env)
- name: Install Clang TestEnv (Windows, Linux)
if: matrix.config.os_id != 'macos'
uses: egor-tensin/setup-clang@v1
with:
version: latest
platform: x64
# Run Unit Tests
- name: RG3 Run unit tests
run: |
cd build
ctest . -C MinSizeRel --verbose --output-on-failure
# Run Python Unit Tests
- name: RG3 Run python unit tests (Windows)
if: matrix.config.os_id == 'windows'
run: |
cp PyBind/rg3py.pyd Tests/PyIntegration
cp PyBind/rg3py.pyi Tests/PyIntegration
cd Tests/PyIntegration
pip install pytest
pytest tests.py
# Run Python Unit Tests (Linux, macOS)
- name: RG3 Run python unit tests (Linux, macOS)
if: matrix.config.os_id == 'linux' || matrix.config.os_id == 'macos'
run: |
cp PyBind/rg3py.so Tests/PyIntegration
cp PyBind/rg3py.pyi Tests/PyIntegration
cd Tests/PyIntegration
pip install pytest
pytest tests.py
# Make dist folder with pyd & pyi files.
- name: Create distribution package (Windows)
if: matrix.config.os_id == 'windows'
run: |
mkdir dist
mv PyBind/rg3py.pyi dist
mv PyBind/rg3py.pyd dist
- name: Create distribution package (not Windows)
if: matrix.config.os_id != 'windows'
run: |
mkdir dist
mv PyBind/rg3py.pyi dist
mv PyBind/rg3py.so dist
# Upload artifacts
- name: Upload RG3 artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.artifact_id }}
path: dist
public_release_template:
name: Create release and public PyPI packages
needs: [build_rg3]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
# --------------------------------------------------------------------
# Create GitHub release
# --------------------------------------------------------------------
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Create release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: ${{ steps.get_version.outputs.VERSION }}
draft: true
prerelease: ${{ contains(github.ref, '-pre') }}
- name: Download all artifact
uses: actions/download-artifact@v4
- name: Package artifact for release
run: zip -r RG3_Release_v${{ steps.get_version.outputs.VERSION }}.zip *
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./RG3_Release_v${{ steps.get_version.outputs.VERSION }}.zip
asset_name: RG3_Release_v${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip
# --------------------------------------------------------------------
# Publish PyPI libs
# --------------------------------------------------------------------
# Clone whole project with all submodules
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
# Install any python 3.x to run Extensions/setup.pys
- name: Install Python
id: install-python3
uses: actions/setup-python@v5
with:
python-version: '3.x'
# Install build tools
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
# Download all available artifacts
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Build WHL for Linux
env:
RG3_DEPLOY_VERSION: ${{ steps.get_version.outputs.VERSION }}
RG3_DEPLOY_OS: 'linux'
run: |
mv RG3_Linux/rg3py.so Extension/rg3py
mv RG3_Linux/rg3py.pyi Extension/rg3py
cd Extension
python setup.py bdist_wheel --plat-name manylinux_2_28_x86_64
rm build/lib/rg3py/rg3py.so
rm build/lib/rg3py/rg3py.pyi
cd ..
rm Extension/rg3py/rg3py.so
rm Extension/rg3py/rg3py.pyi
- name: Build WHL for Windows
env:
RG3_DEPLOY_VERSION: ${{ steps.get_version.outputs.VERSION }}
RG3_DEPLOY_OS: 'windows'
run: |
mv RG3_Windows/rg3py.pyd Extension/rg3py
mv RG3_Windows/rg3py.pyi Extension/rg3py
cd Extension
python setup.py bdist_wheel --plat-name win_amd64
rm build/lib/rg3py/rg3py.pyd
rm build/lib/rg3py/rg3py.pyi
cd ..
rm Extension/rg3py/rg3py.pyd
rm Extension/rg3py/rg3py.pyi
- name: Build WHL for macOS
env:
RG3_DEPLOY_VERSION: ${{ steps.get_version.outputs.VERSION }}
RG3_DEPLOY_OS: 'macos'
run: |
mv RG3_macOS/rg3py.so Extension/rg3py
mv RG3_macOS/rg3py.pyi Extension/rg3py
cd Extension
python setup.py bdist_wheel --plat-name macosx_14_0_universal2
rm build/lib/rg3py/rg3py.so
rm build/lib/rg3py/rg3py.pyi
cd ..
rm Extension/rg3py/rg3py.so
rm Extension/rg3py/rg3py.pyi
- name: Upload wheels
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
working-directory: Extension
run: |
twine upload dist/*