Hi Brad. It is nice to see that support for tail-calls is improving in GCC. If you want to test this out, here are the lines of gambit.h.in that define the ___PROPER_TAIL_CALL C macro that is used to indicate that a call must be a tail call:
#if __has_attribute(musttail) #define ___PROPER_TAIL_CALL(call) __attribute__((musttail)) return call #else #if defined(___TRUST_C_TCO) #define ___PROPER_TAIL_CALL(call) return call #endif #endif
The __has_attribute(musttail) will be true for clang versions that have the musttail attribute. Something similar should be used to detect the feature on GCC (I’m not sure this test also works for GCC as is).
What is also needed is some testing on various architectures to see which targets (x86, arm, etc) support the attribute. This knowledge can then be used in conditional expansions in the gambit.h.in file to use musttail only on those targets where it is known to work. The fallback when the target is not known to support musttail is to use a trampoline, which has worked for many years with acceptable performance.
Marc
On Aug 20, 2024, at 6:54 PM, Bradley Lucier lucier@purdue.edu wrote:
Must I change any configuration or header files to try the musttail attribute of gcc?
Brad