Dynamically load numba AOT compiled library in C application

Hi everyone,

I’m doing experiments to investigate if a numba compiled library can be dynamically used in a C application. Currently, I compile python code using numba, keep the intermediate objects, manipulate the symbols of the object that contains the function and run the linking again. Consequently, the function with the prefix “cfunc” is a dynamic symbol in the resulting library and can be used by dlopen/dlsym in a C application. This works fine for basic functions like calculations.
However, functions that are listed as supported (like string split()) result in a segmentation fault in NRT_incref, called by split_withespace_impl. A similar error happens using other functions (upper(), …). I guess this occurs when the NRT memory system is involved. I debugged with lldb and saw the error happening in a “lock” instruction.

Two questions:

  1. Is there something to initialize that I’m missing?
  2. Is there a possibility to compile the llvm code with debug symbols? This would make searching easier.

I know, this is not the main goal of the numba project and not the main use case. However, I look forward to any comments. Thank you in advance.

Best regards

2 Likes

hello~ I am doing the same thing as you do!
Would you give me more details about how to expose the dynamic symbol of the “cfunc” in the resulting library?