great...

On Sun, Jun 21, 2020 at 8:45 PM Conor Williams <conor.williams@gmail.com> wrote:
great... i will apply those and repaste

On Sun, Jun 21, 2020 at 8:34 PM <ori@eigenstate.org> wrote:
> ok... attached are the compiler listings...

First off, let's keep this on the list so that anyone can help out.

> i have made very few changes to the code so
> no diff yet...
> -----------------------------
> #                  file.6
> -----------------------------
> cc -c -O    -DBUILD_tcl  -I"." -I/usr/glenda/tcl8.6.10/unix
> -I/usr/glenda/tcl8.6.10/generic -I/usr/glenda/tcl8.6.10/libtommath
>  -DPACKAGE_NAME=\"tcl\" -DPACKAGE_TARNAME=\"tcl\" -DPACKAGE_VERSION=\"8.6\"
> -DPACKAGE_STRING=\"tcl\ 8.6\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1
> -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1
> -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DNO_VALUES_H=1 -DNO_DLFCN_H=1
> -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=0 -D_REENTRANT=1 -D_THREAD_SAFE=0
> -DTCL_CFGVAL_ENCODING=\"iso8859-1\" -DHAVE_NET_ERRNO_H=1 -DHAVE_ZLIB=1
> -DMODULE_SCOPE=extern -DTCL_SHLIB_EXT=\"\" -DNDEBUG=1 -DTCL_CFG_OPTIMIZED=1
> -DTCL_TOMMATH=1 -DMP_PREC=4 -DTCL_WIDE_INT_TYPE=long\ long
> -DHAVE_STRUCT_DIRENT64=0 -DHAVE_GETCWD=1 -DHAVE_OPENDIR=1 -DHAVE_STRTOL=1
> -DHAVE_WAITPID=1 -DNO_GETWD=1 -DNO_REALPATH=1 -DNEED_FAKE_RFC2553=0
> -DHAVE_TERMIOS_H=1 -DHAVE_SYS_IOCTL_H=1 -DNO_FD_SET=1 -DHAVE_SYS_TIME_H=1
> -DTIME_WITH_SYS_TIME=1 -DHAVE_GMTIME_R=1 -DHAVE_LOCALTIME_R=1
> -DHAVE_MKTIME=1 -DHAVE_TIMEZONE_VAR=1 -DNO_FSTATFS=1 -Dsocklen_t=int
> -Dintptr_t=int -Duintptr_t=unsigned\ int -DNO_UNION_WAIT=1
> -DHAVE_SIGNED_CHAR=1 -DHAVE_PUTENV_THAT_COPIES=1 -DNO_ISNAN=1
> -DHAVE_SYS_IOCTL_H=1 -DTCL_UNLOAD_DLLS=1       -DMP_FIXED_CUTOFFS
> -DMP_NO_STDINT /usr/glenda/tcl8.6.10/generic/tclIOSock.c
>  /usr/glenda/tcl8.6.10/generic/tclIOSock.c:191[stdin:18411] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:191[stdin:18411] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:192[stdin:18412] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:203[stdin:18421] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:205[stdin:18423] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:210[stdin:18428] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:230[stdin:18440] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:230[stdin:18440] name not
> declared: AI_PASSIVE
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:233[stdin:18443] structure not
> fully declared addrinfo
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:240[stdin:18450] incompatible
> types: "IND CONST CHAR" and "INT" for op "AS"
> /usr/glenda/tcl8.6.10/generic/tclIOSock.c:255[stdin:18461] structure not
> fully declared addrinfo
> too many errors

First off, TCL seems to do

        #ifdef FOO_FEATURE
        #       thing
        #endif

That means that

        -DFOO_FEATURE=0

is the same as

        -DFOO_FEATURE=1

The exception I see is for threads, where undefined threadss means
turning threading on, and -DTCL_THREADS=0 means turn it off.

I removed the -DFOO=0 defines, and added -DTCL_THREADS=0. Note, it'd
be better to import lufia's pthreads.h code from the pull request on
9legacy, and enable all ape programs to use pthreads.

Other than that, I needed to make four changes:

        -DHAVE_NET_ERRNO_H=1:
                we don't have this
        -DNEED_FAKE_RFC2553=0:
                this breaks us
        -D_BSD_EXTENSION:
                we need to turn on some BSD functions. There's a good
                chance that you'll need -D_POSIX_SOURCE -D_SUSV2_SOURCE
                for some other code too; I find that pretty much any
                recent code that does nontrivial things wants these to
                be defined.
        -tclUnixPort.h:134 #include <sys/file.h>
                we don't have this, but there's no define around it;
                this works for the file I compiled, but probably breaks
                elsewhere; you'll probably need to look at what posix
                mandates is in here, and then implement it.

Running on 9front amd64. the command that worked for this file:

        cc -c -O -D_BSD_EXTENSION -DTCL_THREADS=0 -DBUILD_tcl -I"."
        -I/tmp/tcl8.7a3/unix -I/tmp/tcl8.7a3/generic
        -I/tmp/tcl8.7a3/libtommath -DPACKAGE_NAME=\"tcl\"
        -DPACKAGE_TARNAME=\"tcl\" -DPACKAGE_VERSION=\"8.6\"
        -DPACKAGE_STRING=\"tcl\ 8.6\" -DPACKAGE_BUGREPORT=\"\"
        -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1
        -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1
        -DNO_VALUES_H=1 -DNO_DLFCN_H=1 -DHAVE_SYS_PARAM_H=1
        -D_REENTRANT=1 -DTCL_CFGVAL_ENCODING=\"iso8859-1\"
        -DHAVE_ZLIB=1 -DMODULE_SCOPE=extern -DTCL_SHLIB_EXT=\"\"
        -DNDEBUG=1 -DTCL_CFG_OPTIMIZED=1 -DTCL_TOMMATH=1 -DMP_PREC=4
        -DTCL_WIDE_INT_TYPE=long\ long -DHAVE_GETCWD=1
        -DHAVE_OPENDIR=1 -DHAVE_STRTOL=1 -DHAVE_WAITPID=1 -DNO_GETWD=1
        -DNO_REALPATH=1 -DHAVE_TERMIOS_H=1 -DHAVE_SYS_IOCTL_H=1
        -DNO_FD_SET=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1
        -DHAVE_GMTIME_R=1 -DHAVE_LOCALTIME_R=1 -DHAVE_MKTIME=1
        -DHAVE_TIMEZONE_VAR=1 -DNO_FSTATFS=1 -Dsocklen_t=int
        -Dintptr_t=int -Duintptr_t=unsigned\ int -DNO_UNION_WAIT=1
        -DHAVE_SIGNED_CHAR=1 -DHAVE_PUTENV_THAT_COPIES=1 -DNO_ISNAN=1
        -DHAVE_SYS_IOCTL_H=1 -DTCL_UNLOAD_DLLS=1 -DMP_FIXED_CUTOFFS
        -DMP_NO_STDINT /tmp/tcl8.7a3/generic/tclIOSock.c

With this diff applied:

diff -urN tcl8.7a3/unix/tclUnixPort.h tcl8.7a3.new/unix/tclUnixPort.h
--- tcl8.7a3/unix/tclUnixPort.h Sun Jun 21 12:32:13 2020
+++ tcl8.7a3.new/unix/tclUnixPort.h     Sun Jun 21 12:33:16 2020
@@ -131,7 +131,7 @@
  *---------------------------------------------------------------------------
  */

-#include <sys/file.h>
+//#include <sys/file.h>
 #ifdef HAVE_SYS_SELECT_H
 #   include <sys/select.h>
 #endif