New issue by leahneukirchen on void-packages repository https://github.com/void-linux/void-packages/issues/35992 Description: I'm suggesting this change because I want to bring the RISC-V port forward, but the problem also affects us already on armv6 in some way. In short: for certain operations, gcc generates calls to its own library of atomic functions, `libatomic`. Where exactly depends on the architecture and how powerful the instruction-set atomics are, but for example: - On aarch64 and x86_64, for atomic 128-bit ints or double complex numbers. - On armv6, for any C11 _Atomic integer type. - On RISC-V 64-bit, for *any* code that uses `-pthread`. The problem is: gcc doesn't link against libatomic automatically in these cases. Code that uses more than 64-bit atomics usually uses libatomic upstream (because all platforms are affected), so this is not our problem. For armv6 and other platforms, we currently use `$XBPS_TARGET_NO_ATOMIC8` in roughly 150 templates. This is annoying, but bearable, and we did the work already. For RISC-V, this is unacceptable, as we need to touch way too many templates to adjust every package using pthreads. I therefore suggest a two-step solution: 1. Add `libatomic-devel` as a `depends=` of gcc. This will ensure code that knows it needs `-latomic` will just work without further changes. As `libatomic-devel` is a small subpackage of gcc, this doesn't change else much. It requires just a rebuild of gcc. 2. Import the `--enable-autolink-libatomic` [patch](https://git.alpinelinux.org/aports/tree/main/gcc/0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch). This patch links to libatomic automatically, as needed. I'd suggest to enable it for the $XBPS_TARGET_NO_ATOMIC8 platforms by default, and RISC-V in the future. This patch is not merged upstream, but some distros use it, for example Alpine. It is also quite small so should not be much additional maintenance. There is one caveat with the patch, in that it breaks building libatomic itself :clown_face:, so we also need [this Alpine patch](https://git.alpinelinux.org/aports/tree/main/gcc/0040-configure-fix-detection-of-atomic-builtins-in-libato.patch). This requires a full rebuild of all affected cross toolchains. As a result, after step one, we can gradually remove all ``` if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then makedepends+=" libatomic-devel" fi ``` and after step two, also all `LDFLAGS+=" -latomic"`.