mirror of
https://github.com/zml/zml.git
synced 2026-11-16 19:11:09 +00:00
ZML initializes runfiles before `main` so its loaders can locate packaged libraries and data. When using `-fno-llvm -fincremental` and linking with the incremental ELF linker, declaring the registration pointer in Zig produces incorrect `.init_array` data. See https://codeberg.org/ziglang/zig/issues/37453 Use a C constructor on Linux and macOS so the C compiler emits the platform-specific startup registration, while Zig exports the existing runfiles initialization function directly. We can revert when https://codeberg.org/ziglang/zig/issues/37453 is fixed. With this fix, we bypass the wrong behavior in incremental ELF linker and get closer to ZML compliance with zig incremental using their incremental linker. The registration is shared by the `use_cc_common_link=true` and `false` paths. Keep the explicit linker retention so the constructor is included even when its object is in a static archive.
27 lines
1 KiB
27 lines
1 KiB