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.
in LTO, the linker would garbage collect that exported symbol since it
wouldn't be used inside the final binary
forcing it undefined via a link flag prevents it from being removed.
runfiles are process-wide in space and time.
so it makes sense to keep them around
because they are bound to the process, we use the smp_allocator and
except the memory to be kept around during the lifetime of the process.