On Fri, Dec 10, 2021 at 05:31:39AM +0100, Florian Weimer wrote: > * Marc Feeley: > >> On Dec 9, 2021, at 9:04 AM, Florian Weimer <fweimer@xxxxxxxxxx> wrote: > > What worries me however is that you say “I expect GCC to turn it into > > a tail call” and I really need “I guarantee that GCC will turn it into > > a tail call”. > > I'm just a GCC user. And GCC is sufficiently complex and has many > targets that maybe no GCC developer wants to make such a guarantee. It is impossible to make that guarantee (with most ABIs). What we can (and imho should) do is add something like that musttail attribute, to make the compiler loudly complain if it cannot do it, instead of silently generate code that does not do what the user needs. But that will only work with new compilers, after we implemented such a feature. For all older compilers (going back 21 years, anyway) you can just ask for it (-O2 or -Os is enough), and check if you got what you needed. > If you don't want to patch glibc, you can perhaps inspect the generated > assembler code. If the only indirect calls are the tail calls, it might > work. Kind of like the Evil Mangler, but with less mangling. Yup :-) Segher