nx_ccbuild_lib.nx
buildroot/runtime/nx_ccbuild_lib.nx
about
nx_ccbuild_lib.nx -- LIB: COMPILE A SOURCE WITH A NAMED COMPILER, THEN RUN IT.
WHY THIS EXISTS. Every compiler gate needs the same four moves: fork/exec a
chosen cc, assemble+link its output sovereignly, make the product executable,
and run it capturing status. nx_cc_equiv_gate had the only correct copy, and
the next gate that needed it (nx_linecont_gate, LN15) would have COPIED it --
which is the duplicate-ruler defect: two spellings of one invariant that drift
silently. nx_spendgate/nx_capsearch over 6,925 organs (corpus_complete=1)
returned NO incumbent exposing this primitive, so it is extracted here once.
The bodies below are VERBATIM from nx_cc_equiv_gate's eq_* helpers so the
migration of that gate onto this lib is provably neutral: its oracle is its own
published verdict, rows=10 passed=10 selfhost=1 -- anything else means the
extraction changed behaviour and must be reverted, not argued with.
EVERY CORRECTION THAT LIVED IN THOSE HELPERS IS CARRIED, NOT RE-LEARNED:
* nxasm writes 0644, so the product is NOT EXECUTABLE and every exec dies 127.
Both sides dying identically made two failures agree and READ AS AN
EQUIVALENCE. The fchmodat is load-bearing; do not drop it.
* a failed rename used to be DISCARDED, so elf_out went missing while the
build still returned 0 and the downstream 127 looked like a compiler fault.
* the compiler's stderr must go to a REAL log, never /dev/null: a gate that
reports a failure without its diagnostic makes the failure unactionable.
* every source path is relative to the buildroot, so a caller with a different
cwd (nx_job_run fixes cwd at ~/nishihost) fails to FIND its sources and every
row reports build-failed -- which reads as a broken compiler when nothing is
wrong. cb_anchor_root exists to make that impossible; call it FIRST.
ONE DELIBERATE CHANGE FROM THE ORIGINAL: eq_build carried an `o_tmp` parameter
its body never read. It is dropped here rather than carried forward, and the
neutrality of dropping it is exactly what the equiv gate's re-run proves.
dependencies 1 imports · 15 importers
diagram shows first 10 each side; +0 more imports, +5 more importers in the complete lists below.
imports: nx_syscalls.nx
imported by: nx_bck_elide_gate.nxnx_bck_iv_gate.nxnx_chkarith_jo_gate.nxnx_deploy_stage_cli_driver_t188.nxnx_deploy_stage_driver_t188.nxnx_descriptor_driver_t188.nxnx_f64_gate.nxnx_field_type_gate_t280.nxnx_gram_compiler_gate_t280.nxnx_import_qualified_gate.nxnx_linecont_gate.nxnx_ownership_gate.nxnx_signal_driver_t188.nxnx_stage_cli_canonical_gate_t188.nxnx_waitrc_gate.nx
structs
| none |
consts
| none |
functions
| 37 | func cb_run(path: *u8, argv: *i64, envp: *i64, redir_out: i64, redir_err: i64) -> i64 |
| 51 | func cb_fsize(path: *u8) -> i64 |
| 63 | func cb_build(cc_path: *u8, src_path: *u8, s_tmp: *u8, |
| 81 | func cb_build_flag(cc_path: *u8, src_path: *u8, s_tmp: *u8, called by 5: mainmaincb_buildmainmain calls 6: sys_mmapsys_openat_wrcb_runsys_closesys_renameatsys_fchmodat |
| 109 | func cb_run_capture(elf: *u8, out_path: *u8, envp: *i64, devnull: i64) -> i64 |
| 119 | func cb_files_equal(pa: *u8, pb: *u8) -> i64 |
| 150 | func cb_anchor_root() -> i64 |