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
61 changes: 45 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
# (npm/README.md, "Trusted publishing"). Pull requests that change the release files, and a manual
# run, do everything but the release and the publish.
#
# These builds are the plain shipped profile (fat LTO), without the PGO and BOLT of
# crates/ts_goport/scripts/build-release.sh, which needs a host with BOLT and the project inputs.
# The tsc is a PGO build of the shipped profile (fat LTO), trained on each platform:
# crates/ts_goport/scripts/build-pgo.sh with the training set of scripts/goport/pgo-train.sh (7
# projects at fixed commits). The job also builds the plain tsc, and fails unless the PGO tsc gives
# the same stdout, stderr, exit code and emitted files as the plain tsc on that set. No BOLT
# (build-release.sh has it): BOLT refuses the static Linux bin (build-bolt.sh), its Mach-O support
# is experimental, and macOS has no perf branch sampling for its profile.
# Linux is static musl and non-PIE, so it starts on any x86-64 or arm64 Linux, Alpine too
# (npm/README.md, "Linux libc"). Each Linux tsc builds natively on a Blacksmith runner of its arch.
name: Release
Expand All @@ -24,7 +28,9 @@ on:
- ".github/workflows/release.yml"
- "npm/**"
- "scripts/goport/npm-pack.sh"
- "scripts/goport/pgo-train.sh"
- "crates/ts_goport/scripts/copy-libs.sh"
- "crates/ts_goport/scripts/build-pgo.sh"
- "LICENSE"
- "NOTICE.md"
- "licenses/**"
Expand Down Expand Up @@ -87,33 +93,56 @@ jobs:
- uses: actions/checkout@v5
with:
persist-credentials: false
- run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal --target ${{ matrix.target }}
# llvm-tools: the llvm-profdata of this rustc's LLVM (build-pgo.sh checks it).
- 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
- uses: actions/setup-node@v5
with:
node-version: 24
- uses: Swatinem/rust-cache@v2
with:
key: release-${{ matrix.target }}
save-if: ${{ github.event_name != 'pull_request' }}
# As build-release.sh: the musl build compiles jemalloc with musl-gcc, links static with no PIE,
# and has bin/tsgo.rs JEMALLOC_CONF built in, so the tsc does not exec itself at start. No
# GOPORT_BUILD_VERSION: the tsc reports the TypeScript version, which typesVersions matching
# reads (npm/README.md, "tsc-rs releases").
# reads (npm/README.md, "tsc-rs releases"). Both builds below use this environment.
- name: Build environment
if: runner.os == 'Linux'
run: |
conf=$(sed -n 's/^const JEMALLOC_CONF: &str = "\([^"]*\)";$/\1/p' crates/ts_goport/src/bin/tsgo.rs | head -1)
[[ -n $conf ]] || { echo "::error::no JEMALLOC_CONF in bin/tsgo.rs"; exit 1; }
echo "JEMALLOC_SYS_WITH_MALLOC_CONF=$conf" >> "$GITHUB_ENV"
target=${{ matrix.target }}
echo "CC_${target//-/_}=musl-gcc" >> "$GITHUB_ENV"
# 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.
- name: Build
run: |
if [[ $RUNNER_OS == Linux ]]; then
target=${{ matrix.target }}
export "CC_${target//-/_}=musl-gcc"
# 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-* ]] || export JEMALLOC_SYS_WITH_LG_PAGE=16
export RUSTFLAGS="-C target-feature=+crt-static -C relocation-model=static"
JEMALLOC_SYS_WITH_MALLOC_CONF=$(sed -n 's/^const JEMALLOC_CONF: &str = "\([^"]*\)";$/\1/p' crates/ts_goport/src/bin/tsgo.rs | head -1)
[[ -n $JEMALLOC_SYS_WITH_MALLOC_CONF ]] || { echo "::error::no JEMALLOC_CONF in bin/tsgo.rs"; exit 1; }
export JEMALLOC_SYS_WITH_MALLOC_CONF
fi
[[ $RUNNER_OS != Linux ]] || export RUSTFLAGS="-C target-feature=+crt-static -C relocation-model=static"
cargo build --profile goport --locked -p ts_goport --bin tsgo --features noembed --target ${{ matrix.target }}
mkdir -p "$RUNNER_TEMP/plain"
cp "target/${{ matrix.target }}/goport/tsgo" "$RUNNER_TEMP/plain/tsc"
- name: PGO training set
run: scripts/goport/pgo-train.sh setup "$RUNNER_TEMP/train"
# The same build with -Cprofile-generate, the training set, then -Cprofile-use. PGO_LINK=static
# gives the RUSTFLAGS of the plain Linux build. Separate target dirs (not cached).
- name: PGO build
env:
PGO_TARGET: ${{ matrix.target }}
PGO_BINS: tsgo
PGO_CARGO: cargo
CARGO_FEATURES: --features noembed
run: |
[[ $RUNNER_OS != Linux ]] || export PGO_LINK=static
PGO_TRAIN="scripts/goport/pgo-train.sh run $RUNNER_TEMP/train" crates/ts_goport/scripts/build-pgo.sh "$RUNNER_TEMP/pgo"
mkdir -p "$RUNNER_TEMP/out"
cp "target/${{ matrix.target }}/goport/tsgo" "$RUNNER_TEMP/out/tsc"
cp "$RUNNER_TEMP/pgo/target-use/goport/tsgo" "$RUNNER_TEMP/out/tsc"
- name: Check the PGO tsc against the plain tsc
run: scripts/goport/pgo-train.sh compare "$RUNNER_TEMP/train" "$RUNNER_TEMP/plain/tsc" "$RUNNER_TEMP/out/tsc"
- name: Check the tsc
run: |
out="$RUNNER_TEMP/out"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ goes away when the port moves to a newer pin.
181,711 ported Go tests pass. The language server and API answers match Go on the oracle test
sets.
- **Faster.** On 60 open-source projects, type checking takes about half of Go's time (geometric
mean). The preview packages are built in CI without PGO and BOLT, so they are slower than that
measured build.
mean). The npm packages are built in CI with PGO but without BOLT (0.1.0 has neither), so they
are slower than that measured build.
- **Real projects.** On 120 open-source repos, the command-line output differs from Go's only in
the problems below and where Go's own output changes from run to run.

Expand Down
Loading
Loading