graememacdonald at fastmail.fm
2014-Dec-24 02:19 UTC
[LLVMdev] MCJIT Obj-c [NSApplication sharedApplication] unrecognized selector
Hi, I'm trying to use MCJIT to run some c++ code that has Objective-C++ calls to standard OSX frameworks in it. I'm fairly new to this so please forgive any naive assumptions I may be making. I don't have a deep understanding of it, but I've been hacking at it for the past week and have had some success running basic jit'd C++ code (excluding objective-c). I'm using llvm 3.6 from about a week or so ago. When I first tried to run some code that depends on the Cocoa framework I encountered a "Program used external function...could not resolve" error. In order to resolve that I loaded the Cocoa framework using DynamicLibrary::LoadLibraryPermanently. That got me passed that and got the code to execute to the point of encountering [NSApplication sharedApplication] (which I believe is the first occurrence of an actual selector call). From that I got the error listed below. I found an old email (2012) to the list where someone was using the OLD JIT and encountered an issue like this but I'm not sure how it might apply to MCJIT. I'm wondering then, is calling Objective-C frameworks from MCJIT'd code supported/doable? If so, is DynamicLibrary::LoadLibraryPermantly a proper way to load the framework? Any thoughts/tips are appreciated and I can share my setup code if someone would like to take a look at it. Thanks! THE ERROR: 2014-12-23 17:02:54.215 exe2.o[20538:507] *** NSForwarding: warning: selector (0x10c5f5561) for message 'sharedApplication' does not match selector known to Objective C runtime (0x7fff94565368)-- abort 2014-12-23 17:02:54.215 exe2.o[20538:507] +[NSApplication sharedApplication]: unrecognized selector sent to class 0x7fff7a19f078 2014-12-23 17:02:54.216 exe2.o[20538:507] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSApplication sharedApplication]: unrecognized selector sent to class 0x7fff7a19f078' *** First throw call stack: ( 0 CoreFoundation 0x00007fff89a9d25c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff8b000e75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff89aa002d +[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff899fb272 ___forwarding___ + 1010 4 CoreFoundation 0x00007fff899fadf8 _CF_forwarding_prep_0 + 120 5 ??? 0x000000010ec9bc3b 0x0 + 4543069243 6 ??? 0x000000010ec9bb64 0x0 + 4543069028 7 ??? 0x000000010b632076 0x0 + 4486013046 8 exe2.o 0x0000000109c096c1 _ZN4llvm5MCJIT11runFunctionEPNS_8FunctionERKNSt3__16vectorINS_12GenericValueENS3_9allocatorIS5_EEEE + 257 9 exe2.o 0x0000000109ad44b3 _ZN4llvm15ExecutionEngine17runFunctionAsMainEPNS_8FunctionERKNSt3__16vectorINS3_12basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEENS8_ISA_EEEEPKPKc + 1523 10 exe2.o 0x000000010ac92bcc main + 204 11 libdyld.dylib 0x00007fff8cdf15fd start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException Abort trap: 6 -- graememacdonald at fastmail.fm