Trouble getting symbols in current process linked to ORCJit

I’m using the ORCJit to execute some code generated by MLIR, and I can’t seem to get some symbols defined in my current process to be visible to the JIT. I’m creating the JIT like this:

  llvm::orc::JITDylib &mainJD = jit->getMainJITDylib();

but seeing the following output when executing the code through the JIT:

JIT session error: Symbols not found: [ mgpuLaunchKernel, mgpuModuleGetFunction, mgpuModuleLoad, mgpuModuleUnload, mgpuStreamCreate, mgpuStreamDestroy, mgpuStreamSynchronize ]

I’m quite sure that these symbols are in my process. Checking objdump -TC reports that they are in a library I’m linking with:

 objdump -TC build/lib/  | grep mgpu
000000000130d870 g    DF .text	0000000000000005  Base        mgpuModuleUnload
000000000130da60 g    DF .text	0000000000000005  Base        mgpuStreamDestroy
000000000130da00 g    DF .text	000000000000005b  Base        mgpuStreamCreate
000000000130d940 g    DF .text	00000000000000b2  Base        mgpuLaunchKernel
000000000130d7c0 g    DF .text	00000000000000ab  Base        mgpuModuleLoad
000000000130d880 g    DF .text	00000000000000b3  Base        mgpuModuleGetFunction
000000000130da70 g    DF .text	000000000000009a  Base        mgpuStreamSynchronize

and the following code before the Jit invocation:

  std::cout << "found mgpuLaunchKernel at address " << dlsym(RTLD_DEFAULT, "mgpuLaunchKernel") << std::endl;                                
  std::cout << "found mgpuModuleLoad at address " << dlsym(RTLD_DEFAULT, "mgpuModuleLoad") << std::endl;                                      
  std::cout << "found mgpuModuleUnload at address " << dlsym(RTLD_DEFAULT, "mgpuModuleUnload") << std::endl;                                 
  std::cout << "found mgpuModuleGetFunction at address " << dlsym(RTLD_DEFAULT, "mgpuModuleGetFunction") << std::endl;                       
  std::cout << "found mgpuStreamCreate at address " << dlsym(RTLD_DEFAULT, "mgpuStreamCreate") << std::endl;                                 
  std::cout << "found mgpuStreamDestroy at address " << dlsym(RTLD_DEFAULT, "mgpuStreamDestroy") << std::endl;                               
  std::cout << "found mgpuStreamSynchronize at address " << dlsym(RTLD_DEFAULT, "mgpuStreamSynchronize") << std::endl;


found mgpuLaunchKernel at address 0x7f0bcd955940
found mgpuModuleLoad at address 0x7f0bcd9557c0
found mgpuModuleUnload at address 0x7f0bcd955870
found mgpuModuleGetFunction at address 0x7f0bcd955880
found mgpuStreamCreate at address 0x7f0bcd955a00
found mgpuStreamDestroy at address 0x7f0bcd955a60
found mgpuStreamSynchronize at address 0x7f0bcd955a70

So i’m not sure where to go. Based on the documentation, the DynamicSearchLibraryGenerator::getForCurrentProcess uses dlsym internally.

I was able to get it to work. I had not correctly added the library these symbols were defined in to the search path of dlopen.