https://github.com/anutosh491 updated 
https://github.com/llvm/llvm-project/pull/175910

>From 60f7b2d3a9873049abbacedc0fb50c13f33ef143 Mon Sep 17 00:00:00 2001
From: anutosh491 <[email protected]>
Date: Wed, 7 Oct 2026 11:54:57 +0530
Subject: [PATCH 1/2] [clang-repl] Drop ORC link dependencies from Emscripten
 builds

Select native and WebAssembly executor implementations in CMake, preserve the 
header-only executor address and context types, and keep library loading in the 
executor interface. Return dlopen diagnostics to callers and test side-module 
loading, exported symbols, and custom-executor dispatch.
---
 .../clang/Interpreter/IncrementalExecutor.h   |  4 +++
 clang/include/clang/Interpreter/Interpreter.h |  2 --
 clang/lib/Interpreter/CMakeLists.txt          | 29 +++++++++--------
 clang/lib/Interpreter/IncrementalExecutor.cpp | 12 ++-----
 clang/lib/Interpreter/Interpreter.cpp         |  4 +--
 clang/lib/Interpreter/Wasm.cpp                | 31 +++++++++++++++++++
 clang/unittests/Interpreter/CMakeLists.txt    |  2 +-
 .../Interpreter/ExceptionTests/CMakeLists.txt | 24 +++++++++++---
 .../InterpreterExceptionTest.cpp              |  8 +++++
 .../Interpreter/InterpreterExtensionsTest.cpp |  5 +++
 .../Interpreter/InterpreterTestFixture.h      |  5 +++
 11 files changed, 94 insertions(+), 32 deletions(-)

