Commit Graph

7 Commits

Author SHA1 Message Date
John Ericson
5acbc090bb gccNGPackages.libgfortran: Fix patch conflict with system-libbacktrace
`force-regular-dirs.patch` and `system-libbacktrace.patch` both rewrite
the same region of `libgfortran/Makefile.am`, and applied in that order
the second one fails:

    patching file libgfortran/Makefile.am
    Hunk #1 FAILED at 48.

`force-regular-dirs.patch` turns `toolexeclib_LTLIBRARIES` into
`lib_LTLIBRARIES`, and that line is *context* for the hunk that swaps
`../libbacktrace/libbacktrace.la` for `$(LIBBACKTRACE_LIB)` just below
it. So the hunk can never apply afterwards.

Apply `system-libbacktrace.patch` first and rebase ours onto the result,
rather than the other way around: that one is the version posted to
gcc-patches and is best kept as posted, while this one is ours to move.
The rebased patch makes exactly the same edits -- only context lines and
offsets change.

This was latent rather than new: nothing rebuilt `libgfortran` from
source until the `gcc` changes on this branch forced it to.

Assisted-by: Claude Code (Claude Opus 5)
2026-08-21 15:59:52 -04:00
John Ericson
2a1d427bd9 gccNGPackages: Do not use vendored libbacktrace
- `gccNGPackages.libbacktrace`: Remove, in favor of the `libbacktrace`
  package in `pkgs/by-name`

- `stdenvNoCxx`: New, a compiler with a libc but no C++ standard library

- `libbacktrace`: Build with `stdenvNoCxx`, so `libstdc++` can link it
  without a cycle

- `gccNGPackages.gcc`, `gccNGPackages.libgfortran`,
  `gccNGPackages.libstdcxx`: Take `libbacktrace` as a build input and pass
  `--with-system-libbacktrace`

That option is not upstream; it comes from a patch posted to gcc-patches[^1],
which we fetch from the archive rather than vendor.

One posting covers every component that links libbacktrace, so each
package filters it down to the files its own `src` carries, and leaves
out the generated files because we regenerate those locally anyway.

`gcc` and `libgfortran` were already using this `libbacktrace`, but by
faking up the sibling directory an in-tree build would have had --
archive, libtool archive and headers -- for the relative paths to resolve
against. Passing the flag lets that go.

Note that this means our libstdc++ is getting `std::stacktrace` support
for the first time; we were unwittingly excluding the vendored support.
Nothing failed, which is why it went unnoticed:
`--enable-libstdcxx-backtrace` defaults to `auto`, and `auto` means yes
wherever the library is hosted, so the feature was asked for. But the
probe that picks the object format runs `libbacktrace/filetype.awk`,
which was not among the files we copied, so it got nothing back, warned
"could not determine output file type", and quietly settled on
`enable_libstdcxx_backtrace=no`.

Note also that with this approach, a downstream `libbacktrace`
*cannot* be built by the regular `stdenv` with `useGccNG = true`,
because its symbols would conflict. We'll see whether that is acceptable
or not. If it isn't, we can still avoid vendoring, but we will need to
replicate the symbol renaming that GCC would have done externally.

[^1]: https://inbox.sourceware.org/gcc-patches/20260814013206.3818461-1-git@JohnEricson.me/

Assisted-by: Claude Code (Claude Opus 5)
2026-08-13 23:18:53 -04:00
NAHO
c8d4dabc43 pkgs: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --type file \
      . \
      pkgs \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2025-10-04 19:02:37 +02:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
John Ericson
424f8f2abb gccNGPackages: Force regular dirs
Because we're building things separately, we don't need the fancy
lib/... namespacing tricks that GCC normally does to squeeze itself in
the FHS. We can just use the normal autotools libdir and include dir,
and the nixpkgs infra will sort everything out.

Where possible I submitted patches to the mailing list, and fetched
those. The ones I am vendoring are the residuals which I don't think are
ready for upstreaming yet. (I can imagine a further reworking upstream
such that we wouldn't need our own patches of that sort, but it would be
good to get the first crop merged first before discussing that.)
2025-07-21 15:40:34 -04:00
John Ericson
1840d4dbf0 gccNGPackages: Rework threading model patch based on feedback on IRC
Also clean up some comments, and avoid unnecessarily patching GCC
itself.
2025-07-13 12:51:54 -04:00
Tristan Ross
e51bc1ab23 gccNGPackages: init 2025-07-11 07:42:18 -07:00