mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-30 07:14:39 +08:00
The Linux helpers linked LLVM 22.1.8's release archive. The helper's code generation is LLVM's code, so building that LLVM from its release sources with ThinLTO and with a profile of the helper's own work makes code generation 5-9% faster than the helper as released, with identical objects. - native/llvm-codegen/llvm.profdata.gz is the profile, collected by scripts/refresh-llvm-profile.mjs: it builds LLVM with IR instrumentation and an instrumented helper, and runs that helper on tsc-ts, five Effect fixtures, the runtime benchmark workloads and every 50th corpus program (scripts/llvm-helper-inputs.mjs). It follows LLVM's sources, so it needs a refresh when LLVM is bumped. - scripts/build-llvm-dist.mjs builds LLVM with that profile and ThinLTO, and packs it with a checksum. The llvm-dist workflow, run by hand, builds it for x64 and arm64, requires a helper linked against it to give the same objects as one linked against the release archive (scripts/check-llvm-dist.mjs), prints both helpers' times and the profile's mismatch count, and attaches the archive to the LLVM_DIST_TAG release of this repository. - The release workflow's Linux jobs, and the wasm32-wasi job, which also uploads the x64 GNU helper, download that archive and build the helper with SCRIPTC_LLVM_THINLTO=1: clang, lld and ThinLTO, and the profile for the helper's own sources. Without the archive, or if that build fails, the helper links the release archive as before. - The four Linux helper packages share their build in native/llvm-codegen/linux-helper.mjs. Without SCRIPTC_LLVM_THINLTO it builds the same executable as before.
21 lines
812 B
JavaScript
21 lines
812 B
JavaScript
#!/usr/bin/env node
|
|
import { buildLinuxHelper } from "../../../native/llvm-codegen/linux-helper.mjs";
|
|
import { readFileSync } from "node:fs";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
const repo = fileURLToPath(new URL("../../..", import.meta.url));
|
|
if (process.platform !== "linux" || process.arch !== "arm64") {
|
|
process.stdout.write("@scriptc/llvm-linux-arm64-gnu: skipped on this host\n");
|
|
process.exit(0);
|
|
}
|
|
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
buildLinuxHelper({
|
|
arch: "arm64",
|
|
libc: "gnu",
|
|
version: manifest.version,
|
|
build: join(repo, "node_modules/.cache/scriptc-llvm-linux-arm64-gnu"),
|
|
output: join(root, "bin", "scriptc-llvm-codegen"),
|
|
});
|