dbd76e5503
bugfix-swarm-rc-alloc-undercount, GREEN stage. RED is the separate audit-trail commit483117d. Root cause of the m5.2-resume-attempt residual: ail-embed/build.rs declared cargo:rerun-if-changed only for the kernel .ail + build.rs itself — NOT the runtime/ C sources ail build --emit=staticlib compiles into libailang_rt.a. Cargo never re-ran build.rs after the atomic-counter fix7bfa11e, so ail-embed kept linking a stale pre-7bfa11e non-atomic libailang_rt.a; the swarm's concurrent TLS-NULL host allocs raced the stale non-atomic g_rc_alloc_count++ (frees-stable/allocs-jitter). NOT a second runtime bug and NOT test-methodology unsoundness — runtime/rc.c at HEAD is correct; the isolated crates/ail RED was green only because it rebuilds the staticlib fresh per run. Fix (ail-embed/build.rs, +7 lines): directory-level cargo:rerun-if-changed=<repo>/runtime (Cargo recurses mtimes under the dir). Preferred over a per-file list — the implementer inspected crates/ail build_staticlib (libailang_rt.a = ar(rc.o, str.o), both under runtime/) and chose the directory mechanism so any future runtime source cannot silently re-introduce the same staleness. Existing kernel/build.rs/AIL_BIN rerun-if-changed lines kept. Cohesive consequence (in-scope): symbol_fan_swarm_leak_free un-#[ignore]d — the test BODY is byte-for-byte unchanged (it was quarantined, never weakened); the module-doc + fn-doc breadcrumbs rewritten to the resolved build-dep-staleness rationale. It is now the integration-level acceptance of both7bfa11eand this fix. Boss also removed a pre-existing unused `DataFormat` import in swarm.rs inline (trivial; the file is committed this iter regardless; warning-clean after). Boss-verified independently: RED rt_archive_freshness -> GREEN; swarm determinism 5/5 (symbol_fan_swarm_leak_free + symbol_fan_swarm_bit_exact GREEN every run, 0 ignored, jitter gone, Sallocs==Sfrees==12000003); isolated embed_rc_global_stats_race still GREEN (untouched, runtime untouched); Invariant 1 data-server count 0; scope = ail-embed/build.rs + ail-embed/tests/swarm.rs + journal + stats only. The M5 swarm leak-proof bounce-back is fully resolved end-to-end. M5 stays open [~]; m5.3 (time-shard + friction-harvest + close-out) remains. Includes the per-iter journal, stats, and INDEX.md line.
63 lines
2.6 KiB
Rust
63 lines
2.6 KiB
Rust
//! Emits the M3-frozen kernel staticlib and links it.
|
|
//!
|
|
//! Resolution of the `ail` binary has no in-repo precedent (the
|
|
//! in-test mechanism `env!("CARGO_BIN_EXE_ail")` is unavailable to a
|
|
//! workspace-excluded crate's build script): use `$AIL_BIN` if set,
|
|
//! else `cargo build --manifest-path <repo>/Cargo.toml -p ail` and
|
|
//! use `<repo>/target/debug/ail`. The AILang workspace target dir
|
|
//! (`<repo>/target`) is distinct from this crate's
|
|
//! (`ail-embed/target`), so the nested `cargo build` cannot deadlock
|
|
//! on the outer build's lock.
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
let manifest = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
|
let repo = manifest.parent().unwrap().to_path_buf(); // /home/brummel/dev/ailang
|
|
let kernel = repo.join("examples/embed_backtest_step_tick.ail");
|
|
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
|
|
println!("cargo:rerun-if-changed={}", kernel.display());
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
// `ail build --emit=staticlib` compiles libailang_rt.a from the
|
|
// runtime C sources (rc.c + str.c — see crates/ail build_staticlib).
|
|
// Track the whole `runtime/` directory (Cargo recurses mtimes
|
|
// under a directory path) so any runtime change relinks the
|
|
// archive. A per-file list would silently re-introduce staleness
|
|
// for any future runtime source; the directory mechanism cannot.
|
|
println!("cargo:rerun-if-changed={}", repo.join("runtime").display());
|
|
println!("cargo:rerun-if-env-changed=AIL_BIN");
|
|
|
|
let ail_bin: PathBuf = match env::var("AIL_BIN") {
|
|
Ok(p) => PathBuf::from(p),
|
|
Err(_) => {
|
|
let status = Command::new("cargo")
|
|
.args(["build", "--manifest-path"])
|
|
.arg(repo.join("Cargo.toml"))
|
|
.args(["-p", "ail"])
|
|
.status()
|
|
.expect("spawn `cargo build -p ail`");
|
|
assert!(status.success(), "building the `ail` CLI failed");
|
|
repo.join("target/debug/ail")
|
|
}
|
|
};
|
|
|
|
let build = Command::new(&ail_bin)
|
|
.arg("build")
|
|
.arg(&kernel)
|
|
.args(["--emit=staticlib", "-o"])
|
|
.arg(&out_dir)
|
|
.output()
|
|
.expect("spawn `ail build --emit=staticlib`");
|
|
assert!(
|
|
build.status.success(),
|
|
"ail build --emit=staticlib failed:\n{}",
|
|
String::from_utf8_lossy(&build.stderr)
|
|
);
|
|
|
|
println!("cargo:rustc-link-search=native={}", out_dir.display());
|
|
println!("cargo:rustc-link-lib=static=embed_backtest_step_tick");
|
|
println!("cargo:rustc-link-lib=static=ailang_rt");
|
|
}
|