Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"run:linux": "docker run --rm -v \"$PWD:/root/bun/\" -w /root/bun ghcr.io/oven-sh/bun-development-docker-image",
"uv-posix-stubs": "bun run src/jsc/bindings/libuv/generate_uv_posix_stubs.ts",
"bump": "bun ./scripts/bump.ts",
"orderfile": "bun scripts/orderfile/generate.ts",
"jsc:build": "bun scripts/build.ts --profile=release-local --build-dir=build/release-local --target=WebKit",
"jsc:build:debug": "bun scripts/build.ts --profile=debug-local --build-dir=build/debug-local --target=WebKit",
"jsc:build:lto": "bun scripts/build.ts --profile=release-local --lto=on --build-dir=build/release-local-lto --target=WebKit",
Expand Down
45 changes: 42 additions & 3 deletions scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ import { readFileSync } from "node:fs";
import { join } from "node:path";
import {
downloadArtifacts,
inheritOrderFile,
isCI,
orderFileEligible,
packageAndUpload,
printEnvironment,
regenerateOrderFile,
reportOrderFileFailure,
shouldGenerateOrderFile,
spawnWithAnnotations,
startGroup,
uploadArtifacts,
verifyOrderFileApplied,
} from "./build/ci.ts";
import { formatConfig, formatConfigUnchanged, type PartialConfig } from "./build/config.ts";
import { configure, type ConfigureInput, type ConfigureResult } from "./build/configure.ts";
Expand Down Expand Up @@ -124,9 +130,42 @@ async function main(): Promise<void> {
await startGroup("Download artifacts", () => downloadArtifacts(result.cfg));
}

await startGroup("Build", () =>
spawnWithAnnotations("ninja", ninjaArgv(result.cfg), { label: "ninja", env: ninjaEnv(result.cfg, result.env) }),
);
// Builds that don't trace their own binary link against the last successful
// build's order file. Must land before ninja: it is a link input.
if (orderFileEligible(result.cfg) && !shouldGenerateOrderFile(result.cfg)) {
await startGroup("Inherit symbol order file", () => inheritOrderFile(result.cfg));
}

const runNinja = () =>
spawnWithAnnotations("ninja", ninjaArgv(result.cfg), { label: "ninja", env: ninjaEnv(result.cfg, result.env) });

await startGroup("Build", runNinja);

// Release (and [generate symbol order]) trace the binary they just linked
// and relink against the result. Overwriting the order file dirties exactly
// one ninja edge — the link — so this second pass relinks and nothing else.
// The order file is an optimization, not correctness: a flaky trace workload
// must not fail a release build 40 minutes in. Link unordered, loudly.
if (shouldGenerateOrderFile(result.cfg)) {
let traced = true;
await startGroup("Generate symbol order file", () => {
try {
regenerateOrderFile(result.cfg);
} catch (error) {
traced = false;
reportOrderFileFailure(error as Error);
}
});
if (traced) {
await startGroup("Relink against symbol order file", runNinja);
// We traced this exact binary: every symbol must resolve. Hard-fail.
if (result.output.exe) verifyOrderFileApplied(result.cfg, result.output.exe);
}
} else if (orderFileEligible(result.cfg) && result.output.exe) {
// Inherited: report how much of it still resolved (code moved since), but
// a stale file is a slower binary, not a broken one — never fail here.
verifyOrderFileApplied(result.cfg, result.output.exe, { strict: false });
}

// cpp-only/rust-only: upload build outputs for downstream link-only.
// link-only: package + upload zips for downstream test steps.
Expand Down
Loading
Loading