Re: [PATCH 0/4] -ffreestanding/-fno-builtin-* patches

From: Arvind Sankar
Date: Tue Aug 18 2020 - 20:20:59 EST


On Tue, Aug 18, 2020 at 03:59:45PM -0700, Nick Desaulniers wrote:
> On Tue, Aug 18, 2020 at 3:25 PM Arvind Sankar <nivedita@xxxxxxxxxxxx> wrote:
> >
> > Another thing that needs to be fixed is that at least lib/string.c needs
> > to be compiled with -ffreestanding.
> >
> > gcc-10 optimizes the generic memset implementation in there into a call
> > to memset. Now that's on x86 which doesn't use the generic
> > implementation, but this is just waiting to bite us.
> >
> > https://godbolt.org/z/6EhG15
>
> Admittedly, we've had the same shenanigans with memcpy implemented in
> terms of calls to __builtin_memcpy being lowered to infinitely
> recursive calls...which feels like the same kind of bug. ("You wanted
> infinite recursion in the kexec purgatory image, right?" "No,
> compiler, I did not.") example: https://godbolt.org/z/MzrTaM
> (probably should fix this in both implementations; at the least I feel
> like Clang's -Winfinite-recursion should try to help us out here).
>

What's the other implementation we need to worry about? purgatory (at
least on x86) has freestanding already.