[clang] [clang-repl] Restore local out-of-process executor launch (PR #241216)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 02:59:54 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Anutosh Bhat (anutosh491)
<details>
<summary>Changes</summary>
We should use a socket pair and `socket:adopt` to match llvm-jitlink-executor’s current connection protocol.
---
Full diff: https://github.com/llvm/llvm-project/pull/241216.diff
2 Files Affected:
- (modified) clang/lib/Interpreter/OrcIncrementalExecutorBuilder.cpp (+13-19)
- (modified) clang/unittests/Interpreter/OutOfProcessInterpreterTests.cpp (+1)
``````````diff
diff --git a/clang/lib/Interpreter/OrcIncrementalExecutorBuilder.cpp b/clang/lib/Interpreter/OrcIncrementalExecutorBuilder.cpp
index 89db2d71197a0a..a03291f3487ddb 100644
--- a/clang/lib/Interpreter/OrcIncrementalExecutorBuilder.cpp
+++ b/clang/lib/Interpreter/OrcIncrementalExecutorBuilder.cpp
@@ -187,28 +187,25 @@ launchExecutor(llvm::StringRef ExecutablePath,
llvm::formatv("Specified executor invalid: {0}", ExecutablePath),
llvm::inconvertibleErrorCode());
- constexpr int ReadEnd = 0;
- constexpr int WriteEnd = 1;
+ constexpr int ParentSocket = 0;
+ constexpr int ChildSocket = 1;
- // Pipe FDs.
- int ToExecutor[2];
- int FromExecutor[2];
+ int Sockets[2];
uint32_t ChildPID;
- // Create pipes to/from the executor..
- if (pipe(ToExecutor) != 0 || pipe(FromExecutor) != 0)
+ // Create a socket pair to communicate with the executor.
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, Sockets) != 0)
return llvm::make_error<llvm::StringError>(
- "Unable to create pipe for executor", llvm::inconvertibleErrorCode());
+ "Unable to create socket for executor", llvm::inconvertibleErrorCode());
ChildPID = fork();
if (ChildPID == 0) {
// In the child...
- // Close the parent ends of the pipes
- close(ToExecutor[WriteEnd]);
- close(FromExecutor[ReadEnd]);
+ // Close the parent socket.
+ close(Sockets[ParentSocket]);
if (CustomizeFork)
CustomizeFork();
@@ -219,10 +216,8 @@ launchExecutor(llvm::StringRef ExecutablePath,
ExecutorPath = std::make_unique<char[]>(ExecutablePath.size() + 1);
strcpy(ExecutorPath.get(), ExecutablePath.data());
- std::string FDSpecifierStr("filedescs=");
- FDSpecifierStr += llvm::utostr(ToExecutor[ReadEnd]);
- FDSpecifierStr += ',';
- FDSpecifierStr += llvm::utostr(FromExecutor[WriteEnd]);
+ std::string FDSpecifierStr("socket:adopt=");
+ FDSpecifierStr += llvm::utostr(Sockets[ChildSocket]);
FDSpecifier = std::make_unique<char[]>(FDSpecifierStr.size() + 1);
strcpy(FDSpecifier.get(), FDSpecifierStr.c_str());
}
@@ -237,15 +232,14 @@ launchExecutor(llvm::StringRef ExecutablePath,
}
// else we're the parent...
- // Close the child ends of the pipes
- close(ToExecutor[ReadEnd]);
- close(FromExecutor[WriteEnd]);
+ // Close the child socket.
+ close(Sockets[ChildSocket]);
auto EPCOrErr =
llvm::orc::SimpleRemoteEPC::Create<llvm::orc::FDSimpleRemoteEPCTransport>(
std::make_unique<llvm::orc::DynamicThreadPoolTaskDispatcher>(
std::nullopt),
- FromExecutor[ReadEnd], ToExecutor[WriteEnd]);
+ Sockets[ParentSocket], Sockets[ParentSocket]);
if (!EPCOrErr)
return EPCOrErr.takeError();
return std::make_pair(std::move(*EPCOrErr), ChildPID);
diff --git a/clang/unittests/Interpreter/OutOfProcessInterpreterTests.cpp b/clang/unittests/Interpreter/OutOfProcessInterpreterTests.cpp
index f67ad02d918c64..b6fcc36cafd781 100644
--- a/clang/unittests/Interpreter/OutOfProcessInterpreterTests.cpp
+++ b/clang/unittests/Interpreter/OutOfProcessInterpreterTests.cpp
@@ -183,6 +183,7 @@ class OutOfProcessInterpreterTest : public InterpreterTestBase {
}
static void SetUpTestSuite() {
+ InterpreterTestBase::SetUpTestSuite();
if (!HostSupportsOutOfProcessJIT())
GTEST_SKIP() << "Host does not support out-of-process JIT";
``````````
</details>
https://github.com/llvm/llvm-project/pull/241216
More information about the cfe-commits
mailing list