|
|
|||
File indexing completed on 2026-05-10 08:42:41
0001 //===- lld/Common/Driver.h - Linker Driver Emulator -----------------------===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLD_COMMON_DRIVER_H 0010 #define LLD_COMMON_DRIVER_H 0011 0012 #include "llvm/ADT/ArrayRef.h" 0013 #include "llvm/Support/raw_ostream.h" 0014 0015 namespace lld { 0016 enum Flavor { 0017 Invalid, 0018 Gnu, // -flavor gnu 0019 MinGW, // -flavor gnu MinGW 0020 WinLink, // -flavor link 0021 Darwin, // -flavor darwin 0022 Wasm, // -flavor wasm 0023 }; 0024 0025 using Driver = bool (*)(llvm::ArrayRef<const char *>, llvm::raw_ostream &, 0026 llvm::raw_ostream &, bool, bool); 0027 0028 struct DriverDef { 0029 Flavor f; 0030 Driver d; 0031 }; 0032 0033 struct Result { 0034 int retCode; 0035 bool canRunAgain; 0036 }; 0037 0038 // Generic entry point when using LLD as a library, safe for re-entry, supports 0039 // crash recovery. Returns a general completion code and a boolean telling 0040 // whether it can be called again. In some cases, a crash could corrupt memory 0041 // and re-entry would not be possible anymore. Use exitLld() in that case to 0042 // properly exit your application and avoid intermittent crashes on exit caused 0043 // by cleanup. 0044 Result lldMain(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, 0045 llvm::raw_ostream &stderrOS, llvm::ArrayRef<DriverDef> drivers); 0046 } // namespace lld 0047 0048 // With this macro, library users must specify which drivers they use, provide 0049 // that information to lldMain() in the `drivers` param, and link the 0050 // corresponding driver library in their executable. 0051 #define LLD_HAS_DRIVER(name) \ 0052 namespace lld { \ 0053 namespace name { \ 0054 bool link(llvm::ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, \ 0055 llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput); \ 0056 } \ 0057 } 0058 0059 // An array which declares that all LLD drivers are linked in your executable. 0060 // Must be used along with LLD_HAS_DRIVERS. See examples in LLD unittests. 0061 #define LLD_ALL_DRIVERS \ 0062 { \ 0063 {lld::WinLink, &lld::coff::link}, {lld::Gnu, &lld::elf::link}, \ 0064 {lld::MinGW, &lld::mingw::link}, {lld::Darwin, &lld::macho::link}, { \ 0065 lld::Wasm, &lld::wasm::link \ 0066 } \ 0067 } 0068 0069 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|