diff --git a/pkgs/development/compilers/gcc/ng/16/libatomic/no-gcc-objdir-install.patch b/pkgs/development/compilers/gcc/ng/16/libatomic/no-gcc-objdir-install.patch new file mode 100644 index 000000000000..767544927aa8 --- /dev/null +++ b/pkgs/development/compilers/gcc/ng/16/libatomic/no-gcc-objdir-install.patch @@ -0,0 +1,26 @@ +From: John Ericson +Subject: [PATCH] libatomic: Do not install into the toplevel gcc objdir + +GCC 16 added an `all-local` hook that copies `libatomic.la` into +`../../gcc/`, so that the compiler being built in the same object tree can +link `-latomic`. There is no such tree here: each runtime library is built +on its own, against an already-finished compiler, which is given the library +through the wrapper instead. The rule just fails: + + install: cannot create regular file '/build/build/../../gcc/libatomic.so.1.2.0' + +Drop the hook rather than the rule, so the difference from upstream stays as +small as possible. +--- +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am +index 49689d451..c389e8cd6 100644 +--- a/libatomic/Makefile.am ++++ b/libatomic/Makefile.am +@@ -181,7 +181,6 @@ all-multi: $(libatomic_la_LIBADD) + # from $gcc_objdir seems to fix the issue. + + gcc_objdir = `pwd`/$(MULTIBUILDTOP)../../gcc/ +-all-local: stmp-libatomic + stmp-libatomic: libatomic.la + $(LIBTOOL) --mode=install $(INSTALL_DATA) libatomic.la $(gcc_objdir)$(MULTISUBDIR)/ + if LIBAT_BUILD_ASNEEDED_SOLINK diff --git a/pkgs/development/compilers/gcc/ng/common/libatomic/default.nix b/pkgs/development/compilers/gcc/ng/common/libatomic/default.nix index bc83c8d9a7ca..1bfcd1b18fc7 100644 --- a/pkgs/development/compilers/gcc/ng/common/libatomic/default.nix +++ b/pkgs/development/compilers/gcc/ng/common/libatomic/default.nix @@ -43,22 +43,26 @@ stdenv.mkDerivation (finalAttrs: { '' ); - # Both are the same upstream change, which is in the GCC 16 release branch: - # the backport itself, and the hand-edit of the generated `aclocal.m4` that - # `fetchpatch` cannot carry. GCC 16 already includes `../config/gthr.m4` - # there. - patches = lib.optionals (lib.versionOlder release_version "16") [ - (fetchpatch { - name = "custom-threading-model.patch"; - url = "https://github.com/gcc-mirror/gcc/commit/e5d853bbe9b05d6a00d98ad236f01937303e40c4.diff"; - hash = "sha256-U1Eh6ByhmseHQigfHIyO4MlAQB3fECmpPEP/M00DOg0="; - includes = [ - "config/*" - "libatomic/configure.ac" - ]; - }) - (getVersionFile "libatomic/gthr-include.patch") - ]; + patches = + lib.optionals (lib.versionAtLeast release_version "16") [ + (getVersionFile "libatomic/no-gcc-objdir-install.patch") + ] + # Both are the same upstream change, which is in the GCC 16 release + # branch: the backport itself, and the hand-edit of the generated + # `aclocal.m4` that `fetchpatch` cannot carry. GCC 16 already includes + # `../config/gthr.m4` there. + ++ lib.optionals (lib.versionOlder release_version "16") [ + (fetchpatch { + name = "custom-threading-model.patch"; + url = "https://github.com/gcc-mirror/gcc/commit/e5d853bbe9b05d6a00d98ad236f01937303e40c4.diff"; + hash = "sha256-U1Eh6ByhmseHQigfHIyO4MlAQB3fECmpPEP/M00DOg0="; + includes = [ + "config/*" + "libatomic/configure.ac" + ]; + }) + (getVersionFile "libatomic/gthr-include.patch") + ]; postUnpack = '' mkdir -p ./build @@ -87,6 +91,15 @@ stdenv.mkDerivation (finalAttrs: { "--disable-multilib" ]; + # GCC 16's `libatomic/configure.ac` refuses to run with an empty `CFLAGS`: + # it appends `-fno-link-libatomic` to them and needs `AC_PROG_CC`'s conftests + # to see it, so it will not let `AC_PROG_CC` supply the default instead. In + # the monorepo build the top level passes them down; each library is + # configured on its own here, so pass what `AC_PROG_CC` would have chosen. + env = lib.optionalAttrs (lib.versionAtLeast release_version "16") { + CFLAGS = "-g -O2"; + }; + preConfigure = '' cd "$buildRoot" configureScript=$sourceRoot/configure diff --git a/pkgs/development/compilers/gcc/ng/common/patches.nix b/pkgs/development/compilers/gcc/ng/common/patches.nix index dbce54c543b9..ff978e602d90 100644 --- a/pkgs/development/compilers/gcc/ng/common/patches.nix +++ b/pkgs/development/compilers/gcc/ng/common/patches.nix @@ -14,6 +14,15 @@ } ]; + # Only present under `../16`, so a `gitRelease` build -- whose version + # directory is `../git` -- has to be pointed here too. + "libatomic/no-gcc-objdir-install.patch" = [ + { + after = "16"; + path = ../16; + } + ]; + # In Git: https://github.com/Ericson2314/gcc/tree/regular-dirs-in-libgcc-15 "libgcc/force-regular-dirs.patch" = [ {