Well... I went on the deepest of dives today to fix the link error I've been tangling with while working on tigerbeetle-hs!
First, GHC passes `-lm` near the beginning of the linker flags it generates when compiling an executable. Pretty normal.
Unless you're linking a shared object file compiled from Zig.
Zig's build tool chain vendors it's own versions of libc for the various target platforms. When you call 'linkSystemLibrary2` and tell it to link `"m"` and tell Zig that's it's needed... well, it ignores you.
Zig's build tool sees that you asked to link a system library once and it links libc... and nothing else.
All of this means that if you pass `-lm` before you link the Zig shared object, you get a relink error. Because Zig helpfully provides an implementation for the libc symbol (in my case, `sin`) and the linker already has an implementation for that symbol... in libm.
It looks like Zig's tool chain doesn't include any of the GNU library paths in the RPATH of the elf header and so the linker asks you to relink the library against libm... which you can't actually do with Zig's build tools.
Trying out a hack with nix's `patchelf` to add the RPATH's into the nix store for the glibc so that the object file can declare its dependency on libm's implementation and will have to work through the community to see how we can get Zig to play nicer with systems.