Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-06-23
14:33 • Closed ticket [3508771fff]: load tclreg.dll in cygwin tclsh plus 6 other cha... artifact: 4b0b192dc4 user: nijtmans
2012-06-22
15:33 • Ticket [3508771fff]: 5 changes artifact: 3726fc6649 user: nijtmans
2012-06-13
21:53 • Open ticket [3508771fff]. artifact: 64e3b8b3f8 user: nijtmans
21:53 • Ticket [3508771fff]: 4 changes artifact: 95d76ae7bd user: nijtmans
2012-04-26
22:14 • Ticket [3508771fff]: 4 changes artifact: b1023ea033 user: nijtmans
22:12 • Closed ticket [3508771fff]. artifact: 067e3ef7e7 user: dgp
22:01 • Pending ticket [3508771fff]. artifact: b18b1fcd55 user: nijtmans
21:57 • Ticket [3508771fff]: 4 changes artifact: b7c6bf50fd user: wordtech
21:47 • Ticket [3508771fff]: 4 changes artifact: 4854f0fcde user: dgp
21:37 • Ticket [3508771fff]: 4 changes artifact: 3b560374ae user: dgp
21:35 • Ticket [3508771fff]: 4 changes artifact: 67f624b9d7 user: dgp
21:27 • Ticket [3508771fff]: 4 changes artifact: 4f96d7150a user: dgp
21:17 • Ticket [3508771fff]: 4 changes artifact: 4e87c8559d user: wordtech
20:01 • Open ticket [3508771fff]. artifact: 7fd1db16fd user: nijtmans
19:54 • Ticket [3508771fff]: 4 changes artifact: 3bd568625a user: dgp
19:48 • Pending ticket [3508771fff]. artifact: e675c42bba user: nijtmans
19:48 • Ticket [3508771fff]: 4 changes artifact: 2e95b6bc13 user: nijtmans
19:35 • Closed ticket [3508771fff]. artifact: 17d9c82d71 user: dkf
19:19 • Open ticket [3508771fff]. artifact: fa5dfbe7ac user: dkf
17:47 • Pending ticket [3508771fff]. artifact: 41928981c2 user: nijtmans
17:47 • Ticket [3508771fff]: 5 changes artifact: cde3b6c423 user: nijtmans
17:40 • Ticket [3508771fff]: 4 changes artifact: 7bca7aa7d1 user: dkf
17:38 • Ticket [3508771fff]: 4 changes artifact: cf6bc8f03f user: nijtmans
17:36 • Ticket [3508771fff]: 4 changes artifact: 1a1b0cc81f user: dkf
07:57 • Ticket [3508771fff]: 6 changes artifact: 786c448ed3 user: wordtech
2012-04-25
20:33 • Open ticket [3508771fff]. artifact: 4a21b6f543 user: nijtmans
2012-03-22
17:19 • Ticket [3508771fff]: 4 changes artifact: 302f6891cc user: dkf
17:06 • Pending ticket [3508771fff]. artifact: 73502065e1 user: nijtmans
17:05 • Ticket [3508771fff]: 6 changes artifact: 5684322273 user: nijtmans
16:39 • Ticket [3508771fff]: 4 changes artifact: 520f3b94eb user: nijtmans
16:26 • Ticket [3508771fff]: 6 changes artifact: 81851ae747 user: dkf
2012-03-20
17:54 • Ticket [3508771fff]: 1 change artifact: 3570e4020c user: nijtmans
17:54 • Ticket [3508771fff]: 4 changes artifact: cf232d367c user: nijtmans
2012-03-19
15:35 • New ticket [3508771fff]. artifact: c40cd30b32 user: nijtmans

load tclreg.dll in cygwin tclsh

Closed / Fixed3508771fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 14 years ago
Descriptionplain2012-03-19 15:35:20
Using the stubs mechanism, it should be possible to load tclreg.dll
(compiled with mingw or vc++) in a tclsh compiled with cygwin.
I tried it, and it almost works, but not quite.....

tclreg.dll calls the function TclWinGetPlatformId(), inits init
function:
    if (TclWinGetPlatformId() == VER_PLATFORM_WIN32_NT) {
regWinProcs = &unicodeProcs;
    } else {
regWinProcs = &asciiProcs;
    }
 which resides in slot 9 of tclIntPlatStubs. But
cygwin uses the UNIX stubs, which has TclpCreateTempFile()
in slot 9. So, everything seems to work, but in fact a
temporary file is created, and a handle to it
is returned. This handle is != VER_PLATFORM_WIN32_NT,
so this instructs tclreg.dll to use the ASCII variants
of the registry functions.

Solution: move TclpCreateTempFile from slot 9
to slot 22, and put TclWinGetPlatformId in
slot 9. On UNIX, TclWinGetPlatformId  does not
exist, so use some #define to map it back
to TclpCreateTempFile on non-cygwin.

