e406d07d81
Tasks 4-7 on the Boss-Repaired plan, completing the M1 iteration: - Task 4: check-side export-signature gate — CheckError variants ExportNonScalarSignature / ExportHasEffects (codes export-non-scalar-signature / export-has-effects), code() arms, check_fn gate (params->ret->effects, first-violation-wins, unconditional on f.export.is_some()). The clause-3 discriminator in code: effectful/non-scalar exports fail to typecheck. 6/6. - Task 5: codegen Target::StaticLib — Target enum, threaded param, @main/MissingEntryMain gated behind Target::Executable, one external @<sym> forwarder per export to @ail_<module>_<fn> (fn_scalar_sig/llvm_scalar). In-source missing_entry_main_is_error byte-unchanged. Lowering pin 2/2. - Task 6: CLI ail build --emit=staticlib — clap field, Cmd::Build branch, build_staticlib (verbatim build_to prefix + has_export guard + two-archive clang -c/ar rcs tail) + run_cmd. CLI pin 2/2. - Task 7: C-host E2E coherent-stop proof (cc links libembed_backtest_step.a + libailang_rt.a, backtest_step(0,3)=9 / (9,4)=25, s==25, exit 0) + DESIGN.md §"Embedding ABI (M1)" (scalar C ABI, provisional until M3). E2E pin 1/1. Independent Boss verification: E2E 1/1, gate 6/6, full workspace 0 failures, roundtrip_cli + design_schema_drift + spec_drift green, Invariant 1 holds (no new dep in core/codegen/runtime). 3 behaviour- neutral plan pseudo-vs-reality concerns in the journal. Default-exe codegen/runtime path byte-unchanged (check.py firing = tracked-P2 known-noise, audit-adjudicated). INDEX line added. Completes the M1 iteration (impl). Milestone-close audit + fieldtest (surface-touching) are the next pipeline steps.
58 lines
2.2 KiB
Rust
58 lines
2.2 KiB
Rust
//! Embedding-ABI M1 CLI (spec §5): `ail build --emit=staticlib`
|
|
//! produces `lib<entry>.a` (program-only) + a separate
|
|
//! `libailang_rt.a`, and emits NO executable / NO `@main`.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
fn ail_bin() -> &'static str { env!("CARGO_BIN_EXE_ail") }
|
|
fn ws_root() -> PathBuf {
|
|
Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.parent().unwrap().parent().unwrap().to_path_buf()
|
|
}
|
|
|
|
#[test]
|
|
fn staticlib_emit_produces_two_archives() {
|
|
let fixture = ws_root().join("examples").join("embed_backtest_step.ail");
|
|
let outdir = std::env::temp_dir()
|
|
.join(format!("ail-embed-cli-{}", std::process::id()));
|
|
std::fs::create_dir_all(&outdir).unwrap();
|
|
|
|
let out = Command::new(ail_bin())
|
|
.args([
|
|
"build", fixture.to_str().unwrap(),
|
|
"--emit=staticlib",
|
|
"-o", outdir.to_str().unwrap(),
|
|
])
|
|
.output().expect("ail build --emit=staticlib");
|
|
assert!(out.status.success(),
|
|
"staticlib build failed: stdout={} stderr={}",
|
|
String::from_utf8_lossy(&out.stdout),
|
|
String::from_utf8_lossy(&out.stderr));
|
|
|
|
assert!(outdir.join("libembed_backtest_step.a").exists(),
|
|
"expected libembed_backtest_step.a in {outdir:?}");
|
|
assert!(outdir.join("libailang_rt.a").exists(),
|
|
"expected separate libailang_rt.a in {outdir:?}");
|
|
}
|
|
|
|
#[test]
|
|
fn staticlib_emit_requires_an_export() {
|
|
// embed_noentry_baseline has no `(export …)` fn.
|
|
let fixture = ws_root().join("examples")
|
|
.join("embed_noentry_baseline.ail");
|
|
let outdir = std::env::temp_dir()
|
|
.join(format!("ail-embed-noexp-{}", std::process::id()));
|
|
std::fs::create_dir_all(&outdir).unwrap();
|
|
let out = Command::new(ail_bin())
|
|
.args(["build", fixture.to_str().unwrap(),
|
|
"--emit=staticlib", "-o", outdir.to_str().unwrap()])
|
|
.output().expect("ail build");
|
|
assert!(!out.status.success(),
|
|
"staticlib build with zero exports must fail");
|
|
assert!(String::from_utf8_lossy(&out.stderr)
|
|
.contains("at least one `(export"),
|
|
"expected the zero-export staticlib error; got {}",
|
|
String::from_utf8_lossy(&out.stderr));
|
|
}
|