## Summary
This PR adds cross-compilation support for three new target platforms,
upgrades LLVM to 21.1.8, and overhauls the CI pipelines around
cross-builds and testing.
## Cross-compilation
New target triples accepted via `-DCLICE_TARGET_TRIPLE=...`:
| Target triple | Host | Output |
|---|---|---|
| `x86_64-apple-darwin` | macos-15 (arm64) | macOS x64 |
| `aarch64-linux-gnu` | ubuntu-24.04 (x64) | Linux arm64 |
| `aarch64-pc-windows-msvc` | windows-2025 (x64) | Windows arm64 |
- `cmake/toolchain.cmake` — maps `CLICE_TARGET_TRIPLE` to
`CMAKE_SYSTEM_NAME`/`CMAKE_SYSTEM_PROCESSOR`/compiler `--target`; picks
up conda aarch64 sysroot when cross-compiling Linux.
- `cmake/llvm.cmake` — forwards target platform/arch to `setup-llvm.py`
so the right prebuilt LLVM is downloaded for the target.
- `CMakeLists.txt` — uses a host-side `flatc` from `PATH` under
`CMAKE_CROSSCOMPILING` instead of the in-tree target build.
- `pixi.toml`:
- Adds `osx-64`, `linux-aarch64`, `win-arm64` platforms.
- New environments: `cross-macos-x64`, `cross-linux-aarch64` (adds
`gcc_linux-aarch64` + `sysroot_linux-aarch64`), `cross-windows-arm64`.
- New lightweight `test-run` env used on native ARM/x64 runners to
execute cross-built artifacts (pulls in upstream clang+lld on macOS so
tests don't fall back to Apple clang).
- `scripts/activate_cross_linux.sh` — exports `CONDA_PREFIX`-relative
paths for the aarch64 toolchain.
- `scripts/build-llvm.py` — `--target-triple` support and a
`build_native_tools()` helper that produces host `llvm-tblgen` /
`clang-tblgen` needed when cross-compiling LLVM itself.
## LLVM upgrade 21.1.4 → 21.1.8
- `cmake/package.cmake` bumps `setup_llvm("21.1.8")`.
- `config/llvm-manifest.json` regenerated with 6 new cross-compiled
entries and a new `arch` field on every entry so lookup is `(version,
platform, arch, lto, build_type)`.
- `scripts/setup-llvm.py` — honours the new `arch` field when resolving
artifacts.
- `scripts/update-llvm-version.py` (new) — single-call version bump
across `package.cmake` + manifest.
- `scripts/validate-llvm-components.py` (new) — scans the LLVM source
tree for library targets and diffs them against
`scripts/llvm-components.json` to catch stale/misspelled component names
before a build.
- `scripts/llvm-components.json` (new) — explicit allow-list of required
LLVM/Clang library targets used by `build-llvm.py`.
## CI changes
- `.github/workflows/build-llvm.yml`:
- Adds `workflow_dispatch` with `llvm_version`, `skip_upload`, `skip_pr`
inputs.
- Matrix extended with the 6 cross-compile entries (2 per new platform:
RelWithDebInfo ± LTO).
- `build clice` / test / prune steps gated on `!matrix.target_triple`
for cross-builds; cross-built LTO entries apply the native prune
manifest (arch-independent).
- Cross-compiled binary architecture is verified with `file(1)`.
- New `upload` job triggered by `workflow_dispatch` pushes artifacts to
`clice-io/clice-llvm` and hands the manifest off to the next job.
- `.github/workflows/test-cmake.yml`:
- Build matrix gains three `build_only: true` cross entries that upload
`bin/` + `lib/` artifacts.
- New `test-cross` job runs on native `macos-15-intel`,
`ubuntu-24.04-arm`, `windows-11-arm` runners, downloads the cross-built
artifacts, and runs unit / integration / smoke tests under the
`test-run` pixi env.
- Cache keys now include `target_triple` so native and cross builds
don't collide.
- `.github/workflows/publish-clice.yml`:
- Three additional release artifacts for the new targets
(`clice-x86_64-macos-darwin`, `clice-aarch64-linux-gnu`,
`clice-aarch64-windows-msvc`), each with a matching `-symbol` archive.
## Compatibility
- All existing native builds and tests are preserved; cross entries are
additive.
- `Debug` + ASAN remains disabled on Windows (`llvm_mode == Debug && os
== windows-*` no longer appends `-asan`).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
151 lines
4.7 KiB
YAML
151 lines
4.7 KiB
YAML
name: cmake
|
|
|
|
on:
|
|
workflow_call:
|
|
|
|
env:
|
|
CCACHE_DIR: ${{ github.workspace }}/.cache/ccache
|
|
SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache
|
|
CCACHE_BASEDIR: ${{ github.workspace }}
|
|
SCCACHE_BASEDIRS: ${{ github.workspace }}
|
|
CCACHE_COMPILERCHECK: content
|
|
CCACHE_MAXSIZE: 2G
|
|
SCCACHE_CACHE_SIZE: 2G
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# Native builds
|
|
- os: windows-2025
|
|
build_type: RelWithDebInfo
|
|
- os: ubuntu-24.04
|
|
build_type: Debug
|
|
- os: ubuntu-24.04
|
|
build_type: RelWithDebInfo
|
|
- os: macos-15
|
|
build_type: Debug
|
|
- os: macos-15
|
|
build_type: RelWithDebInfo
|
|
# Cross-compile (build only; tests run on native runners)
|
|
- os: macos-15
|
|
build_type: RelWithDebInfo
|
|
target_triple: x86_64-apple-darwin
|
|
build_only: true
|
|
- os: ubuntu-24.04
|
|
build_type: RelWithDebInfo
|
|
target_triple: aarch64-linux-gnu
|
|
build_only: true
|
|
pixi_env: cross-linux-aarch64
|
|
- os: windows-2025
|
|
build_type: RelWithDebInfo
|
|
target_triple: aarch64-pc-windows-msvc
|
|
build_only: true
|
|
pixi_env: cross-windows-arm64
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- uses: ./.github/actions/setup-pixi
|
|
with:
|
|
environments: ${{ matrix.pixi_env || 'default' }}
|
|
|
|
- name: Restore compiler cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ runner.os == 'Windows' && '.cache/sccache' || '.cache/ccache' }}
|
|
key: ${{ runner.os }}-${{ matrix.build_type }}-${{ matrix.target_triple || 'native' }}-ccache-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.build_type }}-${{ matrix.target_triple || 'native' }}-ccache-
|
|
|
|
- name: Zero cache stats
|
|
run: |
|
|
ENV="${{ matrix.pixi_env || 'default' }}"
|
|
if [ "$RUNNER_OS" = "Windows" ]; then
|
|
pixi run -e "$ENV" -- sccache --stop-server || true
|
|
pixi run -e "$ENV" -- sccache --zero-stats || true
|
|
else
|
|
pixi run -e "$ENV" -- ccache --zero-stats || true
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Build (native)
|
|
if: ${{ !matrix.target_triple }}
|
|
run: pixi run build ${{ matrix.build_type }} ON
|
|
|
|
- name: Build (cross-compile)
|
|
if: ${{ matrix.target_triple }}
|
|
shell: bash
|
|
run: |
|
|
ENV="${{ matrix.pixi_env || 'default' }}"
|
|
pixi run -e "$ENV" cmake-config ${{ matrix.build_type }} OFF -- \
|
|
"-DCLICE_TARGET_TRIPLE=${{ matrix.target_triple }}"
|
|
pixi run -e "$ENV" cmake-build ${{ matrix.build_type }}
|
|
|
|
- name: Upload cross-compiled binaries
|
|
if: ${{ matrix.build_only }}
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cross-build-${{ matrix.target_triple }}
|
|
path: |
|
|
build/${{ matrix.build_type }}/bin/
|
|
build/${{ matrix.build_type }}/lib/
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
- name: Run tests
|
|
if: ${{ !matrix.build_only }}
|
|
run: pixi run test ${{ matrix.build_type }}
|
|
|
|
- name: Print cache stats and stop server
|
|
if: always()
|
|
run: |
|
|
ENV="${{ matrix.pixi_env || 'default' }}"
|
|
if [ "$RUNNER_OS" = "Windows" ]; then
|
|
pixi run -e "$ENV" -- sccache --show-stats
|
|
pixi run -e "$ENV" -- sccache --stop-server || true
|
|
else
|
|
pixi run -e "$ENV" -- ccache --show-stats
|
|
fi
|
|
shell: bash
|
|
|
|
test-cross:
|
|
needs: build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: macos-15-intel
|
|
build_type: RelWithDebInfo
|
|
target_triple: x86_64-apple-darwin
|
|
- os: ubuntu-24.04-arm
|
|
build_type: RelWithDebInfo
|
|
target_triple: aarch64-linux-gnu
|
|
- os: windows-11-arm
|
|
build_type: RelWithDebInfo
|
|
target_triple: aarch64-pc-windows-msvc
|
|
runs-on: ${{ matrix.os }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- uses: ./.github/actions/setup-pixi
|
|
with:
|
|
environments: test-run
|
|
|
|
- name: Download cross-compiled binaries
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: cross-build-${{ matrix.target_triple }}
|
|
path: build/${{ matrix.build_type }}/
|
|
|
|
- name: Make binaries executable
|
|
if: runner.os != 'Windows'
|
|
run: chmod +x build/${{ matrix.build_type }}/bin/*
|
|
|
|
- name: Run tests
|
|
run: pixi run -e test-run test ${{ matrix.build_type }}
|