[clang] [clang-repl] Disable EmulatedTLS on Windows (PR #127468)
Aaron Jomy via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 17 02:23:05 PST 2025
https://github.com/aaronj0 created https://github.com/llvm/llvm-project/pull/127468
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`
cc @vgvassilev
>From 28a34270aba842b10b35765dc55f8ea6b2dd5428 Mon Sep 17 00:00:00 2001
From: Aaron Jomy <75925957+aaronj0 at users.noreply.github.com>
Date: Mon, 17 Feb 2025 11:22:23 +0100
Subject: [PATCH] [clang-repl] Disable EmulatedTLS on Windows
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`
---
clang/lib/Interpreter/Interpreter.cpp | 3 +++
1 file changed, 3 insertions(+)
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();
More information about the cfe-commits
mailing list