Skip to content

netbsd: Upgrade to 11, and switch to GCC NG - #573715

Merged
Ericson2314 merged 8 commits into
NixOS:masterfrom
Ericson2314:netbsd-11/1-upgrade
Oct 13, 2026
Merged

Ericson2314 merged 8 commits into
NixOS:masterfrom
Ericson2314:netbsd-11/1-upgrade

Conversation

@Ericson2314

@Ericson2314 Ericson2314 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

See each commit for details.

Things done

Update to the latest major release. 10 is skipped: it is no longer the
newest, and an older tree is less likely to build with the compilers we
use, such as GCC 16.

Note that this commit just updates the source code, and doesn't unbreak
the packages. NetBSD in Nixpkgs was already rather bitrotten, so this
isn't a regresion TODO CHECK. The fixes 11.0 needs follow in separate
commits.

The source now comes from the release's source sets rather than a
`fetchcvs` export of `src`, which takes on the order of ten hours; the
sets download in about a minute. Their hashes are taken from the `SHA512`
file NetBSD publishes beside them. Only `src`, `syssrc` and `sharesrc` are
fetched, since nothing here builds the imported GNU tools (`gnusrc`) or
X11 (`xsrc`).

Assisted-by: Claude Code (Claude Opus 5.5)
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. llm-assisted Contributions that include code generation with LLMs 6.topic: lib The Nixpkgs function library labels Oct 13, 2026
@Ericson2314
Ericson2314 force-pushed the netbsd-11/1-upgrade branch 2 times, most recently from edf0765 to dd330f6 Compare October 13, 2026 19:18
@Ericson2314

This comment was marked as resolved.

`name` was the literal `"netbsd-headers-9.2"`, so the join advertised 9.2
while joining 11.0 inputs. Take `version` from the scope like everything
else.

Assisted-by: Claude Code (Claude Opus 5.5)
Make `useGccNG` the default for every NetBSD platform, as Cygwin's already
is, rather than opting in one example system. NetBSD 11.0 is only supported
with the split set, so this comes straight after the version bump: the
monolithic `gcc` is not kept working for it.

NetBSD is low tier and has to use GCC rather than LLVM, so it is a good
place to dogfood the split set.

With the fixes that follow, GCC 16 builds `hello`, `zlib`, `bash`,
`perl`, `python3` and the NetBSD libc for it.

`x86_64-netbsd-llvm` is unaffected, since `useLLVM` takes precedence.

Assisted-by: Claude Code (Claude Opus 5.5)
…ripts

The release source sets ship `tools/*/configure` without the executable
bit. NetBSD's own build never cared, because it invokes them as
`${HOST_SH} configure` rather than executing them directly. `fetchcvs`
preserved the bit, so this only surfaced with the switch to the sets.

stdenv's `configurePhase` tests for an *executable* `./configure`, so
without it the phase quietly reports "no configure script, doing
nothing", and the failure only shows up later and further away:

    sh: ./buildmake.sh: No such file or directory

because `buildmake.sh` is generated from `buildmake.sh.in` by exactly the
configure run that got skipped.

Assisted-by: Claude Code (Claude Opus 5.5)
`compat-dont-configure-twice`: rebased. The `config.cache` rule now
stages through `${.TARGET}.tmp` and passes `CPPFLAGS`/`CONFIGURE_ARGS`.
The fix is unchanged -- delete the rule, because we run `configure`
ourselves in `configurePhase` and letting `make` run it again from inside
the build discards that.

`compat-no-force-native`: rebased, with one substantive change. 9.2
accumulated `tools/compat`'s include flags in `CPPFLAGS` and only moved
them into `HOST_CPPFLAGS` at the bottom of the Makefile, beside the
`bsd.hostlib.mk` include -- so deleting that tail, as the patch already
did, left them in `CPPFLAGS` where `bsd.lib.mk` reads them. 11.0 assigns
them straight to `HOST_CPPFLAGS`, which `bsd.lib.mk` never reads, so the
`lib/libc` sources that `tools/compat` pulls in via `.PATH` stopped
finding their headers:

    lib/libc/gen/dirname.c:37:10: fatal error: namespace.h: No such file or directory

The patch now redirects those two assignments to `CPPFLAGS` explicitly.

