Files
John Ericson 3597baf22b gccNGPackages: apply the monolithic set's patches
None of `gcc/patches/default.nix` was applied here. Take them, with the same
conditions the monolithic set uses:

- `no-sys-dirs`, with its RISC-V companion, keeping `/usr/local/include`,
  `/lib` and `/usr/lib` off the search paths. GCC drops those itself for a
  cross compiler with no sysroot, which is most of what this set builds, so
  the gap only shows up natively -- but it does: a `gcc` built without this
  reports `/lib/` and `/usr/lib/` in `-print-search-dirs`.
- `mangle-NIX_STORE-in-__FILE__`, keeping store hashes out of `__FILE__` and
  so `-dev` outputs out of runtime closures. `cc-wrapper` sets
  `useMacroPrefixMap = !isGNU` and this set's compiler is `isGNU`, so the
  wrapper deliberately leaves this to the compiler and nothing was doing it.
- `ppc-musl`, unconditional there and here. `no-sys-dirs` does not subsume
  it: `rs6000/sysv4.h` builds its own `INCLUDE_DEFAULTS` for musl and tests
  `LOCAL_INCLUDE_DIR` before the `#undef` in `cppdefault.cc` is reached.
- `gfortran-driving`, on `langFortran`. Keeps `-l` and its argument together
  in the `Driving:` line, which is what libtool parses out of `gfortran -v`.
- `c++tools-dont-check-enable-default-pie`, below 16. `--enable-default-pie`
  is a target option but `c++tools` is built for the host and should follow
  `--enable-host-pie`; we pass the former and do build `c++tools`. 16 dropped
  the check upstream.
- the two Cygwin patches, on `isCygwin`. Cygwin's `abort` arrives through
  `windows.h` and collides with the `tsystem.h` macro on the `inhibit_libc`
  path, which this set's bootstrap goes through by design; and `unix` should
  be defined with `builtin_define_std`.

Three go to `libgcc` rather than `gcc`: `cfi_startproc-reorder-label`, which
moves a directive in the aarch64 LSE helpers that clang 18 and later refuse
to assemble; and the two small Darwin ones, where `darwin-detection` is
paired by version -- 14's variant for 16, 15's for 15 -- so it goes through
`getVersionFile` rather than being picked once.

Iain Sandoe's branch is the one that could not simply be copied: it spans the
monorepo, so each package takes the files it builds, the way
`system-libbacktrace.patch` is already split here. `gcc` gets `gcc/`,
`fixincludes/` and the top-level `configure`; `libgcc` gets `libgcc/`;
`libsanitizer` gets its one `configure.tgt` case. That is 69 of the 72 files;
the rest are `libitm` and `libgcobol`, which this set does not package. From
Homebrew rather than GitHub's compare API, as the monolithic set does. The 16
diff is against 16.1.0 and applies to 16.2.0 unchanged.

Two of our own patches are held back on Darwin, because his branch already
carries the same change and they no longer apply on top of it:

- `cfi_startproc-reorder-label`, which the monolithic set also excludes.
  `STARTFN` is replaced by an `ENTRY` macro that already writes the label
  ahead of `.cfi_startproc`, so there is nothing left to reorder.
- `fix-collect2-paths`, which is not excluded there because the monolithic
  set does not have it. His `collect2.cc` has `is_cross_compiler`, the extra
  `post_ld_pass` argument and the unguarded `target_machine` already; all
  ours would add is deleting the loop his version leaves behind.

Copied rather than shared with `../patches`, so that this set does not reach
into the monolithic one's directory.

Not taken: `libssp-noshared-musl32`, which assumes the libc ships
`libssp_nonshared.a` while this set builds its own `libssp`.

No Darwin builds tested yet, as I don't have one.

Assisted-by: Claude Code (Claude Opus 5)
2026-09-03 13:19:36 -04:00
..