================
@@ -388,6 +395,23 @@
IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
if (!JB)
return JB.takeError();
JITBuilder = std::move(*JB);
+#ifdef __APPLE__
+ // On Darwin, thread_locals are lowered to emulated TLS, but the runtime
+ // (__emutls_get_address) lives in the compiler-rt builtins archive and
+ // nothing else in this process references it, so it isn't linked in and
+ // process-symbol lookup cannot find it. Taking its address here forces
+ // the archive member into the binary; defining it as an absolute symbol
+ // makes it visible to JIT'd code. In-process execution only: the address
+ // is meaningless in an out-of-process executor.
+ JITBuilder->setNotifyCreatedCallback([](llvm::orc::LLJIT &J) {
+ auto &JD = J.getProcessSymbolsJITDylib() ? *J.getProcessSymbolsJITDylib()
+ : J.getMainJITDylib();
+ return JD.define(llvm::orc::absoluteSymbols(
+ {{J.mangleAndIntern("__emutls_get_address"),
+ {llvm::orc::ExecutorAddr::fromPtr(&__emutls_get_address),
+ llvm::JITSymbolFlags::Exported}}}));
+ });
+#endif
----------------
lhames wrote:
Could you add a TODO to switch to native TLS on Darwin once clang-repl can
adopt the ORC runtime? That'll solve the "in-process-only" constraint here.
https://github.com/llvm/llvm-project/pull/208413
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits