[clang] [clang-repl] Disable EmulatedTLS on Windows (PR #127468)

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 17 02:23:56 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Aaron  Jomy (aaronj0)

<details>
<summary>Changes</summary>

When running the clang-repl interpreter on windows, calling

```cpp
Interpreter->Process(R"(
                     #include <iostream>
                     void f1(std::string &s) { std::cout<< s.c_str(); };
                      )");
```

Does not work, due to missing emulated tls symbols `__emutls_get_address` and `__emutls_v._Init_thread_epoch`. This requires disabling the option when creating the executor, in the `orc::JITTargetMachineBuilder`

Ping @<!-- -->vgvassilev 

---
Full diff: https://github.com/llvm/llvm-project/pull/127468.diff


1 Files Affected:

- (modified) clang/lib/Interpreter/Interpreter.cpp (+3) 


``````````diff
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index fa4c1439c9261..65e4e58f22a84 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -597,6 +597,9 @@ llvm::Error Interpreter::CreateExecutor() {
     auto JTMB = createJITTargetMachineBuilder(TT);
     if (!JTMB)
       return JTMB.takeError();
+#if defined(_WIN32)
+    JTMB->getOptions().EmulatedTLS = false;
+#endif
     auto JB = IncrementalExecutor::createDefaultJITBuilder(std::move(*JTMB));
     if (!JB)
       return JB.takeError();

``````````

</details>


https://github.com/llvm/llvm-project/pull/127468


More information about the cfe-commits mailing list