Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCL9 support #351

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

dlmiles
Copy link
Contributor

@dlmiles dlmiles commented Oct 21, 2024

Initial attempt at TCL9 support. It builds with 8.6 and 9.0 and appears to run ok, re batch script.

The most recent 4 commits still need work and resolution

  • tkcon.tcl was butchered, removal of ::tk::unsupported items, needs impact assessment
  • use of $::tk_platform (read from migration notes)
  • better ClientData handling in magic.h with TkTcl and non-TkTcl builds, ideally the tcl.h version should always have first opportunity to define this type, but right now magic.h appears to go first even in TkTcl enabled builds.
  • no time has been spent on checking Tk/X11 UI is fully working
  • more checking of tcltk/*.tcl scripts, I could not find any use of octal strings of tilde $HOME expansion

Due to the above drafting status only.

Example command sequence to build and pickup as alternative version

tar -zxvf tcl9.0.0-src.tar.gz
cd tcl9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9
make install
    
tar -zxvf tk9.0.0-src.tar.gz
cd tk9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9 --with-tcl=/opt/tktcl9/lib
make install
    
cd magic
./configure --with-tk=/opt/tktcl9/lib --with-tcl=/opt/tktcl9/lib

Now a (void *) but previously an integer.

These macros resolve the codebase allowing it to be built against both
tcl8 (8.5, 8.6) and tcl9 (9.0).

tar -zxvf tcl9.0.0-src.tar.gz
cd tcl9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9
make install

tar -zxvf tk9.0.0-src.tar.gz
cd tk9.0.0/unix
./configure --enable-symbols --prefix=/opt/tktcl9 --with-tcl=/opt/tktcl9/lib
make install

cd magic
./configure --with-tk=/opt/tktcl9/lib --with-tcl=/opt/tktcl9/lib
Modern compiler have support for 'offsetof' keyword.
Legacy compiler support macro provided by TCL from a time when 'const'
did not exist.
Legacy compiler support macro provided by TCL from a time when 'const'
did not exist.

This looks like it was put in place around the time of TCL 8.4
(from 2002 until 2013) which introduced APIs with 'const' types,
that were previously non-const.  Probably due to legacy compiler
support across target platforms at the time.

Since the minimum TCL level is hardwired to 8.5 (from 2007 until
2016) it does not seem like that compatiblity is a current
requirement.
Tk_ImageType.createProc() uses new Tcl_Size type now.
Header files documentation indicates the macros are of type ClientData
but previously did not cast to ensure that. So now follow this intention.
The Tcl_Exit() replacement proc takes charge of calling exit()

So this function can be easily migrated to libc atexit() which will
now run during exit() not just before.  Which seems ok for the purpose
of restoring the termios state of the tty.

This solution seems compatible with TCL8 as well so all calls to this
removed API are removed.

Note this patch also removes the invalidation (of the callback so
the deefault use of Tcl_Exit() is restored) before returning from
this function.  atexit() usage can not be invalidated after
registration but that can be controlled with application flag
checked inside the callback function if needed.
I have observed scenarios where I need to issue 'reset' manually
after exiting magic, still understanding better the build types
and scenarios that triggers this.
This API uses address of operator to Tcl API with (int) type, but
does not use Tcl_Size in TCL9, it remained an (int) type.
In the TCL8 to TCL9 porting information it was indicated the
sentinal NULL termination should be cast (char *) with API
call Tcl_AppendResult().

This was already in place for most of the codebase this
resolves the last few places.
This seems like it has 2 use cases.

Internal console management around reprinting command prompt, but many
 modes of operation delegate the prompt processing to tkcon or readline.
Process termination to restore the termios.
This did not work as expected.  Maybe that indicate this should have
a slighlt restructure so the tcl.h definition is always given a chance
to provide type.

Or maybe autoconf should detect the type and provide in config.h ?
This reverts commit 8adbd75760aeeb4f39507dcd3e746287381b7b38.
@dlmiles dlmiles force-pushed the master-upstream-20241021-tcl9 branch 2 times, most recently from 918b445 to f49e783 Compare October 21, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant