https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
Arsen Arsenović <arsen at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arsen at gcc dot gnu.org
--- Comment #56 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
(In reply to Rich Felker from comment #54)
> I don't think name detection is a reasonable solution to this problem. It
> won't solve anything when there's an intermediate call where you'd get
> indirect recursion.
>
> The right solution here is always honoring -ffreestanding, never emitting
> calls to string functions in freestanding mode, and insisting that anyone
> writing their own (re)implementation of the standard string functions use
> -ffreestanding.
I disagree; there's no reason freestanding code wouldn't benefit from such loop
pattern recognition.
I'd say that the correct solution working with current GCC versions is to put
all of these functions into a TU (or a few of them, if you prefer), built with
'-fno-lto -fno-builtin'.
But, ISTM that clang also has a no_builtin attribute that's made for cases like
these: https://clang.llvm.org/docs/AttributeReference.html#no-builtin
as does rust, so presumably we'll need it in GCC for gccrs at least