Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
# (npm/README.md, "Linux libc"). Each Linux tsc builds natively on a Blacksmith runner of its arch.
# Windows (x86_64-pc-windows-msvc, aarch64-pc-windows-msvc) builds in Git Bash, with the C runtime
# linked in (+crt-static), so tsc.exe needs no Visual C++ redistributable. jemalloc does not build
# there: it uses the system allocator. Each tsc builds natively, so the PGO training runs on its
# own platform: Blacksmith has no Intel Mac and no arm64 Windows runner, so darwin-x64 builds on
# GitHub's macos-15-intel (4 vCPU) and
# win32-arm64 on GitHub's windows-11-arm (4 vCPU).
# there: it uses the system allocator. Each PGO tsc builds natively, so its training runs on its
# own platform. darwin-x64 and win32-arm64 ship without PGO (about 10 to 13% more CPU on a check:
# R121 measured 14 to 15% fewer cycles than plain for PGO and BOLT, 1.3 to 2.6% of it BOLT), so
# each is one fat-LTO build. Blacksmith has no Intel Mac, so darwin-x64 cross-builds on
# Blacksmith's arm64 Mac, as T3 Code's x64 desktop build does, and its check runs the x86-64 tsc
# under Rosetta 2; the verify job runs it on an Intel Mac (macos-15-intel). Blacksmith has no arm64
# Windows runner, so win32-arm64 builds on GitHub's windows-11-arm (4 vCPU).
name: Release