diff --git a/clang/include/clang/Interpreter/IncrementalExecutor.h 
b/clang/include/clang/Interpreter/IncrementalExecutor.h
index 913da9230a9473..0ff07aaf416ba4 100644
--- a/clang/include/clang/Interpreter/IncrementalExecutor.h
+++ b/clang/include/clang/Interpreter/IncrementalExecutor.h
@@ -33,6 +33,8 @@ class Compilation;
 
 class IncrementalExecutorBuilder {
 public:
+  IncrementalExecutorBuilder();
+
   /// Indicates whether out-of-process JIT execution is enabled.
   bool IsOutOfProcess = false;
   /// Path to the out-of-process JIT executor.
@@ -52,8 +54,10 @@ class IncrementalExecutorBuilder {
   std::optional<llvm::CodeModel::Model> CM = std::nullopt;
   /// An optional external IncrementalExecutor
   std::unique_ptr<IncrementalExecutor> IE;
+#ifndef __EMSCRIPTEN__
   /// An optional external orc jit builder
   std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
+#endif
   /// A default callback that can be used in the IncrementalCompilerBuilder to
   /// retrieve the path to the orc runtime.
   std::function<llvm::Error(const driver::Compilation &)>
diff --git a/clang/include/clang/Interpreter/Interpreter.h 
b/clang/include/clang/Interpreter/Interpreter.h
index c2622b23d5d9ce..0dd1e52749b4f2 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -20,8 +20,6 @@
 #include "clang/Interpreter/Value.h"
 
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/Support/Error.h"
 #include <cstdint>
diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 01d3295d1ac30d..95bac67e1b9dbb 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -3,35 +3,39 @@ set(LLVM_LINK_COMPONENTS
    native
    MC
    Option
-   OrcJit
-   OrcDebugging
-   OrcShared
-   OrcTargetProcess
    Support
    Target
    TargetParser
    TransformUtils
    )
 
-if (EMSCRIPTEN AND "lld" IN_LIST LLVM_ENABLE_PROJECTS)
-  set(WASM_SRC Wasm.cpp)
-  set(WASM_LINK lldWasm)
-  set(COMMON_LINK lldCommon)
+if (EMSCRIPTEN)
+  if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
+    message(FATAL_ERROR "Building clangInterpreter for Emscripten requires 
lld")
+  endif()
+  set(EXECUTOR_SOURCES Wasm.cpp)
+  set(EXECUTOR_LIBS lldWasm lldCommon)
+else()
+  list(APPEND LLVM_LINK_COMPONENTS
+    OrcJit
+    OrcDebugging
+    OrcShared
+    OrcTargetProcess
+    )
+  set(EXECUTOR_SOURCES IncrementalExecutor.cpp OrcIncrementalExecutor.cpp)
 endif()
 
 add_clang_library(clangInterpreter
   DeviceOffload.cpp
   CodeCompletion.cpp
   IncrementalAction.cpp
-  IncrementalExecutor.cpp
-  OrcIncrementalExecutor.cpp
   IncrementalParser.cpp
   Interpreter.cpp
   InterpreterValuePrinter.cpp
   InterpreterUtils.cpp
   Value.cpp
   InterpreterValuePrinter.cpp
-  ${WASM_SRC}
+  ${EXECUTOR_SOURCES}
   PARTIAL_SOURCES_INTENDED
 
   DEPENDS
@@ -51,8 +55,7 @@ add_clang_library(clangInterpreter
   clangParse
   clangSema
   clangSerialization
-  ${WASM_LINK}
-  ${COMMON_LINK}
+  ${EXECUTOR_LIBS}
   )
 
 if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index 5d01ba47742699..e356ce6d9fe99c 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -12,9 +12,6 @@
 
 #include "clang/Interpreter/IncrementalExecutor.h"
 #include "OrcIncrementalExecutor.h"
-#ifdef __EMSCRIPTEN__
-#include "Wasm.h"
-#endif // __EMSCRIPTEN__
 
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Config/config.h"
@@ -84,6 +81,7 @@ static void *getEmuTLSGetAddressPtr() { return nullptr; }
 #endif
 
 namespace clang {
+IncrementalExecutorBuilder::IncrementalExecutorBuilder() = default;
 IncrementalExecutorBuilder::~IncrementalExecutorBuilder() = default;
 
 static llvm::Expected<llvm::orc::JITTargetMachineBuilder>
@@ -427,12 +425,8 @@ 
IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
   }
 
   llvm::Error Err = llvm::Error::success();
-  std::unique_ptr<IncrementalExecutor> Executor;
-#ifdef __EMSCRIPTEN__
-  Executor = std::make_unique<WasmIncrementalExecutor>(Err);
-#else
-  Executor = std::make_unique<OrcIncrementalExecutor>(TSC, *JITBuilder, Err);
-#endif
+  std::unique_ptr<IncrementalExecutor> Executor =
+      std::make_unique<OrcIncrementalExecutor>(TSC, *JITBuilder, Err);
 
   if (Err)
     return std::move(Err);
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 40fbc83db9107c..0cfbe1410e2299 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -45,9 +45,7 @@
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ModuleCache.h"
 #include "clang/Serialization/ObjectFilePCHContainerReader.h"
-#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
-#include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/ErrorHandling.h"
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index 573c8910d3a414..2bc90a8d8c88ae 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -61,6 +61,37 @@ bool link(llvm::ArrayRef<const char *> args, 
llvm::raw_ostream &stdoutOS,
 
 namespace clang {
 
+IncrementalExecutorBuilder::IncrementalExecutorBuilder() = default;
+IncrementalExecutorBuilder::~IncrementalExecutorBuilder() = default;
+
+llvm::Expected<std::unique_ptr<IncrementalExecutor>>
+IncrementalExecutorBuilder::create(llvm::orc::ThreadSafeContext &TSC,
+                                   const clang::TargetInfo &TI) {
+  if (IE)
+    return std::move(IE);
+
+  if (IsOutOfProcess)
+    return llvm::createStringError(llvm::inconvertibleErrorCode(),
+                                   "Out-of-process execution is not supported "
+                                   "by the WebAssembly executor");
+
+  llvm::Error Err = llvm::Error::success();
+  std::unique_ptr<IncrementalExecutor> Executor =
+      std::make_unique<WasmIncrementalExecutor>(Err);
+  if (Err)
+    return std::move(Err);
+  return std::move(Executor);
+}
+
+llvm::Error IncrementalExecutorBuilder::UpdateOrcRuntimePath(
+    const clang::driver::Compilation &C) {
+  if (IsOutOfProcess)
+    return llvm::createStringError(llvm::inconvertibleErrorCode(),
+                                   "Out-of-process execution is not supported "
+                                   "by the WebAssembly executor");
+  return llvm::Error::success();
+}
+
 WasmIncrementalExecutor::WasmIncrementalExecutor(llvm::Error &Err) {
   llvm::ErrorAsOutParameter EAO(&Err);
 
diff --git a/clang/unittests/Interpreter/CMakeLists.txt 
b/clang/unittests/Interpreter/CMakeLists.txt
index 6d999104054c30..60cea441ab4480 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -3,7 +3,7 @@ set(LLVM_COMPONENTS_TO_LINK
   ""
   )
 set(LLVM_LIBS_TO_LINK
-  ""
+  LLVMTestingSupport
   )
 set(CLANG_LIBS_TO_LINK
   clangInterpreter
diff --git a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt 
b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
index dfd94d8e6442c4..800824140a22e2 100644
--- a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
+++ b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
@@ -3,6 +3,11 @@
 set(LLVM_REQUIRES_EH ON)
 set(LLVM_REQUIRES_RTTI ON)
 
+set(INTERPRETER_EXCEPTION_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Core Support)
+if(NOT EMSCRIPTEN)
+  list(APPEND INTERPRETER_EXCEPTION_COMPONENTS OrcJIT)
+endif()
+
 add_distinct_clang_unittest(ClangReplInterpreterExceptionTests
   InterpreterExceptionTest.cpp
   EXPORT_SYMBOLS
@@ -14,11 +19,22 @@ 
add_distinct_clang_unittest(ClangReplInterpreterExceptionTests
   clangFrontend
 
   LLVM_COMPONENTS
-  ${LLVM_TARGETS_TO_BUILD}
-  Core
-  OrcJIT
-  Support
+  ${INTERPRETER_EXCEPTION_COMPONENTS}
   )
 
 llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
 add_dependencies(ClangReplInterpreterExceptionTests clang-resource-headers)
+
+if(EMSCRIPTEN)
+  get_target_property(LINKED_LIBS ClangReplInterpreterExceptionTests 
LINK_LIBRARIES)
+  list(REMOVE_ITEM LINKED_LIBS LLVMSupport)
+  set_target_properties(ClangReplInterpreterExceptionTests PROPERTIES
+    LINK_LIBRARIES "${LINKED_LIBS}"
+    )
+  target_link_options(ClangReplInterpreterExceptionTests PRIVATE
+    "SHELL:-s MAIN_MODULE=1"
+    "SHELL:-s ALLOW_MEMORY_GROWTH=1"
+    "SHELL:-s STACK_SIZE=32mb"
+    "SHELL:-s INITIAL_MEMORY=128mb"
+    )
+endif()
diff --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index c8522e91602768..fcca9fae3dccf3 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -22,7 +22,9 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "llvm/ADT/ArrayRef.h"
+#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#endif
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
@@ -67,6 +69,10 @@ TEST(InterpreterExceptionTest, CatchException) {
   llvm::InitializeNativeTarget();
   llvm::InitializeNativeTargetAsmPrinter();
 
+#ifdef __EMSCRIPTEN__
+  // The WebAssembly executor does not configure exception handling yet.
+  GTEST_SKIP();
+#else
   {
     auto J = llvm::orc::LLJITBuilder().create();
     if (!J) {
@@ -78,6 +84,8 @@ TEST(InterpreterExceptionTest, CatchException) {
     }
   }
 
+#endif
+
 #define Stringify(s) Stringifyx(s)
 #define Stringifyx(s) #s
 
diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp 
b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 13825f2cbdddfd..f2a96719ef0518 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -19,7 +19,9 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
+#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#endif
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/Threading.h"
@@ -65,6 +67,7 @@ class InterpreterExtensionsTest : public InterpreterTestBase {
   }
 };
 
+#ifndef __EMSCRIPTEN__
 class CustomJBInterpreter : public Interpreter {
   using CustomJITBuilderCreatorFunction =
       
std::function<llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>()>;
@@ -138,6 +141,8 @@ TEST_F(InterpreterExtensionsTest, CustomCrossJIT) {
   EXPECT_EQ(1U, Objs.size());
 }
 
+#endif // __EMSCRIPTEN__
+
 TEST_F(InterpreterExtensionsTest, CustomIncrementalExecutor) {
   struct RecordingIncrementalExecutor : public clang::IncrementalExecutor {
     mutable unsigned RanCtors = false;
diff --git a/clang/unittests/Interpreter/InterpreterTestFixture.h 
b/clang/unittests/Interpreter/InterpreterTestFixture.h
index b088fa4a5f8966..0e33aee2fd48a4 100644
--- a/clang/unittests/Interpreter/InterpreterTestFixture.h
+++ b/clang/unittests/Interpreter/InterpreterTestFixture.h
@@ -9,7 +9,9 @@
 #ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 #define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 
+#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#endif
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
@@ -24,6 +26,7 @@ namespace clang {
 
 class InterpreterTestBase : public ::testing::Test {
 protected:
+#ifndef __EMSCRIPTEN__
   static bool HostSupportsJIT() {
 #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
     return false;
@@ -37,6 +40,8 @@ class InterpreterTestBase : public ::testing::Test {
 #endif
   }
 
+#endif
+
   void SetUp() override {
 // FIXME : WebAssembly doesn't currently support Jit (see
 // https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).

>From 13bb4727eb22f1a18522b0ea036bfcaaf4763252 Mon Sep 17 00:00:00 2001
From: anutosh491 <[email protected]>
Date: Wed, 7 Oct 2026 14:37:18 +0530
Subject: [PATCH 2/2] [clang-repl] Remove redundant platform guards from
 interpreter tests

Keep the LLJIT includes and shared fixture helper unconditional. The
inline JIT probe is unused by Emscripten tests, so these declarations do
not introduce ORC linker dependencies. Retain guards around native-only
ORC tests and unsupported Wasm exception handling.

Validated by compiling all six affected Wasm test translation units and
confirming unchanged undefined symbol sets. Formatting and whitespace
checks also pass.
---
 .../Interpreter/ExceptionTests/InterpreterExceptionTest.cpp  | 2 --
 clang/unittests/Interpreter/InterpreterExtensionsTest.cpp    | 2 --
 clang/unittests/Interpreter/InterpreterTestFixture.h         | 5 -----
 3 files changed, 9 deletions(-)

diff --git 
a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp 
b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index fcca9fae3dccf3..c0272d5bd0c555 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -22,9 +22,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 
 #include "llvm/ADT/ArrayRef.h"
-#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
-#endif
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
 
diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp 
b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index f2a96719ef0518..642869e124b8bd 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -19,9 +19,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
-#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
-#endif
 #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Support/Threading.h"
diff --git a/clang/unittests/Interpreter/InterpreterTestFixture.h 
b/clang/unittests/Interpreter/InterpreterTestFixture.h
index 0e33aee2fd48a4..b088fa4a5f8966 100644
--- a/clang/unittests/Interpreter/InterpreterTestFixture.h
+++ b/clang/unittests/Interpreter/InterpreterTestFixture.h
@@ -9,9 +9,7 @@
 #ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 #define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H
 
-#ifndef __EMSCRIPTEN__
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
-#endif
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/TargetSelect.h"
@@ -26,7 +24,6 @@ namespace clang {
 
 class InterpreterTestBase : public ::testing::Test {
 protected:
-#ifndef __EMSCRIPTEN__
   static bool HostSupportsJIT() {
 #ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT
     return false;
@@ -40,8 +37,6 @@ class InterpreterTestBase : public ::testing::Test {
 #endif
   }
 
-#endif
-
   void SetUp() override {
 // FIXME : WebAssembly doesn't currently support Jit (see
 // https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).

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

Reply via email to