[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / tools / lli / ChildTarget / ChildTarget.cpp
blobcf1b03a141c5e22138fa27a79a89b4e29a76a0b1
1 //===----------- ChildTarget.cpp - Out-of-proc executor for lli -----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Simple out-of-process executor for lli.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
15 #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
16 #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h"
17 #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h"
18 #include "llvm/Support/DynamicLibrary.h"
19 #include "llvm/Support/Error.h"
20 #include "llvm/Support/MathExtras.h"
21 #include "llvm/Support/raw_ostream.h"
22 #include <cstring>
23 #include <sstream>
25 using namespace llvm;
26 using namespace llvm::orc;
28 ExitOnError ExitOnErr;
30 int main(int argc, char *argv[]) {
31 #if LLVM_ENABLE_THREADS
33 if (argc != 3) {
34 errs() << "Usage: " << argv[0] << " <input fd> <output fd>\n";
35 return 1;
38 if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
39 errs() << "Error loading program symbols.\n";
40 return 1;
43 ExitOnErr.setBanner(std::string(argv[0]) + ": ");
45 int InFD = 0;
46 int OutFD = 0;
48 std::istringstream InFDStream(argv[1]), OutFDStream(argv[2]);
49 InFDStream >> InFD;
50 OutFDStream >> OutFD;
53 auto Server =
54 ExitOnErr(SimpleRemoteEPCServer::Create<FDSimpleRemoteEPCTransport>(
55 [](SimpleRemoteEPCServer::Setup &S) -> Error {
56 S.setDispatcher(
57 std::make_unique<SimpleRemoteEPCServer::ThreadDispatcher>());
58 S.bootstrapSymbols() =
59 SimpleRemoteEPCServer::defaultBootstrapSymbols();
60 S.services().push_back(
61 std::make_unique<rt_bootstrap::SimpleExecutorMemoryManager>());
62 return Error::success();
64 InFD, OutFD));
66 ExitOnErr(Server->waitForDisconnect());
68 return 0;
70 #else
71 errs() << argv[0]
72 << " error: this tool requires threads, but LLVM was "
73 "built with LLVM_ENABLE_THREADS=Off\n";
74 return 1;
75 #endif