on:
Expand Down Expand Up @@ -95,20 +98,26 @@ jobs:
- platform: darwin-arm64
target: aarch64-apple-darwin
runner: blacksmith-12vcpu-macos-26
# No PGO, cross-built on arm64: GitHub's 4 vCPU macos-15-intel took 76 minutes for the
# three fat-LTO builds of the PGO tsc.
- platform: darwin-x64
target: x86_64-apple-darwin
runner: macos-15-intel
runner: blacksmith-12vcpu-macos-26
rosetta: true
no-pgo: true
- platform: win32-x64
target: x86_64-pc-windows-msvc
runner: blacksmith-16vcpu-windows-2025
exe: .exe
# No PGO: the PGO tsc took 48 minutes on this 4 vCPU runner.
- platform: win32-arm64
target: aarch64-pc-windows-msvc
runner: windows-11-arm
exe: .exe
linker: rust-lld
no-pgo: true
runs-on: ${{ matrix.runner }}
# The 4 vCPU GitHub-hosted runners (darwin-x64, win32-arm64) build slower.
# The 4 vCPU GitHub-hosted runner (win32-arm64) builds slower.
timeout-minutes: 180
# Git Bash on Windows.
defaults:
Expand All @@ -125,6 +134,12 @@ jobs:
- run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal --target ${{ matrix.target }} --component llvm-tools
- if: runner.os == 'Linux'
run: sudo apt-get update -q && sudo apt-get install -yq musl-tools
# darwin-x64 on an arm64 Mac: the check runs the x86-64 tsc, so Rosetta 2 must be there.
- name: Rosetta
if: matrix.rosetta
run: |
arch -x86_64 /usr/bin/true 2>/dev/null || sudo softwareupdate --install-rosetta --agree-to-license
arch -x86_64 /usr/bin/true
# win32-arm64 links with rust-lld (lld-link), all three builds. On arm64, link.exe aligns each
# section contribution to 4 bytes, also the 1-byte start markers of the LLVM profile sections
# (IMAGE_SCN_ALIGN_1BYTES). The instrumented tsc then wrote 3 zero bytes before the names, and
Expand Down Expand Up @@ -161,8 +176,8 @@ jobs:
# jemalloc stops at start when the kernel page is bigger than its build page. arm64 kernels
# use 4, 16 or 64 KiB pages; 2^16 covers all three.
[[ $target != aarch64-* ]] || echo "JEMALLOC_SYS_WITH_LG_PAGE=16" >> "$GITHUB_ENV"
# The plain tsc: the reference of the PGO check below. PGO_LINK is the link mode of both builds
# (build-pgo.sh): static on Linux, crt-static on Windows.
# The plain tsc: the reference of the PGO check below, or the shipped tsc with no-pgo. PGO_LINK is
# the link mode of both builds (build-pgo.sh): static on Linux, crt-static on Windows.
- name: Build
run: |
case $RUNNER_OS in
Expand All @@ -171,13 +186,16 @@ jobs:
esac
echo "PGO_LINK=${PGO_LINK:-}" >> "$GITHUB_ENV"
cargo build --profile goport --locked -p ts_goport --bin tsgo --features noembed --target ${{ matrix.target }}
mkdir -p "$RUNNER_TEMP/plain"
mkdir -p "$RUNNER_TEMP/plain" "$RUNNER_TEMP/out"
cp "target/${{ matrix.target }}/goport/tsgo${{ matrix.exe }}" "$RUNNER_TEMP/plain/tsc${{ matrix.exe }}"
[[ -z "${{ matrix.no-pgo }}" ]] || cp "$RUNNER_TEMP/plain/tsc${{ matrix.exe }}" "$RUNNER_TEMP/out/tsc${{ matrix.exe }}"
- name: PGO training set
if: ${{ !matrix.no-pgo }}
run: scripts/goport/pgo-train.sh setup "$RUNNER_TEMP/train"
# The same build with -Cprofile-generate, the training set, then -Cprofile-use. PGO_LINK (from
# the Build step) gives the RUSTFLAGS of the plain build. Separate target dirs (not cached).
- name: PGO build
if: ${{ !matrix.no-pgo }}
env:
PGO_TARGET: ${{ matrix.target }}
PGO_BINS: tsgo
Expand All @@ -188,6 +206,7 @@ jobs:
mkdir -p "$RUNNER_TEMP/out"
cp "$RUNNER_TEMP/pgo/target-use/goport/tsgo${{ matrix.exe }}" "$RUNNER_TEMP/out/tsc${{ matrix.exe }}"
- name: Check the PGO tsc against the plain tsc
if: ${{ !matrix.no-pgo }}
run: scripts/goport/pgo-train.sh compare "$RUNNER_TEMP/train" "$RUNNER_TEMP/plain/tsc${{ matrix.exe }}" "$RUNNER_TEMP/out/tsc${{ matrix.exe }}"
- name: Check the tsc
env:
Expand Down
28 changes: 14 additions & 14 deletions npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ The release workflow (`.github/workflows/release.yml`) makes a release:
1. Push a tag `v<version>`, for example `git tag v0.1.0 && git push origin v0.1.0`. The npm
version is the tag without the `v`.
2. It builds the tsc on Linux x64 and Linux arm64 (static musl, non-PIE: it starts on any Linux of
its arch; each builds natively on a Blacksmith runner of that arch), on an arm64 Mac and an
Intel Mac (jemalloc does not cross-build for macOS with zig), and on Windows x64 and arm64
(MSVC, the C runtime linked in, the system allocator), from the same source. Each is a PGO
build trained on its own platform (see below). Blacksmith has no Intel Mac and no arm64
Windows runner: darwin-x64 builds on GitHub's `macos-15-intel` and win32-arm64 on GitHub's
`windows-11-arm`.
its arch; each builds natively on a Blacksmith runner of that arch), on an arm64 Mac (both
macOS tscs: jemalloc does not cross-build for macOS with zig, but Apple's clang builds it for
x86-64 on an arm64 Mac), and on Windows x64 and arm64 (MSVC, the C runtime linked in, the
system allocator), from the same source. Each is a PGO build trained on its own platform (see
below), except darwin-x64 and win32-arm64: these ship a plain fat-LTO build, about 10 to 13%
slower on a check, because their PGO builds took 76 and 48 minutes. Blacksmith has no arm64
Windows runner, so win32-arm64 builds on GitHub's `windows-11-arm`.
3. It packs the set with `npm-pack.sh --name tsc-rs --package-version <v> --also linux-arm64=<tsc> --also darwin-arm64=<tsc> --also darwin-x64=<tsc> --also win32-x64=<tsc.exe> --also win32-arm64=<tsc.exe>`,
and `@tsc-rs/typescript` with the same line and `--name @tsc-rs/typescript` (its platform
packages must be the same bytes), makes one archive per platform (the tsc, the lib files,
Expand All @@ -118,14 +119,13 @@ To make a prerelease the default after a check of `npx tsc-rs@next` on each plat
`npm dist-tag add tsc-rs@<v> latest`, and the same for `@tsc-rs/typescript` and each platform
package.

The CI builds are PGO builds of the shipped profile (fat LTO): `build-pgo.sh` trains each
platform's tsc on the set of `scripts/goport/pgo-train.sh`, and the job fails unless the PGO tsc
gives the same output as a plain build on that set. They have no BOLT: BOLT refuses the static
Linux bin, macOS has no perf branch sampling for its profile, and BOLT has no PE (Windows)
support. To make the Linux x64 tsc by
hand on zbook, use
`RELEASE_FEATURES=noembed RELEASE_LIBC=musl RELEASE_PIE=0 crates/ts_goport/scripts/build-release.sh <out>/linux-x64`
and pack and test it:
The CI builds (but darwin-x64 and win32-arm64) are PGO builds of the shipped profile (fat LTO):
`build-pgo.sh` trains each platform's tsc on the set of `scripts/goport/pgo-train.sh`, and the job
fails unless the PGO tsc gives the same output as a plain build on that set. They have no BOLT: BOLT
refuses the static Linux bin, macOS has no perf branch sampling for its profile, and BOLT has no PE
(Windows) support. To make the Linux x64 tsc by hand on zbook, use `RELEASE_FEATURES=noembed
RELEASE_LIBC=musl RELEASE_PIE=0 crates/ts_goport/scripts/build-release.sh <out>/linux-x64` and pack
and test it:

```sh
GOPORT_PIN=<pin> scripts/goport/npm-pack.sh --name tsc-rs --package-version <v> \
Expand Down
Loading