nx_ccgate_lib.nx
buildroot/runtime/nx_ccgate_lib.nx
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
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
| 22 | const CCG_PATH_CAP: i64 = 128 // per-run artifact path buffer; every path here is < 64 bytes |
| 23 | const CCG_MODE_RW: i64 = 0x1a4 // 0644 capture files |
| 24 | const CCG_MODE_X: i64 = 0x1ed // 0755 runnables and the /tmp/<gate> dir |
functions
| 27 | func ccg_run(path: *u8, argv: *i64, redir_out: i64, redir_err: i64) -> i64 |
| 43 | func ccg_path(pfx: *u8, pid: i64, sfx: *u8) -> *u8 |
| 73 | func ccg_compile(cc: *u8, flag: *u8, src: *u8, s_tmp: *u8, err_out: *u8) -> i64 |
| 88 | func ccg_build(cc: *u8, flag: *u8, src: *u8, s_tmp: *u8, elf_out: *u8, err_out: *u8, asm_tmp: *u8) -> i64 called by 6: mainspec_conformance_runmainmainmainmain calls 5: ccg_compilesys_mmapccg_runsys_renameatnx_chmod |
| 105 | func ccg_phase(elf: *u8, phase: *u8) -> i64 |
| 121 | func ccg_phase_to(elf: *u8, phase: *u8, out_path: *u8, err_path: *u8) -> i64 |
| 136 | func ccg_file_has(path: *u8, needle: *u8) -> i64 |
| 170 | func ccg_file_count_lines_with2(path: *u8, n1: *u8, n2: *u8) -> i64 |
| 202 | func ccg_mem_has(b: *u8, lo: i64, hi: i64, needle: *u8, nl: i64) -> i64 |
| 225 | func ccg_val(name: *u8, v: i64) -> i64 |
| 237 | func ccg_anchor_root() -> i64 |
| 244 | func ccg_pid() -> i64 { return __syscall(172, 0, 0, 0, 0, 0, 0) } |