Repository navigation
Expand file tree
/
Copy pathbuild.yo
More file actions
66 lines (61 loc) · 3.2 KB
/
Copy pathbuild.yo
File metadata and controls
66 lines (61 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Build the Yo compiler with its own build system.
//!
//! P2.2 of `plans/archive/SELF_HOSTING_COMPLETION.md`: this file makes `yo build` the
//! canonical way to build the compiler — it replaced both `bun run build` (the
//! retired TypeScript reference) and the raw `yo compile src/main.yo
//! --optimize 2` invocation — and doubles as the P1 build-system parity
//! acceptance test.
//!
//! Steps:
//! yo build → compile the self-hosted compiler (install step)
//! yo build test → run the FAST language suite: tests/internal (each
//! of its 58 files compiles the whole compiler) and
//! tests/cli-cases (differential fixtures, not
//! standalone tests) are excluded via
//! TestSuite.exclude — same set as the CI fast-suite
//! jobs' `yo test ./tests --exclude ...` invocation.
build :: import("std/build");
// ReleaseSafe maps to plain `-O2` — byte-for-byte the flags of today's
// canonical `yo compile src/main.yo --optimize 2` build (see
// optimize_level_for in src/build_runner.yo: release-safe → "2", and only
// the Debug level forwards --debug-symbols). This file used ReleaseSmall
// for exactly that -O2 identity while release-small ALSO mapped to "2";
// release-small is the size-oriented -Os it always claimed to be
// (issues/fixed/build-release-small-is-identical-to-release-safe.md), so
// the plain -O2 build moved here.
// NOT Debug: a -O0 compiler binary hits the 1 GiB main-stack ceiling on deep
// comptime recursion (AGENTS.md "Common Pitfalls").
// Allocator per HOST platform, matching the settled release-bundle decisions:
// macOS measured vendored mimalloc v3 slower AND fatter than libsystem, so the
// macOS bundles ship `system` (release.yml seed-cross-emit matrix); Windows
// dropped mimalloc entirely (plans/reference/WINDOWS_ALLOCATOR_DECISION.md). Linux keeps
// mimalloc — the bundles are musl-only and musl's malloc is far slower — and
// that matches the Linux CI legs' explicit `--allocator mimalloc`.
// Re-measured 2026-08-22 (M4, `check ./src --std-path ./std`): mimalloc-v3
// binary 225.6 s / 16.0 GB footprint vs system 97.5 s / 14.4 GB — the v3
// abandoned-page reclaim-on-free path alone was ~40% of user CPU
// (issues/fixed/macos-yo-build-still-mimalloc-despite-settled-decision.md).
host_allocator :: cond(
(
(build.target_host == build.CompilationTarget.X86_64_Unknown_Linux_Gnu)
|| (build.target_host == build.CompilationTarget.X86_64_Unknown_Linux_Musl)
|| (build.target_host == build.CompilationTarget.Aarch64_Unknown_Linux_Gnu)
|| (build.target_host == build.CompilationTarget.Aarch64_Unknown_Linux_Musl)
) => build.AllocatorKind.Mimalloc,
true => build.AllocatorKind.System
);
yo_exe :: build.executable({
name : "yo",
root : "./src/main.yo",
optimize : build.Optimize.ReleaseSafe,
allocator : host_allocator
});
tests :: build.test({
name : "language-tests",
root : "./tests/",
exclude : "tests/internal,tests/cli-cases"
});
install :: build.step("install", "Build the self-hosted compiler");
install.depend_on(yo_exe);
test_step :: build.step("test", "Run the language test suite");
test_step.depend_on(tests);