All selectors unrecognised when invoking Objective-C methods using the LLVM ExecutionEngine All selectors unrecognised when invoking Objective-C methods using the LLVM ExecutionEngine objective-c objective-c

All selectors unrecognised when invoking Objective-C methods using the LLVM ExecutionEngine


Objective-C uses specially-named globals to refer to selectors, and the linker and ObjC runtime have special knowledge of these globals which makes everything work normally. lli has no knowledge of Objective-C; therefore, the ObjC runtime never runs its special handling for the globals in question.

Off the top of my head, I have no idea what exactly you need to do to make it work, though.


After a few months of research on this topic I would like to share my findings. To quote myself:

It is possible to run Objective-C and Swift code with LLVM JIT on macOS system. One way to make it work is to subclass a SectionMemoryManager used by LLVM JIT engine, intercept memory sections related to Objective-C as they get allocated in memory, find the Objective-C metadata in these sections, parse the Objective-C class information from this metadata, use a number of Objective-C Runtime API methods to register found Objective-C classes in Objective-C runtime.

Although this approach only targets Objective-C code and the Objective-C Runtime, it also seems to enable support for combined Swift and Objective-C code: given that the Objective-C classes are registered, Swift code with enabled Objective-C interoperability seems to run without any major issues in LLVM JIT.

See full article for the details:

LLVM JIT, Objective-C and Swift on macOS: knowledge dump.