<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Machiel, thanks for sharing your solution and the workarounds for
RTDyldObjectLinkingLayer on Windows!<br>
<br>
As in the other "Undefined symbols" thread, you might want to have a
look at symbol generators. They offer an easy way to emit additional
symbols to a Dylib's symbol table. Two examples for this in ORCv2
are:<br>
* DynamicLibrarySearchGenerator in
llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h<br>
* ReexportsGenerator in llvm/include/llvm/ExecutionEngine/Orc/Core.h<br>
<br>
Of course, depending on your use-case a common runtime Dylib can be
a suitable solution too. <br>
<br>
Best<br>
Stefan<br>
<br>
<div class="moz-cite-prefix">Am 02.01.19 um 22:31 schrieb Machiel
van Hooren via llvm-dev:<br>
</div>
<blockquote type="cite"
cite="mid:CAP6HzX9hi8P9Xetsm6F3XSc7sHph-ivK-GDOS8xOpMDFLGBOrg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div>Hi Marcus,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div>This can be done by defining some absolute symbols as
follows:</div>
<div><br>
</div>
<div>llvm::JITSymbolFlags functionFlags;</div>
<div>functionFlags |= llvm::JITSymbolFlags::Callable;</div>
<div>functionFlags |= llvm::JITSymbolFlags::Exported;</div>
<div>functionFlags |= llvm::JITSymbolFlags::Absolute;</div>
<div><br>
</div>
<div>llvm::orc::SymbolMap runtimeSymbols;</div>
<div>//This will map the "sinf" symbol to the absolute address
of std::sinf</div>
<div>//Do this for every runtime library symbol that you need.</div>
<div>runtimeSymbols[executionSession->intern("sinf")] =
llvm::JITEvaluatedSymbol(reinterpret_cast<llvm::JITTargetAddress>(&std::sinf),
functionFlags);</div>
<div>runtimeSymbols[executionSession->intern("cosf")] =
llvm::JITEvaluatedSymbol(reinterpret_cast<llvm::JITTargetAddress>(&std::cosf),
functionFlags);</div>
<div><br>
</div>
<div>//Create your runtime dylib and define the absolute
symbols</div>
<div>llvm::orc::JITDylib& runtimeLibraryDyLib =
executionSession->createJITDylib("runtimeLibrary",
false);</div>
<div>runtimeLibraryDyLib.define(llvm::orc::absoluteSymbols(runtimeSymbols));</div>
<div><span style="white-space:pre"> </span></div>
<div>Then on the JITDylib that you are building:</div>
<div><br>
</div>
<div>dylib.addToSearchOrder(runtimeLibraryDyLib, false);</div>
<div><br>
</div>
<div>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): <a
href="https://bugs.llvm.org/show_bug.cgi?id=40074"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=40074</a></div>
<div><br>
</div>
<div>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:</div>
<div>objectLinkLayer->setAutoClaimResponsibilityForObjectSymbols(true);</div>
<div>objectLinkLayer->setOverrideObjectFlagsWithResponsibilityFlags(true);</div>
<div><br>
</div>
<div>I hope this helps.</div>
<div><br>
</div>
<div>Regards,</div>
<div><br>
</div>
<div>Machiel van Hooren</div>
<div><span style="white-space:pre"> </span></div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="https://weliveindetail.github.io/blog/">https://weliveindetail.github.io/blog/</a>
<a class="moz-txt-link-freetext" href="https://cryptup.org/pub/stefan.graenitz@gmail.com">https://cryptup.org/pub/stefan.graenitz@gmail.com</a></pre>
</body>
</html>