mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-31 20:54:56 +00:00
The crt-building hack in `postPatch` does two things, both of which assume ELF: - it forces `libgcc.a` to depend on `crti.o`/`crtn.o`. Those are an ELF convention. PE/COFF targets have no such files, so the rule makes the build assemble the generic ELF `config/i386/crti.S` with a PE assembler, which fails with `junk at end of line`. - it blanks `SHLIB_LC`, which for ELF is `-lc` and stands in the way of linking `libgcc_s.so` before libc exists. On Cygwin and MinGW `SHLIB_LC` is instead the list of system import libraries the DLL genuinely needs, so blanking it drops real dependencies. So apply it only on ELF. That leaves the pre-libc stage on PE/COFF with no way to link a shared `libgcc`: every symbol in a DLL has to resolve at link time, and the libc's import library does not exist yet. Build only `libgcc.a` there -- which is all that stage is used for -- and let the shared library be built as usual once the real libc is present. Which case applies is read from `stdenv.cc.libc`, as everything else in this package is, with headers-only stand-ins marking themselves via `passthru.headersOnly`. ELF targets build the same thing as before but do not keep the same derivation: `--enable-shared` is now stated outright where configure was previously left to default to it. `libgcc` for `x86_64-unknown-netbsd` gains that one flag and nothing else. Assisted-by: Claude Code (Claude Opus 5)