feat: emcc C compiles go through the object cache
compileCWithEmcc now probes/saves .sx-cache/c-<key>.o with the same content key as the native path (source + declared headers + transitive deps + defines/flags/incdirs), keyed by the emcc --version line and the wasm triple so emsdk upgrades and wasm32/64 variants never collide with each other or with native objects. Cache hits hand the linker the cache path directly. objectMagicOk accepts the wasm magic. Verified: warm wasm build of a c-unit drops 1.85s -> 0.61s (emcc -c skipped).
This commit is contained in:
@@ -70,6 +70,7 @@ test "objectMagicOk: accepts Mach-O and ELF, rejects garbage and truncation" {
|
||||
try std.testing.expect(c_import.objectMagicOk(&.{ 0xcf, 0xfa, 0xed, 0xfe, 0x00 })); // Mach-O 64
|
||||
try std.testing.expect(c_import.objectMagicOk(&.{ 0xce, 0xfa, 0xed, 0xfe })); // Mach-O 32
|
||||
try std.testing.expect(c_import.objectMagicOk(&.{ 0x7f, 'E', 'L', 'F', 0x02 }));
|
||||
try std.testing.expect(c_import.objectMagicOk(&.{ 0x00, 'a', 's', 'm', 0x01 })); // wasm
|
||||
try std.testing.expect(!c_import.objectMagicOk("not an object file"));
|
||||
try std.testing.expect(!c_import.objectMagicOk(&.{ 0xcf, 0xfa, 0xed })); // truncated magic
|
||||
try std.testing.expect(!c_import.objectMagicOk(&.{}));
|
||||
|
||||
Reference in New Issue
Block a user