linkLibC causes linker script to be used instead of library
Zig Version
0.11.0-dev.1910+6d7fb8f19
Steps to Reproduce and Observed Behavior
Use linkLibC() on an executable and in many cases, it'll link with a libc.so linker script instead of an actual shared library. It seems Zig does not do any sort of checks to prevent this when using the builder. In my case, I am using Nix and on the Zig Discord I've discovered that others may have this issue as well. I discovered this when my executable refused to execute and I ran ldd and found this:
outputs/out/bin/neutron-runner: error while loading shared libraries: /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/libc.so: invalid ELF header
I ran file on the file it mentions and it says it's a text file. I checked the contents and it contains this:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/libc.so.6 /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/libc_nonshared.a AS_NEEDED ( /nix/store/76l4v99sk83ylfwkz8wmwrm4s8h73rhd-glibc-2.35-224/lib/ld-linux-x86-64.so.2 ) )
Expected Behavior
Zig's build system should check if the libc is a linker script, if it is then it should parse it and figure out what to do with it. It should also check for other libc's by soversion in the same directory.