OpenBSD is missing the gambit package for mips64, powerpc, and
powerpc64, where __attribute__((musttail)) is a fatal error in clang.
I reported this at https://github.com/gambit/gambit/issues/898

This diff disables musttail, packages Gambit Scheme and runs gsi(1) on
my powerpc and powerpc64; I don't have a mips64.  ok?

A simple reproducer in ports-clang (pkg_add llvm%17),

$ cat f.c                                                              
void g(void);
void f(void) { __attribute__((musttail)) return g(); }
$ clang-17 -target mips64-openbsd -c f.c
fatal error: error in backend: failed to perform tail call elimination on a 
call site marked musttail

--gkoehler

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/gambit/Makefile,v
diff -u -p -r1.49 Makefile
--- Makefile    26 Sep 2023 12:02:01 -0000      1.49
+++ Makefile    23 Mar 2024 04:44:03 -0000
@@ -3,6 +3,7 @@ BROKEN-riscv64= gsi and gsi-script segfa
 COMMENT=       complete, efficient and reliable implementation of Scheme
 
 V=             4.9.5
+REVISION=      0
 DISTNAME=      gambit-v${V:S/./_/g}
 PKGNAME=       gambit-$V
 API_V=         ${V:R:S/./0/}00${V:E}
Index: patches/patch-include_gambit_h_in
===================================================================
RCS file: patches/patch-include_gambit_h_in
diff -N patches/patch-include_gambit_h_in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-include_gambit_h_in   23 Mar 2024 04:44:03 -0000
@@ -0,0 +1,15 @@
+Disable musttail on mips64, powerpc, powerpc64 to avoid a fatal error
+in clang.  https://github.com/gambit/gambit/issues/898
+
+Index: include/gambit.h.in
+--- include/gambit.h.in.orig
++++ include/gambit.h.in
+@@ -1625,7 +1625,7 @@
+ 
+ #endif
+ 
+-#if __has_attribute(musttail)
++#if __has_attribute(musttail) && !defined(__mips__) && !defined(__powerpc__)
+ #define ___PROPER_TAIL_CALL(call) __attribute__((musttail)) return call
+ #else
+ #if defined(___TRUST_C_TCO)

Reply via email to