[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / tools / lli / ChildTarget / ChildTarget.cpp
blobcb81ac5172e4481299ff5413bd38dfe3e5988d37
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/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
14 #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h"
15 #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h"
16 #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h"
17 #include "llvm/Support/DynamicLibrary.h"
18 #include "llvm/Support/Error.h"
19 #include "llvm/Support/MathExtras.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include <cstring>
22 #include <sstream>
24 using namespace llvm;
25 using namespace llvm::orc;
27 ExitOnError ExitOnErr;
29 int main(int argc, char *argv[]) {
30 #if LLVM_ENABLE_THREADS
32 if (argc != 3) {
33 errs() << "Usage: " << argv[0] << " <input fd> <output fd>\n";
34 return 1;
37 if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
38 errs() << "Error loading program symbols.\n";
39 return 1;
42 ExitOnErr.setBanner(std::string(argv[0]) + ": ");
44 int InFD = 0;
45 int OutFD = 0;
47 std::istringstream InFDStream(argv[1]), OutFDStream(argv[2]);
48 InFDStream >> InFD;
49 OutFDStream >> OutFD;
52 auto Server =
53 ExitOnErr(SimpleRemoteEPCServer::Create<FDSimpleRemoteEPCTransport>(
54 [](SimpleRemoteEPCServer::Setup &S) -> Error {
55 S.setDispatcher(
56 std::make_unique<SimpleRemoteEPCServer::ThreadDispatcher>());
57 S.bootstrapSymbols() =
58 SimpleRemoteEPCServer::defaultBootstrapSymbols();
59 S.services().push_back(
60 std::make_unique<rt_bootstrap::SimpleExecutorMemoryManager>());
61 return Error::success();
63 InFD, OutFD));
65 ExitOnErr(Server->waitForDisconnect());
67 return 0;
69 #else
70 errs() << argv[0]
71 << " error: this tool requires threads, but LLVM was "
72 "built with LLVM_ENABLE_THREADS=Off\n";
73 return 1;
74 #endif