`compat-host-locale-t`: new. NetBSD's `<nl_types.h>` typedefs `locale_t`
behind `__LOCALE_T_DECLARED`, a macro no non-NetBSD libc defines.
`tools/compat` builds against the *host* libc and `compat_defs.h` includes
`<ctype.h>`, which on glibc already declares `locale_t`, so the typedef
fires twice and `gencat` fails to compile. Claim the declaration in
`compat_defs.h`, right after `<ctype.h>` -- it is included by every host
tool via `nbtool_config.h`, so that is both sufficient and correctly
ordered. This is latent upstream because it only bites when the build host
is not NetBSD.

Assisted-by: Claude Code (Claude Opus 5.5)
Upstream added

    LDFLAGS+= --no-dynamic-linker --noinhibit-exec

to `Makefile.efiboot` in revision 1.17, so the patch no longer applies:

https://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/i386/stand/efiboot/Makefile.efiboot.diff?r1=1.16&r2=1.17

`sys-headers` shares this patch list with `sys`, and every package needs
the headers, so this breaks the whole package set, not just the kernel.

Assisted-by: Claude Code (Claude Opus 5.5)
Three things 11.0 needs that 9.2 did not.

`genassym` was already an argument but never reached
`nativeBuildInputs`. 9.2 got away with it; 11.0's libc has
`arch/x86_64/genassym.cf`, so `assym.h` is now generated while building
libc rather than only the kernel, and the build died with
`genassym: command not found`.

`lib/csu` joins `extraPaths`. 11.0 added `lib/csu/common/csu-common.h`
and made `lib/libc/gen` include it. The include path already pointed at
`lib/csu/common`; the sources simply were not in the filtered tree.

`nslexer-declare-strdup.patch` declares `_strdup`. `nslexer.l` calls
`strdup`, which `namespace.h` rewrites to `_strdup` -- fine when the
file's own includes come first, because `<string.h>` is then read after
the rename. Built with flex instead of NetBSD's lex it is not: flex's
skeleton emits `#include <string.h>` ahead of the `%{ %}` block, so
`strdup` is declared under its ordinary name and the later `<string.h>`
is a no-op behind its guard.

Declaring the renamed symbol fixes the actual defect. The alternative,
demoting `-Wimplicit-function-declaration` and `-Wint-conversion` to
warnings, is far too blunt for a libc build -- `-Wno-error=int-conversion`
would hide genuine pointer/integer confusion everywhere else in the tree.

This one is not version-specific: `nslexer.l` is byte-identical in 9.2,
10, 11 and -current. It depends on our flex, not on NetBSD's release.

Assisted-by: Claude Code (Claude Opus 5.5)
Two more places where 11.0 needs something 9.2 did not.

`libcrypt` grew an argon2 password hash, implemented by the vendored
`phc-winner-argon2` under `external/apache2/argon2`. Its Makefile reaches
those sources through `.PATH`, so without them in the filtered tree the
build stops at `don't know how to make argon2.c`.

`librpcsvc` needs `RPCGEN_CPP`. `rpcgen` shells out to a C preprocessor,
and 11.0 defaults that to `/usr/bin/clang-cpp`, which does not exist
here. It fails *softly*: the generated stubs come out empty, so the
library still builds and links, and the first sign of trouble is NetBSD's
own expected-symbol check, at which point 283 symbols are missing and
none are extra:

    librpcsvc.so.1.0: error: actual symbols differ from expected symbols

`include` already passes this flag; librpcsvc needs it for the same
reason. It has to name the *build* compiler, since `rpcgen` runs here and
the cross gcc installs only target-prefixed binaries, so it has no plain
`cpp`.

Assisted-by: Claude Code (Claude Opus 5.5)
@Ericson2314
Ericson2314 marked this pull request as ready for review October 13, 2026 20:11
@Ericson2314

Ericson2314 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

OK I am happy with this now. BTW the patch commits come from https://github.com/Ericson2314/netbsd-src, but NetBSD doesn't do a CVS->Git export with stable hashes, so these git hashes aren't so useful anyways. Further maintainership on this should feel free to ignore my repo and just deal with the patches manually. That is why I don't fetchpatch them.

@Ericson2314
Ericson2314 added this pull request to the merge queue Oct 13, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested review from a team and alyssais October 13, 2026 20:30
Merged via the queue into NixOS:master with commit a870c0a Oct 13, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. llm-assisted Contributions that include code generation with LLMs

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant