Repository navigation
Expand file tree
/
Copy pathCargo.toml
More file actions
156 lines (147 loc) · 7.44 KB
/
Copy pathCargo.toml
File metadata and controls
156 lines (147 loc) · 7.44 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
[workspace]
members = [
"parser",
"compiler",
"compiler/bsym",
"diagnostics",
"source_map",
"runtime",
"runtime-core",
"gpu",
"gpu/plugin",
"window",
"lsp",
"plugin",
"nue-plugins",
"rayzor-tensors",
"wasm-opt-helper",
"snapshot-gen"
]
# runtime-wasm is excluded from workspace — built separately for wasm32-wasip1
exclude = [
"cranelift-fork",
"ci/macro-e2e",
"runtime-wasm"
]
[package]
name = "rayzor"
version = "0.1.0"
edition = "2024"
[features]
# LLVM backend ON by default: the LLVM tier (auto-upgrade after main entry)
# must be available without an opt-in flag. LLVM 21 is a required toolchain
# dependency, not optional — and `--no-default-features` does NOT drop it,
# since the `compiler` dependency below carries its own default features.
# Cranelift-only is a shape of that crate, not of this binary.
#
# Two release shapes, because LLVM is most of the binary — 223 MB linked
# statically against 51 MB linked shared:
#
# cargo build --release
# Links the system libLLVM. The default, for anything with a package
# manager behind it (homebrew, apt, a dev checkout) since it can depend
# on llvm@21, and for distros whose `llvm-<v>-dev` lists Polly as a
# static component but ships no libPolly.a (Debian/Ubuntu).
#
# cargo build --release --no-default-features --features llvm-static
# Links LLVM's component archives into the binary. For a standalone
# download: LLVM's C++ ABI does not hold across major versions, so a
# shared-linked binary needs a version-matched libLLVM already present.
default = ["llvm-backend", "llvm-dynamic", "lsp"]
# The language server. On by default so a normal build still answers
# `rayzor lsp`; optional so CI jobs that only need the compiler can skip it
# with `--no-default-features --features llvm-backend,llvm-dynamic`. It pulls
# lsp-server, lsp-types, fluent-uri and a serde_repr proc-macro that nothing
# else in the binary needs, and the `Lsp` subcommand is the single call site.
lsp = ["dep:rayzor-lsp"]
llvm-backend = ["compiler/llvm-backend"]
llvm-dynamic = ["compiler/llvm-dynamic"]
# The self-contained shape. Nothing to enable — LLVM links statically when
# `llvm-dynamic` is absent — so this only names the build, which is why it
# has to be reached through `--no-default-features`.
# `lsp` is included here on purpose: this is the standalone download, and the
# language server was part of it before the dependency became optional.
# Dropping a shipped subcommand is not something a build-time speedup should
# do quietly, so the packaged shape names it explicitly.
llvm-static = ["llvm-backend", "lsp"]
# Heap + CPU profiler. Off by default; see rayzor-runtime's `profile`
# feature for details. Activate with `cargo build --release --features profile`
# then use RAYZOR_DUMP_ALLOC_AT_EXIT / RAYZOR_ALLOC_GRAPH / RAYZOR_CPU_PROFILE.
profile = ["rayzor-runtime/profile"]
# jemalloc under the standard malloc/free names, so the compiler, the runtime
# and JIT'd code (which binds `malloc`/`free` by name) share one allocator that
# returns freed pages, without re-executing under LD_PRELOAD.
[target.'cfg(target_os = "linux")'.dependencies]
tikv-jemalloc-sys = { version = "0.6", features = ["unprefixed_malloc_on_supported_platforms"] }
[dependencies]
parser = { path = "parser" }
compiler = { path = "compiler" }
diagnostics = { path = "diagnostics" }
rayzor-runtime = { path = "runtime" }
clap = { version = "4.5", features = ["derive"] }
libloading = "0.8"
rayzor-plugin = { path = "plugin" }
ratatui = "0.29"
crossterm = "0.28"
postcard = { version = "1.0", features = ["alloc"] }
rayzor-lsp = { path = "lsp", optional = true }
anyhow = "1"
walkdir = "2"
libc = "0.2"
# Binaryen wasm-opt post-pass (default-on): coalesces the per-SSA-value
# local.set/local.get round-trips the wasm_backend emits (wasmtime does not
# fully coalesce them) — a verified ~3x bit-exact speedup on the Q4 kernel.
#
# The bundled `wasm-opt = "0.116"` crate is deliberately NOT a dependency of
# THIS bin — it compiles Binaryen into the binary, and Binaryen exports ~1890
# `llvm::` ADT symbols (incl. llvm::SmallVectorBase::grow_pod) that ODR-collide
# with LLVM 21 (llvm-sys 211) and corrupt the LLVM JIT/AOT backend (6GB-alloc
# SIGSEGV in Module::print). Instead, the workspace member `wasm-opt-helper`
# links Binaryen as a SEPARATE binary `rayzor-wasm-opt`; src/wasm_cmd.rs spawns
# it as a subprocess (resolution: RAYZOR_WASM_OPT_BIN → `rayzor-wasm-opt` next
# to the rayzor exe → `rayzor-wasm-opt`/`wasm-opt` on PATH; falls back to the
# unoptimized module if none is found). Ship both binaries side-by-side.
# Workspace release profile. `lto = "thin"` enables cross-crate inlining so
# `rayzor-runtime` hot-path callsites continue to inline through the per-arch
# SIMD primitives now hosted in `rayzor-runtime-core`. Without this, the
# function-call boundary across crates costs ~8% on Llama 3.2 1B Q4_K_M
# decode. Thin LTO adds ~20% to release build time; full LTO would be cleaner
# but adds another ~30%. The existing [profile.release] blocks inside per-crate
# Cargo.toml files are silently ignored by cargo (see the workspace warning);
# this is the only place release-profile changes take effect.
[profile.release]
opt-level = 3
lto = "thin"
# Compiler crate stays at opt-level=2: workaround for an LLVM optimizer bug
# that causes infinite loops in release builds when lowering TAST expressions.
[profile.release.package.compiler]
opt-level = 2
# NOTE: the wasm-opt-helper crate links Binaryen (a large vendored C++ codebase)
# and inherits the workspace `lto = "thin"`. There's nothing to cross-inline for
# a standalone subprocess binary, so the LTO is wasted build time — but cargo
# does NOT allow `lto` in a per-`package` profile override (only at profile
# level), so we can't disable it just for this crate. It's a rare rebuild
# (Binaryen is cached after the first compile), so we leave it.
# Cranelift 0.133.0 isn't on crates.io yet — sourced from upstream
# bytecodealliance/wasmtime `release-46.0.0` (the macOS cranelift-object
# fix is merged upstream; this branch carries the 0.133 codegen that
# rayzor's native backend targets). wasmtime + wasmtime-wasi are pinned
# to the SAME branch in compiler/Cargo.toml so wasmtime-cranelift uses
# this exact cranelift — otherwise the resolver drops the JIT compiler
# and wasmtime silently falls back to the Pulley interpreter (~50x
# slower). Drop this block once 0.133 lands on crates.io.
[patch.crates-io]
cranelift = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime", rev = "60154144" }
# inkwell 0.7.1 still calls LLVMConstMul and its NSW/NUW variants, which LLVM 21
# removed. Nothing here references those methods, so a normal build never links
# them — but a test binary pulls in the object file that contains them and the
# link fails on an undefined symbol. Thin LTO lets the optimizer drop the dead
# code before the linker looks for it.
[profile.test]
lto = "thin"