The same potential problem exists with
the functions Tcl_WinUtfToTChar and
Tcl_WinTCharToUtf, which are in the
public API. TclWinGetPlatformId is not
public, but because it is used in tclreg.dll I
would like to make an exception for that.
nijtmansplain2012-03-20 17:54:27
Implementation for TclWinGetPlatformId,
Tcl_WinUtfToTChar and Tcl_WinTCharToUtf
done and committed to core-8-4-branch,
core-8-5-branch and trunk.

(Since cygwin now switched to tcl 8.5, it
would not have been necessary to do it
for Tcl 8.4, but it worked, so why not....)

Added a dummy TclWinCPUID too, because
this function is in slot 29, the last win32
slot. win32 has more slots than unix, and
this way all unused slots will be set to
NULL in stead of some random value.
And... TclWinCPUID is intel-specific, not
Windows-specific: it can be implemented
on UNIX and cygwin as well, the only
requirement is that it has an Intel (or AMD)
processor. The default implementation
simply returns TCL_ERROR.

The functions Tcl_WinUtfToTChar and
Tcl_WinTCharToUtf had the problem
that MAC_OSX has all UNIX functions
as well, plus its own. Adding UNIX
stub entries would mean that the
two functions Tcl_MacOSXOpenBundleResources
and Tcl_MacOSXOpenVersionedBundleResources
would shift up!!  So I used the trick to put
the two new functions in the place of the
max functions. Tricky, but it works.

So the Tcl_MacOSXOpenBundleResources
stub entry has its own function on OSX, it
contains the function Tcl_WinUtfToTChar
on cygwin, and it has NULL for other
UNIXes. This makes the function
Tcl_WinUtfToTChar effectively hidden
from Cygwin, but - hey - that's exactly
what we want because it should only
be callable by win32 extensions.

Keeping open, because tclInt.decls
contains more functions that could
be called by win32 extensions.
nijtmans Ticket [3508771fff]: 1 change [History diff]2012-03-20 17:54:38
dkfplain2012-03-22 16:26:11
Note that this BROKE THE OSX BUILD on all the primary branches. Bumping prio until either this is rolled back (/shuffled off onto side branch) or fixed so that in appropriate leakage between platform-specific APIs no longer happens. (The name of the symbol is also inappropriate for a Unix API.)

Undefined symbols:
  "_TclWinGetPlatformId", referenced from:
      _tclIntPlatStubs in tclStubInit.o
ld: symbol(s) not found
nijtmansplain2012-03-22 16:39:20
OK, having a look.
nijtmansplain2012-03-22 17:05:57
Unfortunately, Cygwin is UNIX, but it must have some Windows
API's as well in order to be able to load win32 extensions. So, yes, TclWinGetPlatformId is appropriate. Cygwin is the only
platform where this is actually implemented, for all
other platforms the stub entry for TclpCreateTempFile is in
this slot.

Should be fixed now. Thanks!
nijtmans Pending ticket [3508771fff]. [History diff]2012-03-22 17:06:56
dkfplain2012-03-22 17:19:20
Trunk compiles fine now. Thanks
nijtmansplain2012-04-25 20:33:51
For Tcl, all win32 stub functions are implemented now for cygwin. Doing the
same for the most important ones for Tk now (in the bug-3508771) branch
wordtechplain2012-04-26 07:57:03
Bumping the priority of this bug to 9 and changing resolution to "none" because the recent changes to tclStubInit.c cause a segfault on Wish on OS X from trunk, and (according to dkf) on 8.5 as well. Wish segfaults on startup when trying to run TclMacOSXNotifierAddRunLoopMode in the notifier. I've confirmed that the changes in this bug report are the culprit because when I back them out of tclStubInit.c and revert it to its 2011 version, Wish starts up fine. I'm reluctant to patch tclStubInit.c  because the changes are so extensive and I don't fully understand them, and I don't want to undo all the work you've put in here--but PLEASE take another look and ensure that these changes don't crash Wish on OS X. I will be glad to test any changes you make.
dkfplain2012-04-26 17:36:30
Context: https://core.tcl.tk/tcl/annotate?checkin=3caedf05df5f633f&filename=generic/tclStubInit.c

There's a lot of churn in the OSX part, which is weird as OSX is definitely disjoint from Cygwin. (There's no reason for *ever* calling TclWinConvertError on OSX!)
nijtmansplain2012-04-26 17:38:43
OK, I'll have a look
dkfplain2012-04-26 17:40:45
The simplest fix is to just roll the changes to tclInt.decls back and rebuild. After all, OSX is a supported platform that was broken by this, and Cygwin is not a supported platform (especially if trying to do a mixed build).
nijtmansplain2012-04-26 17:47:15
Should be fixed now.
> Cygwin is not a supported
That's what I'm trying to change, and I must say that
it already is working quite well: 99%
nijtmans Pending ticket [3508771fff]. [History diff]2012-04-26 17:47:34
dkfplain2012-04-26 19:19:12
That fixed it for tk-cocoa-8-5-backport branch. Main Tk core-8-5-branch doesn't work currently; it's missing definitions for all those Win functions you've just added. :-)

