https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
--- Comment #2 from Florian Weimer <fw at gcc dot gnu.org> --- The problem is that if GCC is not configured for SHF_GNU_RETAIN, __has_attribute (retain) should not be true. That is, __has_attribute needs to reflect the actual attribute support status, and not what happens to be registered as attributes in the GCC codebase. __has_builtin has the same problem, see bug 96952 for an example.