================ @@ -47,6 +80,72 @@ 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()); + + llvm::Triple SystemTriple(llvm::sys::getProcessTriple()); + // TODO: Remove once out-of-process execution support is implemented for + // non-Unix platforms. + if ((!SystemTriple.isOSBinFormatELF() && + !SystemTriple.isOSBinFormatMachO()) && + (OOPExecutor.getNumOccurrences() || + OOPExecutorConnect.getNumOccurrences())) + return llvm::make_error<llvm::StringError>( + "Out-of-process execution is only supported on Unix platforms", + 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 require the ORC runtime. + if (OrcRuntimePath.empty() && (OOPExecutor.getNumOccurrences() || + OOPExecutorConnect.getNumOccurrences())) { + llvm::SmallString<256> BasePath(llvm::sys::fs::getMainExecutable( + ArgV0, reinterpret_cast<void *>(&sanitizeOopArguments))); + llvm::sys::path::remove_filename(BasePath); // Remove clang-repl filename. + llvm::sys::path::remove_filename(BasePath); // Remove ./bin directory. + llvm::sys::path::append(BasePath, CLANG_INSTALL_LIBDIR_BASENAME, "clang", + CLANG_VERSION_MAJOR_STRING); + if (SystemTriple.isOSBinFormatELF()) + OrcRuntimePath = + BasePath.str().str() + "lib/x86_64-unknown-linux-gnu/liborc_rt.a"; ---------------- Vipul-Cariappa wrote:
```suggestion BasePath.str().str() + "/lib/x86_64-unknown-linux-gnu/liborc_rt.a"; ``` With this one change, I got this patch to work in my system. https://github.com/llvm/llvm-project/pull/110418 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits