Files
nixpkgs/pkgs/development/compilers/gcc/ng/16/libatomic/no-gcc-objdir-install.patch
John Ericson 0fdf5b63f9 gccNGPackages.libatomic: fix the two ways GCC 16 assumes a monorepo build
Both are new in 16 and both come from `libatomic` no longer being buildable
on its own without help.

`configure.ac` now refuses to run with an empty `CFLAGS`: it appends
`-fno-link-libatomic` and needs `AC_PROG_CC`'s conftests to see it, so it
will not let `AC_PROG_CC` supply the default instead.

    configure: error: CFLAGS must be set.

The top level passes them down in a monorepo build; here each library is
configured on its own, so pass what `AC_PROG_CC` would have chosen anyway.

`Makefile.am` then grew an `all-local` hook copying `libatomic.la` into
`../../gcc/`, so a compiler built in the same object tree can link
`-latomic`. There is no such tree here -- the compiler is a finished package
and gets the library through its wrapper -- so the rule just fails:

    install: cannot create regular file '/build/build/../../gcc/libatomic.so.1.2.0'

Drop the hook rather than the rule, to keep the difference from upstream
small.

Neither is caught by checking that patches apply: both are build failures on
a tree that patched cleanly.

Co-authored-by: Ben Siraphob <bensiraphob@gmail.com>
Assisted-by: Claude Code (Claude Opus 5)
2026-09-03 13:19:36 -04:00

27 lines
1.1 KiB
Diff

From: John Ericson <git@JohnEricson.me>
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