[clang] 89c826d - [clang-repl] Drop orc jit dependency from clangInterpreter's wasm build (#175910)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 01:04:47 PDT 2026
Author: Anutosh Bhat
Date: 2026-10-08T08:04:41Z
New Revision: 89c826d463837b811f5751a959d3484716c94537
URL: https://github.com/llvm/llvm-project/commit/89c826d463837b811f5751a959d3484716c94537
DIFF: https://github.com/llvm/llvm-project/commit/89c826d463837b811f5751a959d3484716c94537.diff
LOG: [clang-repl] Drop orc jit dependency from clangInterpreter's wasm build (#175910)
Fixes https://github.com/llvm/llvm-project/issues/175907 (Read issue
description for more context)
Explanation :
https://github.com/llvm/llvm-project/issues/175907#issuecomment-3748670404
Added:
Modified:
clang/include/clang/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/CMakeLists.txt
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/Wasm.cpp
clang/unittests/Interpreter/CMakeLists.txt
clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Interpreter/IncrementalExecutor.h b/clang/include/clang/Interpreter/IncrementalExecutor.h
index f1a68c0288d00..2e037d1f090e5 100644
--- a/clang/include/clang/Interpreter/IncrementalExecutor.h
+++ b/clang/include/clang/Interpreter/IncrementalExecutor.h
@@ -56,8 +56,10 @@ class IncrementalExecutorBuilder {
/// lldMain call because lld resets all cl options for test-isolation
/// purposes.
std::vector<std::string> LLVMArgs;
+#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/lib/Interpreter/CMakeLists.txt b/clang/lib/Interpreter/CMakeLists.txt
index 01d3295d1ac30..95bac67e1b9db 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 101120626f766..db805bb4219a4 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"
@@ -427,12 +424,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, LLVMArgs);
-#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/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index 017b049fb470c..dbafaae85b556 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -62,6 +62,36 @@ bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
namespace clang {
+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, LLVMArgs);
+ 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, std::vector<std::string> LLVMArgs)
: StoredLLVMArgs(std::move(LLVMArgs)) {
diff --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt
index d18d7819001b1..4ddc9b0528503 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -35,9 +35,12 @@ set(CLANG_REPL_TEST_SOURCES
InterpreterTest.cpp
InterpreterExtensionsTest.cpp
CodeCompletionTest.cpp
- DeviceOffloadTest.cpp
)
+if(NOT EMSCRIPTEN)
+ list(APPEND CLANG_REPL_TEST_SOURCES DeviceOffloadTest.cpp)
+endif()
+
if(TARGET compiler-rt AND LLVM_ON_UNIX)
list(APPEND CLANG_REPL_TEST_SOURCES
OutOfProcessInterpreterTests.cpp
@@ -94,8 +97,8 @@ set_target_properties(ClangReplInterpreterTests PROPERTIES
)
endif()
-# Exceptions on Windows are not yet supported.
-if(NOT WIN32)
+# Interpreter exception tests are not supported on Windows or Emscripten.
+if(NOT WIN32 AND NOT EMSCRIPTEN)
add_subdirectory(ExceptionTests)
endif()
diff --git a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
index 13825f2cbdddf..642869e124b8b 100644
--- a/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterExtensionsTest.cpp
@@ -65,6 +65,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 +139,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;
More information about the cfe-commits
mailing list