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/5] [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/5] 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

>From b2023d7f4a9294715137c3f467e8e9ab51d1d1e5 Mon Sep 17 00:00:00 2001
From: khanxmetu <[email protected]>
Date: Tue, 25 Aug 2026 16:05:45 +0500
Subject: [PATCH 3/5] ignore file not found error

---
 clang/unittests/Interpreter/InterpreterTest.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp 
b/clang/unittests/Interpreter/InterpreterTest.cpp
index fc1bf4b2b05ae..63b2b0655ff26 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -599,6 +599,7 @@ TEST_F(InterpreterTest, NativePlatformSupport) {
   llvm::setCurrentDebugType("orc");
   testing::internal::CaptureStderr();
   auto ExecutorOrErr = IEB->create(TSC, CI->getTarget());
+  llvm::consumeError(ExecutorOrErr.takeError());
   llvm::setCurrentDebugType("");
   llvm::DebugFlag = DebugFlagPrev;
   std::string output = testing::internal::GetCapturedStderr();

>From cd75bfa8698894cd40bb02e73797a9c64a3a8b14 Mon Sep 17 00:00:00 2001
From: khanxmetu <[email protected]>
Date: Thu, 3 Sep 2026 13:00:38 +0500
Subject: [PATCH 4/5] converted error to debug log

---
 clang/lib/Interpreter/IncrementalExecutor.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 1a63e8a0e1817..8e1ec60a2eea1 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -54,6 +54,8 @@
 #include <string>
 #include <utility>
 
+#define DEBUG_TYPE "orc"
+
 #ifdef LLVM_ON_UNIX
 #include <netdb.h>
 #include <netinet/in.h>
@@ -417,11 +419,11 @@ 
IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
       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: ");
+      LLVM_DEBUG({
+        llvm::dbgs() << "OrcRuntime not found, running JIT without native "
+                        "platform support "
+                     << "and some features may not work.\n";
+      });
     }
     // TODO: Switch to native TLS once clang-repl can adopt the ORC runtime
     // (which provides __emutls_get_address and supports the full TLS

>From 3588dd7f68a0da61fc3a387ca075de48b0b168ca Mon Sep 17 00:00:00 2001
From: khanxmetu <[email protected]>
Date: Thu, 3 Sep 2026 13:02:41 +0500
Subject: [PATCH 5/5] simplify log message

---
 clang/lib/Interpreter/IncrementalExecutor.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 8e1ec60a2eea1..08325c322289c 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -419,11 +419,7 @@ 
IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
       JITBuilder->setPlatformSetUp(
           llvm::orc::ExecutorNativePlatform(OrcRuntimePath));
     } else {
-      LLVM_DEBUG({
-        llvm::dbgs() << "OrcRuntime not found, running JIT without native "
-                        "platform support "
-                     << "and some features may not work.\n";
-      });
+      LLVM_DEBUG({ llvm::dbgs() << "OrcRuntime library not found.\n"; });
     }
     // TODO: Switch to native TLS once clang-repl can adopt the ORC runtime
     // (which provides __emutls_get_address and supports the full TLS

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

Reply via email to