code wiki / (root) / nx_ccgate_lib.nx

nx_ccgate_lib.nx

buildroot/runtime/nx_ccgate_lib.nx

10294 B244 linesdepth 3pulls 3 transitivereach 11 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_ccgate_lib.nx -- THE ONE compiler-gate driver: fork/exec a toolchain compiler on a fixture with an optional mode flag, assemble with nxasm, run the fixture by phase, read back stderr captures. Extracted 2026-08-23 from the LN3 gate (nx_boundscheck_gate, whose helpers it reproduces verbatim in behaviour) the day a SECOND and THIRD compiler-mode gate needed them (nx_chkarith_gate for LN1, nx_opt_eqsat_wire_gate for LN8): three private copies of one driver is the duplicate-ruler defect, and a fix to the driver (e.g. the noexec-/tmp placement lesson) must land once. CONVENTIONS CARRIED (all measured in the LN3 gate's record): * data captures (.s, .err) live in /tmp/<gate>/; every ELF THAT MUST RUN lives under _build/ -- the NAS mounts /tmp noexec (execve EACCES 126), so a runnable staged in /tmp passes its compile teeth and fails every run tooth with no diagnostic; * per-run-unique names carry the gate's pid (two concurrent runs racing one rename source is a documented incident class); * ccg_build returns phase codes (0 ok, 1 compile-fail, 2 asm-fail, 3 rename-fail) that the gate PRINTS before its teeth -- a FAIL-only tooth cannot say why; * ccg_anchor_root chdirs into buildroot when the tools-API exec lane starts the gate in the serving root (whose _offc carries no compiler); the laptop lane misses the probe and stays put. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 11 importers

nx_syscalls.nx nx_gate_verdict.nx nx_ccgate_lib.nx nx_chkarith_gate.nx nx_langspec.nx nx_langspec_gate.nx nx_mgmt_gaterun_gate.nx nx_opt_eqsat_wire_gate.nx nx_optenforce_gate.nx nx_osattest.nx nx_osattest_gate.nx nx_ownership_gate.nx nx_srcfmt_gate.nx

diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.

imports: nx_syscalls.nxnx_gate_verdict.nx

imported by: nx_chkarith_gate.nxnx_langspec.nxnx_langspec_gate.nxnx_mgmt_gaterun_gate.nxnx_opt_eqsat_wire_gate.nxnx_optenforce_gate.nxnx_osattest.nxnx_osattest_gate.nxnx_ownership_gate.nxnx_srcfmt_gate.nxnx_x86_regalloc_use_gate.nx

structs

none

consts

22const CCG_PATH_CAP: i64 = 128 // per-run artifact path buffer; every path here is < 64 bytes
23const CCG_MODE_RW: i64 = 0x1a4 // 0644 capture files
24const CCG_MODE_X: i64 = 0x1ed // 0755 runnables and the /tmp/<gate> dir

functions

27func ccg_run(path: *u8, argv: *i64, redir_out: i64, redir_err: i64) -> i64
43func ccg_path(pfx: *u8, pid: i64, sfx: *u8) -> *u8
73func ccg_compile(cc: *u8, flag: *u8, src: *u8, s_tmp: *u8, err_out: *u8) -> i64
88func ccg_build(cc: *u8, flag: *u8, src: *u8, s_tmp: *u8, elf_out: *u8, err_out: *u8, asm_tmp: *u8) -> i64
105func ccg_phase(elf: *u8, phase: *u8) -> i64
121func ccg_phase_to(elf: *u8, phase: *u8, out_path: *u8, err_path: *u8) -> i64
136func ccg_file_has(path: *u8, needle: *u8) -> i64
170func ccg_file_count_lines_with2(path: *u8, n1: *u8, n2: *u8) -> i64
202func ccg_mem_has(b: *u8, lo: i64, hi: i64, needle: *u8, nl: i64) -> i64
225func ccg_val(name: *u8, v: i64) -> i64
called by 7: mainmainmainmainmainmain+1 calls 2: gv_putsgv_num
237func ccg_anchor_root() -> i64
244func ccg_pid() -> i64 { return __syscall(172, 0, 0, 0, 0, 0, 0) }