Not tested the 8.6 code yet; that's next...
dkfplain2012-04-26 19:35:05
allow_comments - 1

Works with Tk 8.6 too, provided I comment out the current unix entries for the tkPlat interface in tk.decls and run 'make genstubs' first. That is, it's the same problem as is on the 8.5 branch and it should be simple to fix (compat functions that Tcl_Panic would be step 1...)

For future reference, adding stuff to (or rearranging!) a platform API when you can't build and test on that platform is a good way to get into trouble. Some things are *incredibly* finicky...
nijtmansplain2012-04-26 19:48:46
Should be fixed now.
> For future reference, adding stuff to (or rearranging!) a platform API when
> you can't build and test on that platform is a good way to get into
> trouble. Some things are *incredibly* finicky...
Yes, I know. But I simply don't have access to OSX, so I don't know
what to do about that, other than being very carefull. Apparently
I am not carefull enough. The trouble comes from the fact
that each platform has its own stub table which is organized
differently. It would be much easier if there was only one
stub table without that many modifications per platform,
but it's not easy to change that. At least CYGWIN shows
this pain, which I solved by combining the windows
and UNIX stub tables into one. Making a separate
table for CYGWIN would only compicate things more ;-(

Anyway, I hope it works now, otherwise please let me know!
nijtmansplain2012-04-26 19:48:47
allow_comments - 0
dgpplain2012-04-26 19:54:14
Tcl build is broken on unix on 8.5 and trunk.

gcc -O2  -pipe    -Wl,--export-dynamic  tclAppInit.o -L/home/dgp/fossil/tcl8.5/unix -ltcl8.5 -ldl  -lieee -lm  \
                -Wl,-rpath,/home/dgp/x86_64/linuxoldld/lib -o tclsh
/home/dgp/fossil/tcl8.5/unix/libtcl8.5.a(tclStubInit.o):(.data.rel+0x8a8): undefined reference to `TclMacOSXGetFileAttribute'
/home/dgp/fossil/tcl8.5/unix/libtcl8.5.a(tclStubInit.o):(.data.rel+0x8c0): undefined reference to `TclMacOSXMatchType'
/home/dgp/fossil/tcl8.5/unix/libtcl8.5.a(tclStubInit.o):(.data.rel+0x8c8): undefined reference to `TclMacOSXNotifierAddRunLoopMode'
collect2: ld returned 1 exit status

NULLing out the undefined routines appears
to be an effective fix, but I have no confidence
poking around here without a lot more review.
nijtmansplain2012-04-26 20:01:32
Thanks! This should be fixed now.
wordtechplain2012-04-26 21:17:33
Still can't build trunk on OS X:  

/Users/kevin/tcl-tk-fossil/tcl/generic/tclStubInit.c:1349: error: ‘Tcl_ZlibStreamGetZstreamp’ undeclared here (not in a function)
dgpplain2012-04-26 21:27:50
trunk checkins after 2e12143e3906901f7fe9
have introduced a segfault in test event-13.1
in a --enable-symbols=mem build of Tcl.
dgpplain2012-04-26 21:35:28
Hold on that claim.
dgpplain2012-04-26 21:37:44
After bisecting, I can't repro it anymore.
Can only guess I didn't have a fully clean build.
dgpplain2012-04-26 21:47:50
Remaining problem is just a compiler warning
(this one from 8.5 branch tip):

tclStubInit.c:513: warning: initialization from incompatible pointer type
wordtechplain2012-04-26 21:57:36
A fresh checkout of trunk builds and runs cleanly on OS X--sorry for the false alarm. Must have been an issue with my setup. Thanks for the fixes.
nijtmansplain2012-04-26 22:01:56
>tclStubInit.c:513: warning: initialization from incompatible pointer type

Should be fixed now as well. Please confirm that everything is fixed now.
dgpplain2012-04-26 22:12:13
allow_comments - 1

Appears good now.
nijtmansplain2012-04-26 22:14:07
Many thanks to all!
nijtmansplain2012-06-13 21:53:04
It turns out that loading dde.dll in cygwin still
doesn't work completely. As dde client there are
no problems, but as dde server no events are
handled at all. The reason is clear: the cygwin
(unix) event loop doesn't handle win32 events,
simply because it doesn't know anything
about it.

So, let's extend the cygwin notifier to do that

First attempt committed in bug-3508771
branch. Still incomplete.
nijtmansplain2012-06-13 21:53:06
allow_comments - 0
nijtmansplain2012-06-22 15:33:36
First working version committed of Cygwin
notifier (branch bug-3508771), which can
handle both Windows and UNIX event.s.
nijtmansplain2012-06-23 14:33:15
allow_comments - 1

Notifier modifications now committed to all open branches.

So, the Cygwin port can now handle win32 events, when
compiled with --enable-threads
Log in (anonymous is fine) to add a comment.