perf: reduce compiler work and reuse CI native builds

- Reduce frontend, runtime, and linking overhead for native builds.
- Add compact compiler artifacts and reproducible build timing benchmarks.
- Reuse native CI packages and consolidate self-hosting validation.
This commit is contained in:
Chris Tate
2026-09-30 11:08:13 -05:00
committed by GitHub
parent 6d1907aa06
commit eb7be34d9a
44 changed files with 1879 additions and 401 deletions
+64 -45
View File
@@ -10,7 +10,36 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
native_macos:
name: build (macOS arm64 native packages)
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 11.1.3
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- run: pnpm install --frozen-lockfile
- uses: ./.github/actions/native-packages
with:
target: darwin-arm64
- name: Preserve executable permissions in shared packages
run: >-
tar -czf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
packages/llvm-darwin-arm64/bin
packages/runtime-darwin-arm64/artifacts
packages/runtime-darwin-arm64/runtime-pack.json
- uses: actions/upload-artifact@v4
with:
name: native-darwin-arm64
path: ${{ runner.temp }}/native-darwin-arm64.tar.gz
retention-days: 1
tests:
needs: native_macos
name: test (${{ matrix.flavor }}, ${{ matrix.shard }}/10)
# arm64 macOS: same clang/libc the differential + number-formatting
# oracles were verified against.
@@ -45,10 +74,12 @@ jobs:
with:
node-version-file: .node-version
cache: pnpm
- run: brew install llvm@22
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @scriptc/llvm-darwin-arm64 build:native
- run: pnpm --filter @scriptc/runtime-darwin-arm64 build:native
- uses: actions/download-artifact@v4
with:
name: native-darwin-arm64
path: ${{ runner.temp }}
- run: tar -xzf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
- run: pnpm build
# Separate vitest invocations because the shard axes must not mix: a file
# lands in exactly ONE --shard slice, so an env-sharded file behind
@@ -68,7 +99,6 @@ jobs:
--exclude=tests/harness/self-hosting.test.ts
--exclude=tests/harness/self-hosting-llvm-emitter.test.ts
--exclude=tests/harness/self-hosting-native-driver.test.ts
--exclude=tests/harness/self-hosting-bootstrap.test.ts
--exclude=tests/harness/fetch.test.ts
--exclude=tests/harness/npm-static.test.ts
--exclude=tests/harness/surface-manifest.test.ts
@@ -137,7 +167,7 @@ jobs:
# Full compiler rebuilds dominate the critical path. Start them immediately
# after setup, independently of corpus and integration test shards.
bootstrap:
name: test (Linux, ${{ matrix.flavor }}, ${{ matrix.compiler }} bootstrap)
name: test (Linux, ${{ matrix.flavor }}, native bootstrap)
# These contracts are portable. Standard Linux runners have enough memory
# for LLVM optimization alongside the compiler that produces its input.
runs-on: ubuntu-24.04
@@ -145,12 +175,6 @@ jobs:
fail-fast: false
matrix:
flavor: [plain, san]
compiler: [frontend, native]
include:
- compiler: frontend
test: tests/harness/self-hosting-bootstrap.test.ts
- compiler: native
test: tests/harness/self-hosting-native-driver.test.ts
env:
SCRIPTC_TEST_WORKERS: "1"
SCRIPTC_SAN: ${{ matrix.flavor == 'san' && '1' || '' }}
@@ -163,25 +187,20 @@ jobs:
with:
node-version-file: .node-version
cache: pnpm
- name: Install pinned LLVM development distribution
run: |
sudo apt-get update
sudo apt-get install --yes g++ zlib1g-dev libzstd-dev
curl -fL --retry 3 -o "$RUNNER_TEMP/llvm.tar.xz" https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/LLVM-22.1.8-Linux-X64.tar.xz
tar -xJf "$RUNNER_TEMP/llvm.tar.xz" -C "$RUNNER_TEMP"
mv "$RUNNER_TEMP/LLVM-22.1.8-Linux-X64" "$RUNNER_TEMP/llvm-22.1.8"
echo "LLVM_DIR=$RUNNER_TEMP/llvm-22.1.8/lib/cmake/llvm" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/llvm-22.1.8/bin" >> "$GITHUB_PATH"
- uses: ./.github/actions/llvm-linux
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @scriptc/llvm-linux-x64-gnu build:native
- uses: vercel-labs/setup-zig@v1
with:
version: 0.16.0
- run: CC=zig AR=zig pnpm --filter @scriptc/runtime-linux-x64-gnu build:native
- if: matrix.compiler == 'native'
run: pnpm --filter @scriptc/runtime-wasm32-wasi build:native
- uses: ./.github/actions/native-packages
with:
target: linux-x64-gnu
- uses: ./.github/actions/native-packages
with:
target: wasm32-wasi
helper: "false"
- run: pnpm build
- run: pnpm test ${{ matrix.test }}
- run: pnpm test tests/harness/self-hosting-native-driver.test.ts
# A real host-clang/glibc build, not the zig cross-target lane: catches
# Linux feature-test macro omissions at compile time and separate-libm
@@ -205,10 +224,11 @@ jobs:
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Host clang static-build regression
- name: Host clang and sanitizer build regressions
run: >-
pnpm test packages/compiler/test/cc-driver.test.ts
--testNamePattern "host-native clang static build"
packages/compiler/src/native/sanitizer.test.ts
--testNamePattern "host-native clang static build|sanitized vendor archives"
# The TS7 parity sweep exercises the compiler frontend, so it can run
# alongside the Linux LLVM/runtime package build instead of following it.
@@ -243,21 +263,14 @@ jobs:
with:
node-version-file: .node-version
cache: pnpm
- name: Install pinned LLVM development distribution
run: |
sudo apt-get update
sudo apt-get install --yes g++ zlib1g-dev libzstd-dev
curl -fL --retry 3 -o "$RUNNER_TEMP/llvm.tar.xz" https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/LLVM-22.1.8-Linux-X64.tar.xz
tar -xJf "$RUNNER_TEMP/llvm.tar.xz" -C "$RUNNER_TEMP"
mv "$RUNNER_TEMP/LLVM-22.1.8-Linux-X64" "$RUNNER_TEMP/llvm-22.1.8"
echo "LLVM_DIR=$RUNNER_TEMP/llvm-22.1.8/lib/cmake/llvm" >> "$GITHUB_ENV"
echo "$RUNNER_TEMP/llvm-22.1.8/bin" >> "$GITHUB_PATH"
- uses: ./.github/actions/llvm-linux
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @scriptc/llvm-linux-x64-gnu build:native
- uses: vercel-labs/setup-zig@v1
with:
version: 0.16.0
- run: CC=zig AR=zig pnpm --filter @scriptc/runtime-linux-x64-gnu build:native
- uses: ./.github/actions/native-packages
with:
target: linux-x64-gnu
- name: Build and verify Linux x64 musl release packages
run: |
pnpm --filter @scriptc/llvm-linux-x64-musl build:native
@@ -274,7 +287,10 @@ jobs:
if (value.default_target !== "x86_64-unknown-linux-musl" || !value.supported_targets?.includes("wasm32-unknown-wasi")) process.exit(1);
'
node packages/runtime-linux-x64-musl/scripts/verify.mjs
- run: pnpm --filter @scriptc/runtime-wasm32-wasi build:native
- uses: ./.github/actions/native-packages
with:
target: wasm32-wasi
helper: "false"
- run: pnpm build
- name: Linux helper object format and no-clang output contract
run: |
@@ -304,6 +320,7 @@ jobs:
run: pnpm test packages/cli/test/wasi-runtime-pack.test.ts tests/harness/wasm-library.test.ts
llvm_artifacts_macos_arm64:
needs: native_macos
name: test (macOS arm64 LLVM artifacts, no clang, ${{ matrix.shard }}/5)
runs-on: macos-15
# Shard 1 additionally runs package/install and link-parity contracts
@@ -329,10 +346,12 @@ jobs:
with:
node-version-file: .node-version
cache: pnpm
- run: brew install llvm@22
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @scriptc/llvm-darwin-arm64 build:native
- run: pnpm --filter @scriptc/runtime-darwin-arm64 build:native
- uses: actions/download-artifact@v4
with:
name: native-darwin-arm64
path: ${{ runner.temp }}
- run: tar -xzf "$RUNNER_TEMP/native-darwin-arm64.tar.gz"
- run: pnpm build
- name: No-clang assembly/object contract
if: matrix.shard == 1
@@ -399,10 +418,10 @@ jobs:
with:
node-version-file: .node-version
cache: pnpm
- run: brew install llvm@22
- run: pnpm install --frozen-lockfile
- run: LLVM_DIR=/usr/local/opt/llvm@22/lib/cmake/llvm pnpm --filter @scriptc/llvm-darwin-x64 build:native
- run: pnpm --filter @scriptc/runtime-darwin-x64 build:native
- uses: ./.github/actions/native-packages
with:
target: darwin-x64
- run: pnpm build
- name: Intel Mach-O no-clang object contract
run: |