Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 1 | //===- Config.h -------------------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 | [diff] [blame] | 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 |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLD_WASM_CONFIG_H |
| 10 | #define LLD_WASM_CONFIG_H |
| 11 | |
| 12 | #include "llvm/ADT/StringRef.h" |
Rui Ueyama | 7d5a137 | 2017-11-29 22:21:37 | [diff] [blame] | 13 | #include "llvm/ADT/StringSet.h" |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 14 | #include "llvm/BinaryFormat/Wasm.h" |
Sam Clegg | c729c1b | 2018-05-30 18:07:52 | [diff] [blame] | 15 | #include "llvm/Support/CachePruning.h" |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 16 | |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 17 | namespace lld { |
| 18 | namespace wasm { |
| 19 | |
Sam Clegg | 206884b | 2020-05-01 16:14:59 | [diff] [blame] | 20 | // For --unresolved-symbols. |
| 21 | // The `ImportFuncs` mode is an additional mode that corresponds to the |
| 22 | // --allow-undefined flag which turns undefined functions in imports |
| 23 | // as opposed ed to Ignore or Warn which turn them into unreachables. |
| 24 | enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportFuncs }; |
| 25 | |
Sam Clegg | a1282a3 | 2019-05-08 16:20:05 | [diff] [blame] | 26 | // This struct contains the global configuration for the linker. |
| 27 | // Most fields are direct mapping from the command line options |
| 28 | // and such fields have the same name as the corresponding options. |
| 29 | // Most fields are initialized by the driver. |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 30 | struct Configuration { |
Sam Clegg | 2513407 | 2020-10-07 21:48:37 | [diff] [blame] | 31 | bool bsymbolic; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 32 | bool checkFeatures; |
| 33 | bool compressRelocations; |
| 34 | bool demangle; |
| 35 | bool disableVerify; |
Dan Gohman | 46a3268 | 2020-06-12 19:05:40 | [diff] [blame] | 36 | bool experimentalPic; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 37 | bool emitRelocs; |
| 38 | bool exportAll; |
| 39 | bool exportDynamic; |
| 40 | bool exportTable; |
Jacob Gravelle | 92ed86d | 2019-08-27 22:58:21 | [diff] [blame] | 41 | bool growableTable; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 42 | bool gcSections; |
| 43 | bool importMemory; |
| 44 | bool sharedMemory; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 45 | bool importTable; |
Wouter van Oortmerssen | 29f8c9f | 2020-07-06 20:34:16 | [diff] [blame] | 46 | llvm::Optional<bool> is64; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 47 | bool mergeDataSegments; |
| 48 | bool pie; |
| 49 | bool printGcSections; |
| 50 | bool relocatable; |
| 51 | bool saveTemps; |
| 52 | bool shared; |
| 53 | bool stripAll; |
| 54 | bool stripDebug; |
| 55 | bool stackFirst; |
| 56 | bool trace; |
Thomas Lively | c496d84 | 2020-04-03 23:18:29 | [diff] [blame] | 57 | uint64_t globalBase; |
| 58 | uint64_t initialMemory; |
| 59 | uint64_t maxMemory; |
| 60 | uint64_t zStackSize; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 61 | unsigned ltoPartitions; |
| 62 | unsigned ltoo; |
| 63 | unsigned optimize; |
Alexandre Ganea | 0915825 | 2020-03-27 14:20:39 | [diff] [blame] | 64 | llvm::StringRef thinLTOJobs; |
Arthur Eubanks | 1314a49 | 2020-12-01 20:22:27 | [diff] [blame] | 65 | bool ltoNewPassManager; |
| 66 | bool ltoDebugPassManager; |
Sam Clegg | 206884b | 2020-05-01 16:14:59 | [diff] [blame] | 67 | UnresolvedPolicy unresolvedSymbols; |
Sam Clegg | a1282a3 | 2019-05-08 16:20:05 | [diff] [blame] | 68 | |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 69 | llvm::StringRef entry; |
Sam Clegg | cc2da55 | 2020-03-27 23:52:27 | [diff] [blame] | 70 | llvm::StringRef mapFile; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 71 | llvm::StringRef outputFile; |
| 72 | llvm::StringRef thinLTOCacheDir; |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 73 | |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 74 | llvm::StringSet<> allowUndefinedSymbols; |
| 75 | llvm::StringSet<> exportedSymbols; |
Sam Clegg | a6f4064 | 2021-04-05 15:00:30 | [diff] [blame^] | 76 | std::vector<llvm::StringRef> requiredExports; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 77 | std::vector<llvm::StringRef> searchPaths; |
| 78 | llvm::CachePruningPolicy thinLTOCachePolicy; |
| 79 | llvm::Optional<std::vector<std::string>> features; |
Sam Clegg | bfb7534 | 2018-11-15 00:37:21 | [diff] [blame] | 80 | |
Sam Clegg | a1282a3 | 2019-05-08 16:20:05 | [diff] [blame] | 81 | // The following config options do not directly correspond to any |
| 82 | // particualr command line options. |
| 83 | |
Sam Clegg | bfb7534 | 2018-11-15 00:37:21 | [diff] [blame] | 84 | // True if we are creating position-independent code. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 85 | bool isPic; |
Sam Clegg | 1a1df72 | 2019-08-27 04:19:34 | [diff] [blame] | 86 | |
Andy Wingo | 4fc2557 | 2021-02-12 19:01:41 | [diff] [blame] | 87 | // True if we have an MVP input that uses __indirect_function_table and which |
| 88 | // requires it to be allocated to table number 0. |
| 89 | bool legacyFunctionTable = false; |
| 90 | |
Sam Clegg | 1a1df72 | 2019-08-27 04:19:34 | [diff] [blame] | 91 | // The table offset at which to place function addresses. We reserve zero |
Kazuaki Ishizaki | 7ae3d33 | 2020-01-06 18:21:05 | [diff] [blame] | 92 | // for the null function pointer. This gets set to 1 for executables and 0 |
Sam Clegg | 1a1df72 | 2019-08-27 04:19:34 | [diff] [blame] | 93 | // for shared libraries (since they always added to a dynamic offset at |
| 94 | // runtime). |
| 95 | uint32_t tableBase = 0; |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | // The only instance of Configuration struct. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 99 | extern Configuration *config; |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 | [diff] [blame] | 100 | |
| 101 | } // namespace wasm |
| 102 | } // namespace lld |
| 103 | |
| 104 | #endif |