Thanks for doing the grunt work of testing musttail on GNU gcc and clang.
I think your changes to gambit.h.in would be better expressed as 2 separate cases for GNU gcc and clang rather than trying to find a syntax that is supported by both (for example it is forcing the use of -std=c2x and that is not a requirement we want to introduce). The case for clang can stay as it is currently. We just need the syntax for GNU gcc. Is it
[[musttail]] return foo(…);
?
Marc
On Aug 24, 2024, at 9:46 PM, Bradley Lucier lucier@purdue.edu wrote:
On 8/20/24 9:38 PM, Marc Feeley wrote:
#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
OK, here's how I understand things. I could be wrong, of course.
GCC 15.0.0 (developmental mainline)
__has_attribute(musttail) is true.
Does not currently support the __attribute__((musttail)) notation, so if you need to bootstrap mainline Gambit, which first checks out and builds 4.9.5 release before building GitHub head, you can't use current mainline gcc. I'll ask the GCC folks whether __attribute__((musttail)) will be supported.
Does support [[gnu::musttail]] and [[clang::musttail]] and they appear to be synonyms.
Clang 14.0.0 (what I have on my Ubuntu 22.04 box):
__has_attribute(musttail) is true.
Supports the __attribute__((musttail)) notation.
If you want to use the [[clang::musttail]] notation, you must set -std=c2x or something similar on the command line.
So by fiddling around with include/gambit.h by hand, I got current Gambit head to build with [[clang:musttail]] on both GCC mainline and clang 14.0.0. make check passes with GCC mainline.
The clang build with -std=c2x has failures in make check of the following form:
------------ TEST 6 (link and execute the code generated) rm -f mix_.c mix.o mix_.o mix ../gsc/gsc -:~~bin=../bin,~~lib=../lib,~~include=../include -f -c mix.scm ../gsc/gsc -:~~bin=../bin,~~lib=../lib,~~include=../include -f -warnings -o mix -exe mix.c In file included from mix.c:631: /home/lucier/programs/gambit/gambit/include/gambit.h:9519:5: error: unknown type name 'sigset_t'; did you mean '__sigset_t'? sigset_t sigset[3]; ^~~~~~~~ __sigset_t /usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h:8:3: note: '__sigset_t' declared here } __sigset_t; ^ 1 error generated. *** ERROR IN ##main -- target compilation or link failed while compiling "mix.c" make[1]: [makefile:149: test6] Error 70 (ignored)
Brad