https://github.com/khanxmetu updated 
https://github.com/llvm/llvm-project/pull/217988

>From 25e82c1be918584f0fb796b257ccbb037007d1e5 Mon Sep 17 00:00:00 2001
From: khanxmetu <[email protected]>
Date: Fri, 21 Aug 2026 20:41:59 +0500
Subject: [PATCH 1/2] [clang-repl] Set up native platform support if orc
 runtime available, warn otherwise

---
 clang/lib/Interpreter/IncrementalExecutor.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 6d337e7848699..1a63e8a0e1817 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -413,6 +413,16 @@ 
IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
     if (!JB)
       return JB.takeError();
     JITBuilder = std::move(*JB);
+    if (!OrcRuntimePath.empty()) {
+      JITBuilder->setPlatformSetUp(
+          llvm::orc::ExecutorNativePlatform(OrcRuntimePath));
+    } else {
+      auto Err = llvm::make_error<llvm::StringError>(
+          "OrcRuntime not found, running JIT without native platform support "
+          "and some features may not work.",
+          std::error_code());
+      llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "warning: ");
+    }
     // TODO: Switch to native TLS once clang-repl can adopt the ORC runtime
     // (which provides __emutls_get_address and supports the full TLS
     // lifecycle). That will also remove the in-process-only constraint below.

>From ff2862d8680535e3317b9b9d6f380d1639d0d73e Mon Sep 17 00:00:00 2001
From: khanxmetu <[email protected]>
Date: Tue, 25 Aug 2026 13:41:26 +0500
Subject: [PATCH 2/2] NativePlatformSupport unittest

---
 .../unittests/Interpreter/InterpreterTest.cpp | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index 450be2a25a12f..fc1bf4b2b05ae 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -60,6 +60,18 @@ static size_t DeclsSize(TranslationUnitDecl *PTUDecl) {
   return std::distance(PTUDecl->decls().begin(), PTUDecl->decls().end());
 }
 
+std::string GetPlatformSetupValue(const std::string &Output) {
+  std::string Key = "Custom platform-setup function: ";
+  size_t Start = Output.find(Key);
+
+  if (Start == std::string::npos)
+    return "<Line not found>";
+
+  Start += Key.length();
+  size_t End = Output.find_first_of("\r\n", Start);
+  return Output.substr(Start, End - Start);
+}
+
 TEST_F(InterpreterTest, Sanity) {
   std::unique_ptr<Interpreter> Interp = createInterpreter();
 
@@ -573,4 +585,27 @@ TEST_F(InterpreterTest, TranslationUnit_CanonicalDecl) {
             sema.getASTContext().getTranslationUnitDecl()->getCanonicalDecl());
 }
 
+TEST_F(InterpreterTest, NativePlatformSupport) {
+#ifndef NDEBUG
+  std::string OrcRuntimePath = "path/liborc_rt";
+  auto IEB = std::make_unique<IncrementalExecutorBuilder>();
+  IEB->OrcRuntimePath = OrcRuntimePath;
+  llvm::orc::ThreadSafeContext TSC;
+  auto CB = IncrementalCompilerBuilder();
+  auto CI = llvm::cantFail(CB.CreateCpp());
+
+  bool DebugFlagPrev = llvm::DebugFlag;
+  llvm::DebugFlag = true;
+  llvm::setCurrentDebugType("orc");
+  testing::internal::CaptureStderr();
+  auto ExecutorOrErr = IEB->create(TSC, CI->getTarget());
+  llvm::setCurrentDebugType("");
+  llvm::DebugFlag = DebugFlagPrev;
+  std::string output = testing::internal::GetCapturedStderr();
+  EXPECT_EQ(GetPlatformSetupValue(output), "Yes");
+#else
+  GTEST_SKIP() << "Assertions must be enabled";
+#endif
+}
+
 } // end anonymous namespace

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to