I ran into the same/similar issue a while ago (and posted the same question here) but since I got no response I eventually came up with the following solution.
Create a JITDylib containing absolute addresses to all your runtime functions like cosf, sinf, etc and then link that JITDylib to each new JITDylib that needs those functions.
This can be done by defining some absolute symbols as follows:
functionFlags |= llvm::JITSymbolFlags::Callable;
functionFlags |= llvm::JITSymbolFlags::Exported;
functionFlags |= llvm::JITSymbolFlags::Absolute;
//This will map the “sinf” symbol to the absolute address of std::sinf
//Do this for every runtime library symbol that you need.
runtimeSymbols[executionSession->intern(“sinf”)] = llvm::JITEvaluatedSymbol(reinterpret_castllvm::JITTargetAddress(&std::sinf), functionFlags);
runtimeSymbols[executionSession->intern(“cosf”)] = llvm::JITEvaluatedSymbol(reinterpret_castllvm::JITTargetAddress(&std::cosf), functionFlags);
//Create your runtime dylib and define the absolute symbols
llvm::orc::JITDylib& runtimeLibraryDyLib = executionSession->createJITDylib(“runtimeLibrary”, false);
Then on the JITDylib that you are building:
Another crash/issue you may run into on Windows that is related to your question is described in this bug report (there is a workaround): https://bugs.llvm.org/show_bug.cgi?id=40074
You may already be doing this, but on Windows you also need to enable some workarounds on your RTDyldObjectLinkingLayer in order for your compiled function symbols to be found at all:
I hope this helps.
Machiel van Hooren