Bump version to 19.1.0 (final)
[llvm-project.git] / lld / wasm / Config.h
blob915c53c4371729901edc1cd994b0904167f23193
1 //===- Config.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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_WASM_CONFIG_H
10 #define LLD_WASM_CONFIG_H
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/ADT/StringSet.h"
15 #include "llvm/BinaryFormat/Wasm.h"
16 #include "llvm/Support/CachePruning.h"
17 #include <optional>
19 namespace llvm {
20 enum class CodeGenOptLevel;
21 } // namespace llvm
23 namespace lld::wasm {
25 class InputFile;
26 class StubFile;
27 class ObjFile;
28 class SharedFile;
29 class BitcodeFile;
30 class InputTable;
31 class InputGlobal;
32 class InputFunction;
33 class Symbol;
35 // For --unresolved-symbols.
36 enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportDynamic };
38 // For --build-id.
39 enum class BuildIdKind { None, Fast, Sha1, Hexstring, Uuid };
41 // This struct contains the global configuration for the linker.
42 // Most fields are direct mapping from the command line options
43 // and such fields have the same name as the corresponding options.
44 // Most fields are initialized by the driver.
45 struct Configuration {
46 bool bsymbolic;
47 bool checkFeatures;
48 bool compressRelocations;
49 bool demangle;
50 bool disableVerify;
51 bool experimentalPic;
52 bool emitRelocs;
53 bool exportAll;
54 bool exportDynamic;
55 bool exportTable;
56 bool extendedConst;
57 bool growableTable;
58 bool gcSections;
59 llvm::StringSet<> keepSections;
60 std::optional<std::pair<llvm::StringRef, llvm::StringRef>> memoryImport;
61 std::optional<llvm::StringRef> memoryExport;
62 bool sharedMemory;
63 bool importTable;
64 bool importUndefined;
65 std::optional<bool> is64;
66 bool mergeDataSegments;
67 bool pie;
68 bool printGcSections;
69 bool relocatable;
70 bool saveTemps;
71 bool shared;
72 bool shlibSigCheck;
73 bool stripAll;
74 bool stripDebug;
75 bool stackFirst;
76 // Because dyamanic linking under Wasm is still experimental we default to
77 // static linking
78 bool isStatic = true;
79 bool trace;
80 uint64_t globalBase;
81 uint64_t initialHeap;
82 uint64_t initialMemory;
83 uint64_t maxMemory;
84 bool noGrowableMemory;
85 // The table offset at which to place function addresses. We reserve zero
86 // for the null function pointer. This gets set to 1 for executables and 0
87 // for shared libraries (since they always added to a dynamic offset at
88 // runtime).
89 uint64_t tableBase;
90 uint64_t zStackSize;
91 unsigned ltoPartitions;
92 unsigned ltoo;
93 llvm::CodeGenOptLevel ltoCgo;
94 unsigned optimize;
95 llvm::StringRef thinLTOJobs;
96 bool ltoDebugPassManager;
97 UnresolvedPolicy unresolvedSymbols;
98 BuildIdKind buildId = BuildIdKind::None;
100 llvm::StringRef entry;
101 llvm::StringRef mapFile;
102 llvm::StringRef outputFile;
103 llvm::StringRef soName;
104 llvm::StringRef thinLTOCacheDir;
105 llvm::StringRef whyExtract;
107 llvm::StringSet<> allowUndefinedSymbols;
108 llvm::StringSet<> exportedSymbols;
109 std::vector<llvm::StringRef> requiredExports;
110 llvm::SmallVector<llvm::StringRef, 0> searchPaths;
111 llvm::CachePruningPolicy thinLTOCachePolicy;
112 std::optional<std::vector<std::string>> features;
113 std::optional<std::vector<std::string>> extraFeatures;
114 llvm::SmallVector<uint8_t, 0> buildIdVector;
117 // The only instance of Configuration struct.
118 extern Configuration *config;
120 // The Ctx object hold all other (non-configuration) global state.
121 struct Ctx {
122 llvm::SmallVector<ObjFile *, 0> objectFiles;
123 llvm::SmallVector<StubFile *, 0> stubFiles;
124 llvm::SmallVector<SharedFile *, 0> sharedFiles;
125 llvm::SmallVector<BitcodeFile *, 0> bitcodeFiles;
126 llvm::SmallVector<InputFunction *, 0> syntheticFunctions;
127 llvm::SmallVector<InputGlobal *, 0> syntheticGlobals;
128 llvm::SmallVector<InputTable *, 0> syntheticTables;
130 // True if we are creating position-independent code.
131 bool isPic = false;
133 // True if we have an MVP input that uses __indirect_function_table and which
134 // requires it to be allocated to table number 0.
135 bool legacyFunctionTable = false;
137 // Will be set to true if bss data segments should be emitted. In most cases
138 // this is not necessary.
139 bool emitBssSegments = false;
141 // A tuple of (reference, extractedFile, sym). Used by --why-extract=.
142 llvm::SmallVector<std::tuple<std::string, const InputFile *, const Symbol &>,
144 whyExtractRecords;
146 void reset();
149 extern Ctx ctx;
151 } // namespace lld::wasm
153 #endif