Here on powerpc (macppc), tcl 8.6 and 9 run well, but 8.5 is bad:

$ tclsh8.5
application-specific initialization failed: out of stack space (infinite loop?) 
% expr 2 + 3
out of stack space (infinite loop?)

This breaks devel/p5-Tcl on powerpc.  All other archs with snapshot
packages (aarch64 arm64 arm i386 mips64 powerpc64 riscv64 sparc64)
have packaged p5-Tcl.

My diff fixes tclsh8.5 by overriding this configure check,

        int StackGrowsUp(int *parent) {
            int here;
            volatile int result;
            if (parent)
                result = (&here < parent);
            else
                result = StackGrowsUp(&here);
            return result;
        }
        int main (int argc, char *argv[]) {
            return StackGrowsUp(0);
        }

powerpc clang 22.1.6 -O2 inlines both StackGrowsUp calls into main
and reorders the "int here;"s.  The check gives the wrong answer.

I believe that the stack grows down everywhere but hppa.  This diff
won't work if someone finds a new arch where the stack grows up.  Tcl
8.6 and 9 don't have this check.  Most distros don't package 8.5, so
I don't know if anyone has an existing fix.

Is this ok?
--gkoehler 

Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/tcl/8.5/Makefile,v
diff -u -p -r1.49 Makefile
--- Makefile    26 Sep 2023 12:02:04 -0000      1.49
+++ Makefile    1 Dec 2026 22:50:52 -0000
@@ -3,7 +3,7 @@ COMMENT =               Tool Command Language
 DISTNAME =             tcl8.5.19
 PKGNAME =              tcl-8.5.19
 PKGSTEM =              tcl-8.5
-REVISION =             6
+REVISION =             7
 SHARED_LIBS =          tcl85 1.8
 CATEGORIES =           lang lang/tcl
 HOMEPAGE =             http://www.tcl-lang.org/
@@ -39,6 +39,16 @@ CONFIGURE_ARGS +=    --includedir="${PREFIX
                        && $$(INSTALL_DATA) libtcl85.a 
$$(LIB_INSTALL_DIR)/libtcl85.a \
                        && (cd $$(LIB_INSTALL_DIR) ; $$(RANLIB) libtcl85.a)' \
                        SHLIB_VERSION="${LIBtcl85_VERSION}"
+
+# Tcl 8.5 "checking if the C stack grows upwards in memory" might be
+# wrong if CC inlines the function.  If so, any Tcl command fails,
+# "out of stack space (infinite loop?)".  The only OpenBSD arch with
+# MACHINE_STACK_GROWS_UP in <machine/param.h> is hppa.
+.if ${MACHINE_ARCH} == "hppa"
+CONFIGURE_ENV +=       tcl_cv_stack_grows_up=yes
+.else
+CONFIGURE_ENV +=       tcl_cv_stack_grows_up=no
+.endif
 
 ALL_TARGET =           all libtcl85.a
 

Reply via email to