feat(C1.2): persistent content-addressed cache for compiled #source units

compileCToObjects now probes .sx-cache/c-<key>.o before invoking the
embedded clang and writes fresh objects back (per-pid temp + copy, the
main object cache's pattern). Default on for both JIT and AOT — the
temp-compile-and-delete behavior it replaces was strictly worse. A
cached entry must carry an object-file magic (Mach-O/ELF) or it falls
back to a fresh compile; no cache failure can fail a build. Cold/warm
verified via --time: the object compile disappears on the warm run.
This commit is contained in:
agra
2026-06-12 16:48:02 +03:00
parent 10f5a4318d
commit 053314b3ea
2 changed files with 98 additions and 3 deletions

View File

@@ -325,7 +325,7 @@ fn compileCForJIT(allocator: std.mem.Allocator, io: std.Io, comp: *sx.core.Compi
const c_infos = try comp.collectCImportSources();
if (c_infos.len == 0) return .{ .allocator = allocator };
const obj_bufs = try sx.c_import.compileCToObjects(allocator, c_infos, comp.target_config);
const obj_bufs = try sx.c_import.compileCToObjects(allocator, io, c_infos, comp.target_config);
return try sx.c_import.loadCObjectsForJIT(allocator, io, obj_bufs);
}
@@ -339,7 +339,7 @@ fn compileCForBuild(allocator: std.mem.Allocator, io: std.Io, comp: *sx.core.Com
return try sx.c_import.compileCWithEmcc(allocator, io, c_infos, comp.target_config, tmp_dir);
}
const obj_bufs = try sx.c_import.compileCToObjects(allocator, c_infos, comp.target_config);
const obj_bufs = try sx.c_import.compileCToObjects(allocator, io, c_infos, comp.target_config);
return try sx.c_import.writeCObjectFiles(allocator, io, obj_bufs, tmp_dir);
}