xref: /llvm-project/compiler-rt/lib/orc/tests/tools/orc-rt-executor.cpp (revision 1169586dcde0376ef291802208daedc4f8107c7e)
1*1169586dSLang Hames //===- orc-rt-executor.cpp ------------------------------------------------===//
2*1169586dSLang Hames //
3*1169586dSLang Hames // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*1169586dSLang Hames // See https://llvm.org/LICENSE.txt for license information.
5*1169586dSLang Hames // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*1169586dSLang Hames //
7*1169586dSLang Hames //===----------------------------------------------------------------------===//
8*1169586dSLang Hames //
9*1169586dSLang Hames // Contains the orc-rt-executor test tool. This is a "blank executable" that
10*1169586dSLang Hames // links the ORC runtime and can accept code from a JIT controller like lii or
11*1169586dSLang Hames // llvm-jitlink.
12*1169586dSLang Hames //
13*1169586dSLang Hames //===----------------------------------------------------------------------===//
14*1169586dSLang Hames 
15*1169586dSLang Hames #include <cstring>
16*1169586dSLang Hames #include <iostream>
17*1169586dSLang Hames #include <optional>
18*1169586dSLang Hames #include <string_view>
19*1169586dSLang Hames 
printHelp(std::string_view ProgName,std::ostream & OS)20*1169586dSLang Hames void printHelp(std::string_view ProgName, std::ostream &OS) {
21*1169586dSLang Hames   OS << "usage: " << ProgName << " [help] [<mode>] <program arguments>...\n"
22*1169586dSLang Hames      << "  <mode>                 -- specify how to listen for JIT'd program\n"
23*1169586dSLang Hames      << "    filedesc=<in>,<out>  -- read from <in> filedesc, write to out\n"
24*1169586dSLang Hames      << "    tcp=<host>:<port>    -- listen on the given host/port\n"
25*1169586dSLang Hames      << "  help                   -- print help and exit\n"
26*1169586dSLang Hames      << "\n"
27*1169586dSLang Hames      << " Notes:\n"
28*1169586dSLang Hames      << "   Program arguments will be made available to the JIT controller.\n"
29*1169586dSLang Hames      << "   When running a JIT'd program containing a main function the\n"
30*1169586dSLang Hames      << "   controller may choose to pass these on to main, however\n"
31*1169586dSLang Hames      << "   orc-rt-executor does not enforce this.\n";
32*1169586dSLang Hames }
33*1169586dSLang Hames 
main(int argc,char * argv[])34*1169586dSLang Hames int main(int argc, char *argv[]) {
35*1169586dSLang Hames   if (argc < 2) {
36*1169586dSLang Hames     printHelp("orc-rt-executor", std::cerr);
37*1169586dSLang Hames     std::cerr << "error: insufficient arguments.\n";
38*1169586dSLang Hames     exit(1);
39*1169586dSLang Hames   }
40*1169586dSLang Hames 
41*1169586dSLang Hames   if (!strcmp(argv[1], "help")) {
42*1169586dSLang Hames     printHelp(argv[0], std::cerr);
43*1169586dSLang Hames     exit(0);
44*1169586dSLang Hames   }
45*1169586dSLang Hames 
46*1169586dSLang Hames   std::cerr << "error: One day I will be a real program, but I am not yet.\n";
47*1169586dSLang Hames 
48*1169586dSLang Hames   return 0;
49*1169586dSLang Hames }
50