xref: /llvm-project/lld/ELF/Driver.h (revision e24457a330923dbc43a0e056deddb2d42c682e6c)
1 //===- Driver.h -------------------------------------------------*- C++ -*-===//
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 #ifndef LLD_ELF_DRIVER_H
10 #define LLD_ELF_DRIVER_H
11 
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/Option/ArgList.h"
15 #include <optional>
16 
17 namespace lld::elf {
18 struct Ctx;
19 
20 // Parses command line options.
21 class ELFOptTable : public llvm::opt::GenericOptTable {
22 public:
23   ELFOptTable();
24   llvm::opt::InputArgList parse(Ctx &, ArrayRef<const char *> argv);
25 };
26 
27 // Create enum with OPT_xxx values for each option in Options.td
28 enum {
29   OPT_INVALID = 0,
30 #define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
31 #include "Options.inc"
32 #undef OPTION
33 };
34 
35 void printHelp(Ctx &ctx);
36 std::string createResponseFile(const llvm::opt::InputArgList &args);
37 
38 std::optional<std::string> findFromSearchPaths(Ctx &, StringRef path);
39 std::optional<std::string> searchScript(Ctx &, StringRef path);
40 std::optional<std::string> searchLibraryBaseName(Ctx &, StringRef path);
41 std::optional<std::string> searchLibrary(Ctx &, StringRef path);
42 
43 } // namespace lld::elf
44 
45 #endif
46