I thought I'd build mainline and try to use the new musttail attribute
on some Scheme code that's been translated by the Gambit Scheme compiler
to heavily macrofied C code.
The code that selects whether to use the musttail attribute, which
previously triggered only on clang, is
#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
This now triggers with gcc mainline.
The Scheme compiler translates all intramodule tail calls to C computed
goto's, so there is only one call marked with the musttail attribute per
C file, and I get the failure:
/pkgs/gcc-mainline/bin/gcc -save-temps -O1 -fexpensive-optimizations
-fno-gcse -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv
-fno-strict-aliasing -fno-trapping-math -fno-math-errno
-fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -fipa-ra
-fmove-loop-invariants -march=native -fPIC -fno-common -mpc64
-I"../include" -c -o _io.o -I. -DHAVE_CONFIG_H
-D___GAMBITDIR="\"/usr/local/Gambit/v4.9.5\""
-D___GAMBITDIR_USERLIB="\"\176/.gambit_userlib\""
-D___GAMBITDIR_INSTLIB="\"\176\176userlib\""
-D___SYS_TYPE_CPU="\"x86_64\"" -D___SYS_TYPE_VENDOR="\"pc\""
-D___SYS_TYPE_OS="\"linux-gnu\"" -D___CONFIGURE_COMMAND="\"./configure
'CC=/pkgs/gcc-mainline/bin/gcc' '--enable-march=native'
'--enable-dynamic-clib' '--enable-single-host'
'--enable-multiple-versions' '--enable-shared' '--enable-trust-c-tco'"\"
-D___OBJ_EXTENSION="\".o\"" -D___EXE_EXTENSION="\"\""
-D___BAT_EXTENSION="\"\"" -D___PRIMAL _io.c -D___LIBRARY
_io.c: In function '___H___io':
_io.c:120971:177: error: expected identifier or '(' before 'return'
120971 | ___END_M_COD
|
^
make: *** [makefile:311: _io.o] Error 1
The offending line in the .i file is
__attribute__((musttail)) return (*((___host*)((((long*)((___pc)-(1)))
+ (1 +((-2)))))))(___ps);
Am I doing things incorrectly here?
Thanks.
Brad