Tk Source Code

View Ticket
Login
Ticket UUID: 85f316beb15108ac43b03fa6c8608e31f3ae5f92
Title: Tk 8.6.11 RC1 fails to produce static Wish with Aqua support
Type: Bug Version: Tk 8.6.11 RC1
Submitter: bagnon Created on: 2020-12-27 17:48:44
Subsystem: 83. Mac OS X Build Assigned To: nobody
Priority: 5 Medium Severity: Critical
Status: Closed Last Modified: 2020-12-31 01:51:45
Resolution: Fixed Closed By: dgp
    Closed on: 2020-12-31 01:51:45
Description:
After configuring in tk8.6.11/unix/ 

./configure --disable-shared --enable-threads --enable-64bit --enable-symbols --enable-aqua=yes --prefix=/Users/bagnon/Downloads/

The generated binary fails to start:

2020-12-27 18:44:44.406 wish8.6[23769:71033] -[TKApplication tkProcessEvent:]: unrecognized selector sent to instance 0x7fed19c240c0
2020-12-27 18:44:44.409 wish8.6[23769:71033] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TKApplication tkProcessEvent:]: unrecognized selector sent to instance 0x7fed19c240c0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff321ecb57 __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff6b0785bf objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff3226bbe7 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff321513bb ___forwarding___ + 1427
	4   CoreFoundation                      0x00007fff32150d98 _CF_forwarding_prep_0 + 120
	5   wish8.6                             0x000000010d51cc90 TkMacOSXEventsCheckProc + 432
	6   wish8.6                             0x000000010d6ae14d Tcl_DoOneEvent + 493
	7   wish8.6                             0x000000010d50f23f TkpInit + 623
	8   wish8.6                             0x000000010d42df94 Initialize + 3316
	9   wish8.6                             0x000000010d42d295 Tk_Init + 21
	10  wish8.6                             0x000000010d3de613 Tcl_AppInit + 51
	11  wish8.6                             0x000000010d415bd8 Tk_MainEx + 1288
	12  wish8.6                             0x000000010d3de5ce main + 78
	13  libdyld.dylib                       0x00007fff6c220cc9 start + 1
	14  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Other combinations (static, no Aqua), (shared libs, Aqua) seem to work well.
User Comments: jan.nijtmans added on 2020-12-31 01:14:37:

Don, feel free to merge, then. I won't be able to tomorrow, but don't let that stop you ... Thanks!


dgp added on 2020-12-31 01:02:28:
That patch is an effective fix for the reported problem on my Catalina system.

I testes a few other variations and didn't see any new troubles created by it.

jan.nijtmans added on 2020-12-31 00:30:44:

So, how about [2564d053] ?


marc_culler added on 2020-12-30 23:15:30:

Hi Jan,

Well, it doesn't help for this specific issue because your patch applies to main rather than core-8-6-branch. And, of course, there is no configure.ac for core-8-6-branch, so the change would have to be in configure.in and you would have to use your magical autoconf.

What needs to happen is that -ObjC needs to be added to the LDFLAGS for the WISH_EXE target in the case of a static build of Aqua Tk. I do not know how to do that, but I bet that you do.

This works:

$ export LDFLAGS="-ObjC"
$ ./configure --disable-shared --enable-threads --enable-64bit --enable-symbols --enable-aqua=yes
$ make
$ ./wish

If LDFLAGS is undefined or empty you get the abort shown in the ticket.

@dgp: it is interesting that this appeared way back in July. But that only makes it more mysterious. There was no change to the linker flags in that commit. And Apple is decidedly unhelpful. This is that they say:

An impedance mismatch between UNIX static libraries and the dynamic nature of Objective-C can cause category methods in static libraries to not be linked into an app, resulting in "selector not recognized" exceptions when the methods aren't found at runtime.

I do own a multimeter, but I have no idea how to measure the impedance of a UNIX static library nor of the dynamic nature of Objective-C. I guess Apple engineers get some training that is not available to the rest of us.


jan.nijtmans added on 2020-12-30 22:22:02:

Does this help?: [afdc682b].


dgp added on 2020-12-30 19:08:01:
bisecting locates the regression to the merging of the idle_curiosity
branch on July 18.

marc_culler (claiming to be Marc Culler) added on 2020-12-30 11:32:33:
@bagnon: I agree that it is mysterious.  But I have no explanation.

Are you suggesting that a patch is needed for the configure script?  If so,
can you provide one?

bagnon added on 2020-12-29 22:04:29:
Thanks Marc, worked like a charm.

I guess -ObjC needs to be then added to the configure LDFLAGS.

What I do not get then is how 8.6.10 and 8.7.a3 compile well in static form without this -ObjC.

marc_culler (claiming to be Marc Culler) added on 2020-12-29 21:03:38:

This is just a guess, since I have never tried building Wish that way: maybe it would help to add the -ObjC flag.

According to this page

Passing the -ObjC option to the linker causes it to load all members of static libraries that implement any Objective-C class or category. This will pickup any category method implementations. But it can make the resulting executable larger, and may pickup unnecessary objects. For this reason it is not on by default.