nx_buildmode_lib.nx
buildroot/runtime/nx_buildmode_lib.nx
about
nx_buildmode_lib.nx -- THE COMPILE MODE THE BUILD LANE USES, AS DATA (LN44, 2026-09-03).
THE GAP THIS CLOSES, measured. No build lane in this estate passes `--mode` at all: a grep for it across
the build-lane sources returns one hit and it is a GATE, not a builder. So every organ ships compiled in
DEFAULT, which by deliberate contract has every declared mode OFF -- including `--bckelide`, LN7 sound
bounds-check elision, which is already written, already promoted, and already proven by
nx_bck_elide_gate 13/13 against the live compiler with both out-of-bounds legs still trapping 71.
Cost of that omission, measured two independent ways: the published h2h receipt reads default 7105 us
against f1 4189 us on the same workload (1.70x), and a 15-round interleaved re-measure on a quiet host
reads 8275 us against 5210 us (1.59x). On a divide-dominated loop the same pair is 45807 against 44851,
i.e. NEUTRAL -- the mode wins where it can and costs nothing where it cannot.
WHY THIS IS A BUILD-LANE POLICY AND EMPHATICALLY NOT A COMPILER-DEFAULT CHANGE. nx_compile_x86 states
the contract in its own source: default builds stay BYTE-IDENTICAL BY CONSTRUCTION, which is exactly
what every drift, contentdiff and artifact-comparison instrument in the estate rests on. Flipping the
language default would re-baseline ALL of those instruments in the same instant -- so the undo path
would run straight through the comparison surface needed to judge whether the change was safe. That is
the static-stability violation this estate already has doctrine about. The mode therefore moves
PER TARGET, declared here, provable one organ at a time.
THE SAFETY PROPERTY, AND IT IS THE WHOLE DESIGN: an ABSENT conf, an absent row, or an empty flag list
yields ZERO flags AND contributes ZERO bytes to the build-cache key. Adopting this lib therefore cannot
change one byte of one artifact until somebody writes a row. There is no flag day.
⚠ THE CACHE KEY IS PART OF THE CONTRACT, NOT AN AFTERTHOUGHT. nx_sov_build_run caches artifacts under
sha256(expanded closure ++ compilerSha ++ asmSha ++ 'g'|'n'). A mode that changed the emitted code
WITHOUT entering that key would serve a stale artifact compiled under the other mode -- silently, and
looking like a cache hit. bm_key_token exists so the mode enters the key by construction, and the gate
asserts that two different modes produce two different tokens.
Row grammar, one per line, first match wins:
target|<name>|<flags...> the mode for exactly this build target
all|<flags...> the mode for every target that has no row of its own
`#` and `;` start a comment. Flags are passed to the compiler verbatim and are exactly the tokens its
own driver already parses -- this lib can never invent a switch the compiler does not have.
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_buildmode_gate.nx
structs
| none |
consts
| 38 | const BM_CONF: *u8 = "knowledge/build_modes.conf" |
| 39 | const BM_CONF_ALT: *u8 = "../knowledge/build_modes.conf" |
| 40 | const BM_BUF: i64 = 65536 |
| 41 | const BM_FLAGS_CAP: i64 = 512 |
| 42 | const BM_NL: i64 = 10 |
| 43 | const BM_BAR: i64 = 124 |
| 44 | const BM_HASH: i64 = 35 |
| 45 | const BM_SEMI: i64 = 59 |
| 46 | const BM_SP: i64 = 32 |
| 47 | const BM_TAB: i64 = 9 |
functions
| 49 | func bm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: bm_flags_for |
| 50 | func bm_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 65 | func bm_field(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64 called by 1: bm_flags_for |
| 90 | func bm_streq(a: *u8, b: *u8) -> i64 called by 1: bm_flags_for |
| 99 | func bm_flags_for(target: *u8, out: *u8) -> i64 |
| 143 | func bm_key_token(target: *u8, out: *u8) -> i64 { return bm_flags_for(target, out) } |
| 146 | func bm_split(flags: *u8, store: *u8, slots: *i64, cap: i64) -> i64 called by 1: main |