Best practice for linking against libatomic?

Simon Richter <[email protected]> Mon, 12 Jan 2026 19:12:57 +0900
Newsgroups gmane.comp.gcc.help
Message-ID <[email protected]>
Hi,

I have a pile of build failures on RISC-V because the program uses 
atomics but doesn't link against libatomic.

A lot of programs seem to notice the need for libatomic when they first 
use some construct that isn't inlined on x86_64 -- some then add a 
configure time test if it is actually needed, for good measure.

The "correct" approach would probably be to test if libatomic is needed 
for all data types or at least sizes that are then used in the actual 
program, but that's a game of whack-a-mole.

The less correct, but lazy approach is to always link against libatomic 
with --as-needed (which assumes the GNU linker).

Is there a recommended way of handling this for package maintainers, or 
should this really be done at system level (e.g. by hacking the specs)?

    Simon
OpenPGP_signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEtjuqOJSXmNjSiX3Tfr04e7CZCBEFAmlkySkACgkQfr04e7CZ
CBE94wgAsIXbFoMc8XNmMz9PdXORUY3AeDRNazeBh6JF/pv16BP8bUhxYhdjhpFN
R2llREfh4GB0UotTT2DgkihfsSNmqrt+4/G7A5W45UG2m38a3vnjQ5wsyR4LkmTE
l2j32GS3gWsTtkTKh1s7Vb5RSIq8eshGegDVApAWpmtQOdrP0/tQ6DMl09MNZDaG
lxLf7oeKMZVP6H1lHgiVpGbGeSAR7T6MlNfO6XoyI1Lnv+2CTzjsQ4qCE0kzgcVP
BEhqAwvsf+0Nl/fHkjP8cOOVLMqHy2IJAlaqHIOB5POXKpJtJxyCn/zOMcGyny7i
GmjEuT9kFRpyiG50C0bGaLgZsAHLUw==
=mLNl
-----END PGP SIGNATURE-----