RE: [PATCH] Makefile: LTO: have linker check -Wframe-larger-than

From: David Laight
Date: Mon Mar 15 2021 - 06:58:59 EST


From: Nick Desaulniers
> Sent: 12 March 2021 17:55
>
> On Thu, Mar 11, 2021 at 5:09 PM Nick Desaulniers
> <ndesaulniers@xxxxxxxxxx> wrote:
> >
> > -Wframe-larger-than= requires stack frame information, which the
> > frontend cannot provide. This diagnostic is emitted late during
> > compilation once stack frame size is available.
> >
> > When building with LTO, the frontend simply lowers C to LLVM IR and does
> > not have stack frame information, so it cannot emit this diagnostic.
> > When the linker drives LTO, it restarts optimizations and lowers LLVM IR
> > to object code. At that point, it has stack frame information but
> > doesn't know to check for a specific max stack frame size.

With LTO the linker ought to be able to do a stack frame check
across multiples functions in the call stack.

Clearly recursive calls cause issues.
Indirect ones as well - but does CFI include enough info
about what can be called from where to help?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)