Skip to content

fixed merger error #104

fixed merger error

fixed merger error #104

Workflow file for this run

name: Release
on:
push:
branches: [main]
tags: ['v*']
pull_request:
permissions:
contents: read
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-15-intel
llvm_method: brew
archive_ext: tar.gz
- target: aarch64-apple-darwin
os: macos-14
llvm_method: brew
archive_ext: tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
llvm_method: tarball
archive_ext: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
llvm_method: tarball
archive_ext: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-24.04
llvm_method: docker
archive_ext: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
llvm_method: tarball
archive_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v4
# ── LLVM 21 Installation ──────────────────────────────────────
- name: Cache LLVM
if: matrix.llvm_method == 'tarball'
uses: actions/cache@v4
id: cache-llvm
with:
path: ~/llvm
key: llvm-21.1.8-v4-${{ matrix.target }}
- name: Install LLVM 21 (Homebrew)
if: matrix.llvm_method == 'brew'
run: |
brew install llvm@21
echo "LLVM_SYS_211_PREFIX=$(brew --prefix llvm@21)" >> "$GITHUB_ENV"
- name: Install LLVM 21 (Linux x86_64)
if: >-
matrix.llvm_method == 'tarball' &&
runner.os == 'Linux' &&
steps.cache-llvm.outputs.cache-hit != 'true'
run: |
LLVM_VERSION="21.1.8"
LLVM_ARCHIVE="LLVM-${LLVM_VERSION}-Linux-X64.tar.xz"
LLVM_URL="https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/${LLVM_ARCHIVE}"
curl -sSfL "$LLVM_URL" -o llvm.tar.xz
mkdir -p "$HOME/llvm"
tar xf llvm.tar.xz --strip-components=1 -C "$HOME/llvm"
rm llvm.tar.xz
- name: Install LLVM 21 (Linux ARM64)
if: >-
matrix.llvm_method == 'tarball' &&
matrix.target == 'aarch64-unknown-linux-gnu' &&
steps.cache-llvm.outputs.cache-hit != 'true'
run: |
LLVM_VERSION="21.1.3"
LLVM_ARCHIVE="clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz"
LLVM_URL="https://github.com/ycm-core/llvm/releases/download/${LLVM_VERSION}/${LLVM_ARCHIVE}"
curl -sSfL "$LLVM_URL" -o llvm.tar.xz
mkdir -p "$HOME/llvm"
tar xf llvm.tar.xz --strip-components=1 -C "$HOME/llvm"
rm llvm.tar.xz
- name: Install LLVM 21 (Windows)
if: >-
matrix.llvm_method == 'tarball' &&
matrix.target == 'x86_64-pc-windows-msvc' &&
steps.cache-llvm.outputs.cache-hit != 'true'
shell: pwsh
run: |
$LLVM_VERSION = "21.1.8"
$LLVM_DIR = "$env:USERPROFILE\llvm"
# Use the clang+llvm tarball which includes llvm-config, headers, and static libs
$LLVM_URL = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-pc-windows-msvc.tar.xz"
Invoke-WebRequest -Uri $LLVM_URL -OutFile llvm.tar.xz
7z x llvm.tar.xz
7z x llvm.tar -o"$env:USERPROFILE"
Rename-Item "$env:USERPROFILE\clang+llvm-${LLVM_VERSION}-x86_64-pc-windows-msvc" $LLVM_DIR
Remove-Item llvm.tar.xz, llvm.tar -Force
# The LLVM 21 prebuilt tarball is built with LLVM_ENABLE_RPMALLOC=ON,
# which embeds rpmalloc's malloc/free/realloc/calloc overrides into
# LLVMSupport.lib. When statically linked into a Rust binary via
# llvm-sys, these collide with ucrt.lib's heap symbols (LNK2005).
#
# Fix: extract all objects, remove the rpmalloc ones, compile a
# stub for rpmalloc_linker_reference, and rebuild the library.
$supportLib = "$LLVM_DIR\lib\LLVMSupport.lib"
$llvmAr = "$LLVM_DIR\bin\llvm-ar.exe"
$clang = "$LLVM_DIR\bin\clang.exe"
if ((Test-Path $supportLib) -and (Test-Path $llvmAr)) {
$workDir = "$LLVM_DIR\lib\_rpmalloc_strip"
New-Item -ItemType Directory -Force -Path $workDir | Out-Null
Push-Location $workDir
Write-Host "Extracting LLVMSupport.lib members..."
& $llvmAr x $supportLib
# Remove rpmalloc-related objects
$rpFiles = Get-ChildItem -Filter "*.obj" | Where-Object { $_.Name -match "rpmalloc" }
foreach ($f in $rpFiles) {
Write-Host " Removing: $($f.Name)"
Remove-Item $f.FullName -Force
}
# Provide stub so InitLLVM.cpp.obj's reference resolves
$stubC = Join-Path $workDir "rpmalloc_stub.c"
$stubObj = Join-Path $workDir "rpmalloc_stub.obj"
Set-Content $stubC "void rpmalloc_linker_reference(void) {}"
& $clang -c -o $stubObj $stubC
Remove-Item $stubC -Force
# Rebuild the library from all remaining objects
Write-Host "Rebuilding LLVMSupport.lib without rpmalloc..."
Remove-Item $supportLib -Force
$objs = (Get-ChildItem -Filter "*.obj").FullName
& $llvmAr rcs $supportLib @objs
Pop-Location
Remove-Item $workDir -Recurse -Force
Write-Host "Done — rpmalloc stripped, stub added."
}
- name: Set LLVM prefix (Linux tarball)
if: matrix.llvm_method == 'tarball' && runner.os == 'Linux'
run: echo "LLVM_SYS_211_PREFIX=$HOME/llvm" >> "$GITHUB_ENV"
- name: Set LLVM prefix (Windows tarball)
if: matrix.llvm_method == 'tarball' && runner.os == 'Windows'
shell: pwsh
run: echo "LLVM_SYS_211_PREFIX=$env:USERPROFILE\llvm" >> $env:GITHUB_ENV
# ── Platform dependencies ─────────────────────────────────────
- name: Provide libxml2 for Windows LLVM link
if: runner.os == 'Windows'
shell: pwsh
run: |
# llvm-config --system-libs demands libxml2s.lib but the LLVM
# tarball doesn't ship it. Install via vcpkg and copy the .lib
# into the LLVM prefix lib dir so the linker finds it without
# a global LIB override (which previously caused duplicate symbols).
vcpkg install libxml2:x64-windows-static
$vcpkgLib = "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows-static\lib"
$dest = "$env:USERPROFILE\llvm\lib\libxml2s.lib"
# vcpkg names it libxml2.lib; LLVM expects libxml2s.lib
$candidates = @("$vcpkgLib\libxml2s.lib", "$vcpkgLib\libxml2.lib", "$vcpkgLib\xml2s.lib", "$vcpkgLib\xml2.lib")
Write-Host "Scanning for libxml2 in $vcpkgLib ..."
Get-ChildItem $vcpkgLib -Filter "*xml2*" | ForEach-Object { Write-Host " found: $($_.FullName)" }
$src = $null
foreach ($c in $candidates) {
if (Test-Path $c) { $src = $c; break }
}
if (-not $src) {
Write-Error "No libxml2 .lib found in $vcpkgLib"
exit 1
}
Copy-Item $src $dest -Force
Write-Host "Copied $src -> $dest"
# ── Rust Toolchain ────────────────────────────────────────────
- name: Install Rust
if: matrix.llvm_method != 'docker'
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cargo cache
if: matrix.llvm_method != 'docker'
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
# ── Build ─────────────────────────────────────────────────────
- name: Build meshc (Alpine/musl)
if: matrix.llvm_method == 'docker'
run: |
docker run --rm \
-v "$GITHUB_WORKSPACE:/workspace" \
-w /workspace \
alpine:3.23 sh -c '
apk add --no-cache \
llvm21-dev llvm21-static \
musl-dev gcc g++ make cmake perl \
zlib-dev zlib-static zstd-dev zstd-static \
libffi-dev libxml2-dev libxml2-static \
openssl-dev openssl-libs-static \
linux-headers curl git &&
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable &&
source "$HOME/.cargo/env" &&
export LLVM_SYS_211_PREFIX=/usr/lib/llvm21 &&
cargo build --release --target x86_64-unknown-linux-musl
'
sudo chown -R $(id -u):$(id -g) target/
- name: Build meshc (Unix)
if: runner.os != 'Windows' && matrix.llvm_method != 'docker'
run: cargo build --release --target ${{ matrix.target }}
env:
LLVM_SYS_211_PREFIX: ${{ env.LLVM_SYS_211_PREFIX }}
- name: Build meshc (Windows)
if: runner.os == 'Windows'
run: cargo build --release --target ${{ matrix.target }}
env:
LLVM_SYS_211_PREFIX: ${{ env.LLVM_SYS_211_PREFIX }}
# ── Strip & Package ───────────────────────────────────────────
- name: Determine version
id: version
shell: bash
run: |
meshc_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' compiler/meshc/Cargo.toml | head -n1)"
meshpkg_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' compiler/meshpkg/Cargo.toml | head -n1)"
if [[ -z "$meshc_version" || "$meshc_version" != "$meshpkg_version" ]]; then
echo "meshc and meshpkg versions must stay aligned" >&2
exit 1
fi
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
tag_version="${GITHUB_REF_NAME#v}"
if [[ "$tag_version" != "$meshc_version" ]]; then
echo "tag version $tag_version does not match Cargo version $meshc_version" >&2
exit 1
fi
echo "version=$tag_version" >> "$GITHUB_OUTPUT"
else
echo "version=$meshc_version" >> "$GITHUB_OUTPUT"
fi
- name: Strip binary (Unix)
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/meshc
- name: Package (tar.gz)
if: matrix.archive_ext == 'tar.gz'
run: |
tar czf "meshc-v${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz" \
-C "target/${{ matrix.target }}/release" meshc
- name: Package (zip)
if: matrix.archive_ext == 'zip'
shell: pwsh
run: |
Compress-Archive `
-Path "target/${{ matrix.target }}/release/meshc.exe" `
-DestinationPath "meshc-v${{ steps.version.outputs.version }}-${{ matrix.target }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: meshc-${{ matrix.target }}
path: meshc-v${{ steps.version.outputs.version }}-${{ matrix.target }}.${{ matrix.archive_ext }}
# ── Build meshpkg ────────────────────────────────────────────────────
build-meshpkg:
name: Build meshpkg (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-15-intel
archive_ext: tar.gz
- target: aarch64-apple-darwin
os: macos-14
archive_ext: tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
archive_ext: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
archive_ext: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cargo cache
uses: Swatinem/rust-cache@v2
with:
key: meshpkg-${{ matrix.target }}
- name: Determine version
id: version
shell: bash
run: |
meshc_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' compiler/meshc/Cargo.toml | head -n1)"
meshpkg_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' compiler/meshpkg/Cargo.toml | head -n1)"
if [[ -z "$meshc_version" || "$meshc_version" != "$meshpkg_version" ]]; then
echo "meshc and meshpkg versions must stay aligned" >&2
exit 1
fi
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
tag_version="${GITHUB_REF_NAME#v}"
if [[ "$tag_version" != "$meshc_version" ]]; then
echo "tag version $tag_version does not match Cargo version $meshc_version" >&2
exit 1
fi
echo "version=$tag_version" >> "$GITHUB_OUTPUT"
else
echo "version=$meshc_version" >> "$GITHUB_OUTPUT"
fi
- name: Build meshpkg
run: cargo build --release -p meshpkg --target ${{ matrix.target }}
- name: Strip binary
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/meshpkg
- name: Package (tar.gz)
if: matrix.archive_ext == 'tar.gz'
run: |
tar czf "meshpkg-v${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz" \
-C "target/${{ matrix.target }}/release" meshpkg
- name: Package (zip)
if: matrix.archive_ext == 'zip'
shell: pwsh
run: |
Compress-Archive `
-Path "target/${{ matrix.target }}/release/meshpkg.exe" `
-DestinationPath "meshpkg-v${{ steps.version.outputs.version }}-${{ matrix.target }}.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: meshpkg-${{ matrix.target }}
path: meshpkg-v${{ steps.version.outputs.version }}-${{ matrix.target }}.${{ matrix.archive_ext }}
# ── Authoritative live proof ───────────────────────────────────────
authoritative-live-proof:
name: Authoritative live proof
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/authoritative-live-proof.yml
secrets:
MESH_PUBLISH_OWNER: ${{ secrets.MESH_PUBLISH_OWNER }}
MESH_PUBLISH_TOKEN: ${{ secrets.MESH_PUBLISH_TOKEN }}
# ── Release asset smoke ────────────────────────────────────────────
verify-release-assets:
name: Verify release assets (${{ matrix.target }})
needs: [build, build-meshpkg]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-15-intel
archive_ext: tar.gz
- target: aarch64-apple-darwin
os: macos-14
archive_ext: tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-24.04
archive_ext: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-24.04-arm
archive_ext: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive_ext: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download meshc artifact
uses: actions/download-artifact@v4
with:
name: meshc-${{ matrix.target }}
path: release-assets/
- name: Download meshpkg artifact
uses: actions/download-artifact@v4
with:
name: meshpkg-${{ matrix.target }}
path: release-assets/
- name: Generate SHA256SUMS (Unix)
if: runner.os != 'Windows'
run: |
python3 - <<'PY'
from glob import glob
from hashlib import sha256
from pathlib import Path
patterns = [
"release-assets/meshc-v*-${{ matrix.target }}.${{ matrix.archive_ext }}",
"release-assets/meshpkg-v*-${{ matrix.target }}.${{ matrix.archive_ext }}",
]
files = []
for pattern in patterns:
matches = sorted(glob(pattern))
if len(matches) != 1:
raise SystemExit(f"missing release archive for ${{ matrix.target }}: {pattern} -> {len(matches)} matches")
files.append(Path(matches[0]))
lines = [
f"{sha256(path.read_bytes()).hexdigest()} {path.name}"
for path in files
]
output = Path("release-assets/SHA256SUMS")
output.write_text("\n".join(lines) + "\n", encoding="utf-8")
print(output.read_text(encoding="utf-8"), end="")
PY
- name: Generate SHA256SUMS (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$meshcArchive = Get-ChildItem -Path release-assets -Filter "meshc-v*-${{ matrix.target }}.${{ matrix.archive_ext }}" | Select-Object -First 1
$meshpkgArchive = Get-ChildItem -Path release-assets -Filter "meshpkg-v*-${{ matrix.target }}.${{ matrix.archive_ext }}" | Select-Object -First 1
$files = @($meshcArchive, $meshpkgArchive)
if ($files.Count -ne 2 -or ($files | Where-Object { $null -eq $_ }).Count -gt 0) {
throw "missing release archive for ${{ matrix.target }}"
}
$lines = foreach ($file in $files) {
"$((Get-FileHash -Path $file.FullName -Algorithm SHA256).Hash.ToLowerInvariant()) $($file.Name)"
}
Set-Content -Path release-assets/SHA256SUMS -Value $lines
Get-Content release-assets/SHA256SUMS
- name: Install Rust for smoke verifier
uses: dtolnay/rust-toolchain@stable
- name: Install LLVM 21 for Windows smoke verifier
if: runner.os == 'Windows'
shell: pwsh
run: |
$LLVM_VERSION = "21.1.8"
$LLVM_DIR = "$env:USERPROFILE\llvm"
$ClangPath = Join-Path $LLVM_DIR 'bin\clang.exe'
if (Test-Path $ClangPath) {
Write-Host "LLVM already present at $LLVM_DIR"
exit 0
}
$LLVM_URL = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-pc-windows-msvc.tar.xz"
Invoke-WebRequest -Uri $LLVM_URL -OutFile llvm.tar.xz
7z x llvm.tar.xz
7z x llvm.tar -o"$env:USERPROFILE"
Rename-Item "$env:USERPROFILE\clang+llvm-${LLVM_VERSION}-x86_64-pc-windows-msvc" $LLVM_DIR
Remove-Item llvm.tar.xz, llvm.tar -Force
# Strip rpmalloc from LLVMSupport.lib (same fix as Build job above)
$supportLib = "$LLVM_DIR\lib\LLVMSupport.lib"
$llvmAr = "$LLVM_DIR\bin\llvm-ar.exe"
$clang = "$LLVM_DIR\bin\clang.exe"
if ((Test-Path $supportLib) -and (Test-Path $llvmAr)) {
$workDir = "$LLVM_DIR\lib\_rpmalloc_strip"
New-Item -ItemType Directory -Force -Path $workDir | Out-Null
Push-Location $workDir
Write-Host "Extracting LLVMSupport.lib members..."
& $llvmAr x $supportLib
$rpFiles = Get-ChildItem -Filter "*.obj" | Where-Object { $_.Name -match "rpmalloc" }
foreach ($f in $rpFiles) {
Write-Host " Removing: $($f.Name)"
Remove-Item $f.FullName -Force
}
$stubC = Join-Path $workDir "rpmalloc_stub.c"
$stubObj = Join-Path $workDir "rpmalloc_stub.obj"
Set-Content $stubC "void rpmalloc_linker_reference(void) {}"
& $clang -c -o $stubObj $stubC
Remove-Item $stubC -Force
Write-Host "Rebuilding LLVMSupport.lib without rpmalloc..."
Remove-Item $supportLib -Force
$objs = (Get-ChildItem -Filter "*.obj").FullName
& $llvmAr rcs $supportLib @objs
Pop-Location
Remove-Item $workDir -Recurse -Force
Write-Host "Done — rpmalloc stripped, stub added."
}
- name: Set LLVM prefix for Windows smoke verifier
if: runner.os == 'Windows'
shell: pwsh
run: echo "LLVM_SYS_211_PREFIX=$env:USERPROFILE\llvm" >> $env:GITHUB_ENV
- name: Build mesh-rt for smoke verifier
run: cargo build -q -p mesh-rt
- name: Verify staged installer assets (Unix)
if: runner.os != 'Windows'
env:
M034_S03_PREBUILT_RELEASE_DIR: ${{ github.workspace }}/release-assets
run: bash scripts/verify-m034-s03.sh
- name: Verify staged installer assets (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
M034_S03_PREBUILT_RELEASE_DIR: ${{ github.workspace }}\release-assets
run: pwsh -NoProfile -File scripts/verify-m034-s03.ps1
- name: Upload release smoke diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: release-smoke-${{ matrix.target }}-diagnostics
path: .tmp/m034-s03/**
if-no-files-found: warn
# ── Release ─────────────────────────────────────────────────────────
release:
name: Create Release
needs: [build, build-meshpkg, authoritative-live-proof, verify-release-assets]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
merge-multiple: true
- name: Generate SHA256SUMS
run: |
cd artifacts/
sha256sum *.tar.gz *.zip > SHA256SUMS
cat SHA256SUMS
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*
generate_release_notes: false
draft: false
prerelease: false