[clang] [Clang-Repl] Add Lambda Support, PID Retrieval, and Dynamic liborc_rt Path in Clang-Repl (PR #155140)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 28 00:57:28 PDT 2025
================
@@ -460,10 +464,99 @@ const char *const Runtimes = R"(
EXTERN_C void __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, ...);
)";
+llvm::ExitOnError ExitOnErr;
+
+std::unique_ptr<llvm::orc::LLJITBuilder>
+Interpreter::outOfProcessJITBuilder(OutOfProcessJITConfig OutOfProcessConfig) {
+ std::unique_ptr<llvm::orc::ExecutorProcessControl> EPC;
+ if (OutOfProcessConfig.OOPExecutor != "") {
+ // Launch an out-of-process executor locally in a child process.
+ EPC = ExitOnErr(launchExecutor(OutOfProcessConfig.OOPExecutor,
+ OutOfProcessConfig.UseSharedMemory,
+ OutOfProcessConfig.SlabAllocateSizeString));
+ } else if (OutOfProcessConfig.OOPExecutorConnect != "") {
+ EPC =
+ ExitOnErr(connectTCPSocket(OutOfProcessConfig.OOPExecutorConnect,
+ OutOfProcessConfig.UseSharedMemory,
+ OutOfProcessConfig.SlabAllocateSizeString));
+ }
+
+ std::unique_ptr<llvm::orc::LLJITBuilder> JB;
+ if (EPC) {
+ JB = ExitOnErr(clang::Interpreter::createLLJITBuilder(
+ std::move(EPC), OutOfProcessConfig.OrcRuntimePath));
+ }
+
+ return JB;
+}
+
+llvm::Expected<std::string>
+Interpreter::getOrcRuntimePath(const driver::ToolChain &TC) {
+ std::optional<std::string> CompilerRTPath = TC.getCompilerRTPath();
+ if (!CompilerRTPath) {
+ return llvm::make_error<llvm::StringError>("CompilerRT path not found",
+ std::error_code());
+ }
+ llvm::SmallString<256> BasePath(llvm::sys::fs::getMainExecutable(
+ "clang-repl", reinterpret_cast<void *>(&getOrcRuntimePath)));
----------------
vgvassilev wrote:
That does not work when we are in a library. Why do we need the BasePath at all? I'd think we can ask the `TC` and that is mostly it. Do you try to get somehow to the source directory?
https://github.com/llvm/llvm-project/pull/155140
More information about the cfe-commits
mailing list