[clang] [llvm] [Clang-Repl] Add support for out-of-process execution. (PR #110418)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 02:53:25 PST 2024
================
@@ -47,6 +76,59 @@ static llvm::cl::opt<bool> OptHostSupportsJit("host-supports-jit",
static llvm::cl::list<std::string> OptInputs(llvm::cl::Positional,
llvm::cl::desc("[code to run]"));
+static llvm::Error sanitizeOopArguments(const char *ArgV0) {
+ // Only one of -oop-executor and -oop-executor-connect can be used.
+ if (!!OOPExecutor.getNumOccurrences() &&
+ !!OOPExecutorConnect.getNumOccurrences())
+ return llvm::make_error<llvm::StringError>(
+ "Only one of -" + OOPExecutor.ArgStr + " and -" +
+ OOPExecutorConnect.ArgStr + " can be specified",
+ llvm::inconvertibleErrorCode());
+
+ // If -slab-allocate is passed, check that we're not trying to use it in
+ // -oop-executor or -oop-executor-connect mode.
+ //
+ // FIXME: Remove once we enable remote slab allocation.
+ if (SlabAllocateSizeString != "") {
+ if (OOPExecutor.getNumOccurrences() ||
+ OOPExecutorConnect.getNumOccurrences())
+ return llvm::make_error<llvm::StringError>(
+ "-slab-allocate cannot be used with -oop-executor or "
+ "-oop-executor-connect",
+ llvm::inconvertibleErrorCode());
+ }
+
+ // Out-of-process executors must run with the ORC runtime for destructor
+ // support.
+ if (OrcRuntimePath.empty() && (OOPExecutor.getNumOccurrences() ||
+ OOPExecutorConnect.getNumOccurrences())) {
+ llvm::SmallString<256> OrcPath(llvm::sys::fs::getMainExecutable(
+ ArgV0, reinterpret_cast<void *>(&sanitizeOopArguments)));
+ llvm::sys::path::remove_filename(OrcPath); // Remove clang-repl filename.
+ llvm::sys::path::remove_filename(OrcPath); // Remove ./bin directory.
+ llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
+ llvm::StringRef Path;
+ if (SystemTriple.isOSBinFormatELF())
+ Path = "lib/clang/20/lib/x86_64-unknown-linux-gnu/liborc_rt.a";
+ else if (SystemTriple.isOSBinFormatMachO())
+ Path = "lib/clang/20/lib/darwin/liborc_rt_osx.a";
----------------
vgvassilev wrote:
Clang-repl is included in the toolchains, yes.
https://github.com/llvm/llvm-project/pull/110418
More information about the cfe-commits
mailing list