Rafael Espindola | beee25e | 2015-08-14 14:12:54 | [diff] [blame] | 1 | //===- Config.h -------------------------------------------------*- C++ -*-===// |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 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 |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLD_COFF_CONFIG_H |
| 10 | #define LLD_COFF_CONFIG_H |
| 11 | |
Fangrui Song | 982575fd | 2024-12-04 04:51:50 | [diff] [blame] | 12 | #include "lld/Common/ErrorHandler.h" |
Zequan Wu | 763671f | 2020-07-21 20:46:11 | [diff] [blame] | 13 | #include "llvm/ADT/MapVector.h" |
Nico Weber | 400a1de | 2021-08-24 14:19:21 | [diff] [blame] | 14 | #include "llvm/ADT/SetVector.h" |
Nico Weber | 67d311a | 2022-11-14 19:23:56 | [diff] [blame] | 15 | #include "llvm/ADT/SmallVector.h" |
Rui Ueyama | 57175aa | 2018-01-27 00:34:46 | [diff] [blame] | 16 | #include "llvm/ADT/StringMap.h" |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 17 | #include "llvm/ADT/StringRef.h" |
Rui Ueyama | 3d3e6fb | 2015-05-29 16:06:00 | [diff] [blame] | 18 | #include "llvm/Object/COFF.h" |
Peter Collingbourne | 052e855e | 2017-09-08 00:50:50 | [diff] [blame] | 19 | #include "llvm/Support/CachePruning.h" |
Alex Brachet | fd9962e | 2022-07-11 21:31:01 | [diff] [blame] | 20 | #include "llvm/Support/VirtualFileSystem.h" |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 21 | #include <cstdint> |
Rui Ueyama | 8854d8a | 2015-06-04 19:21:24 | [diff] [blame] | 22 | #include <map> |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 23 | #include <set> |
| 24 | #include <string> |
| 25 | |
Nico Weber | 7c26641 | 2022-08-08 15:32:26 | [diff] [blame] | 26 | namespace lld::coff { |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 27 | |
Rui Ueyama | e16a75d5 | 2015-07-08 18:14:51 | [diff] [blame] | 28 | using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; |
Rui Ueyama | 15cc47e | 2015-05-29 16:34:31 | [diff] [blame] | 29 | using llvm::COFF::WindowsSubsystem; |
Rui Ueyama | d21b00b | 2015-05-31 19:17:14 | [diff] [blame] | 30 | using llvm::StringRef; |
Fangrui Song | 982575fd | 2024-12-04 04:51:50 | [diff] [blame] | 31 | class COFFLinkerContext; |
Rui Ueyama | cd3f99b | 2015-07-24 23:51:14 | [diff] [blame] | 32 | class DefinedAbsolute; |
Rui Ueyama | 84425d7 | 2016-01-09 01:22:00 | [diff] [blame] | 33 | class StringChunk; |
Rui Ueyama | f52496e | 2017-11-03 21:21:47 | [diff] [blame] | 34 | class Symbol; |
Alexandre Ganea | 347a45c | 2019-03-29 19:58:58 | [diff] [blame] | 35 | class InputFile; |
Zequan Wu | 763671f | 2020-07-21 20:46:11 | [diff] [blame] | 36 | class SectionChunk; |
Rui Ueyama | 15cc47e | 2015-05-29 16:34:31 | [diff] [blame] | 37 | |
Rui Ueyama | 35ccb0f | 2015-07-25 00:20:06 | [diff] [blame] | 38 | // Short aliases. |
| 39 | static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64; |
Martin Storsjo | 94fce50 | 2017-07-01 20:29:27 | [diff] [blame] | 40 | static const auto ARM64 = llvm::COFF::IMAGE_FILE_MACHINE_ARM64; |
Jacek Caban | 482ee33 | 2023-03-21 19:01:22 | [diff] [blame] | 41 | static const auto ARM64EC = llvm::COFF::IMAGE_FILE_MACHINE_ARM64EC; |
| 42 | static const auto ARM64X = llvm::COFF::IMAGE_FILE_MACHINE_ARM64X; |
Rui Ueyama | a265b01 | 2015-07-25 02:25:14 | [diff] [blame] | 43 | static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT; |
Rui Ueyama | 35ccb0f | 2015-07-25 00:20:06 | [diff] [blame] | 44 | static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386; |
| 45 | |
Alexandre Ganea | adcdc9c | 2023-06-13 19:12:55 | [diff] [blame] | 46 | enum class ExportSource { |
| 47 | Unset, |
| 48 | Directives, |
| 49 | Export, |
| 50 | ModuleDefinition, |
| 51 | }; |
| 52 | |
Matheus Izvekov | d12b99a | 2023-10-03 23:24:54 | [diff] [blame] | 53 | enum class EmitKind { Obj, LLVM, ASM }; |
Matheus Izvekov | 3923e61 | 2023-10-02 20:54:43 | [diff] [blame] | 54 | |
Rui Ueyama | 97dff9e | 2015-06-17 00:16:33 | [diff] [blame] | 55 | // Represents an /export option. |
| 56 | struct Export { |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 57 | StringRef name; // N in /export:N or /export:E=N |
| 58 | StringRef extName; // E in /export:E=N |
Jacek Caban | cc23ee8 | 2024-03-27 10:37:02 | [diff] [blame] | 59 | StringRef exportAs; // E in /export:N,EXPORTAS,E |
Martin Storsjö | 750de32 | 2024-04-18 10:29:38 | [diff] [blame] | 60 | StringRef importName; // GNU specific: N in "othername == N" |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 61 | Symbol *sym = nullptr; |
| 62 | uint16_t ordinal = 0; |
| 63 | bool noname = false; |
| 64 | bool data = false; |
| 65 | bool isPrivate = false; |
| 66 | bool constant = false; |
Rui Ueyama | 4b8cdd20 | 2015-07-03 23:23:29 | [diff] [blame] | 67 | |
Rui Ueyama | 84425d7 | 2016-01-09 01:22:00 | [diff] [blame] | 68 | // If an export is a form of /export:foo=dllname.bar, that means |
| 69 | // that foo should be exported as an alias to bar in the DLL. |
Fangrui Song | 2e2038b | 2019-07-16 08:26:38 | [diff] [blame] | 70 | // forwardTo is set to "dllname.bar" part. Usually empty. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 71 | StringRef forwardTo; |
| 72 | StringChunk *forwardChunk = nullptr; |
Rui Ueyama | 84425d7 | 2016-01-09 01:22:00 | [diff] [blame] | 73 | |
Alexandre Ganea | adcdc9c | 2023-06-13 19:12:55 | [diff] [blame] | 74 | ExportSource source = ExportSource::Unset; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 75 | StringRef symbolName; |
| 76 | StringRef exportName; // Name in DLL |
Rui Ueyama | f10a320 | 2015-08-31 08:43:21 | [diff] [blame] | 77 | |
Samira Bazuzi | 8899b71 | 2023-10-04 15:39:20 | [diff] [blame] | 78 | bool operator==(const Export &e) const { |
Jacek Caban | cc23ee8 | 2024-03-27 10:37:02 | [diff] [blame] | 79 | return (name == e.name && extName == e.extName && exportAs == e.exportAs && |
Martin Storsjö | 750de32 | 2024-04-18 10:29:38 | [diff] [blame] | 80 | importName == e.importName && ordinal == e.ordinal && |
Jacek Caban | cc23ee8 | 2024-03-27 10:37:02 | [diff] [blame] | 81 | noname == e.noname && data == e.data && isPrivate == e.isPrivate); |
Rui Ueyama | 4b8cdd20 | 2015-07-03 23:23:29 | [diff] [blame] | 82 | } |
Rui Ueyama | 97dff9e | 2015-06-17 00:16:33 | [diff] [blame] | 83 | }; |
| 84 | |
Saleem Abdulrasool | a2cca7e | 2016-08-08 22:02:44 | [diff] [blame] | 85 | enum class DebugType { |
| 86 | None = 0x0, |
| 87 | CV = 0x1, /// CodeView |
| 88 | PData = 0x2, /// Procedure Data |
| 89 | Fixup = 0x4, /// Relocation Table |
| 90 | }; |
| 91 | |
Pengfei Wang | 184377d | 2021-04-14 06:21:52 | [diff] [blame] | 92 | enum GuardCFLevel { |
| 93 | Off = 0x0, |
| 94 | CF = 0x1, /// Emit gfids tables |
| 95 | LongJmp = 0x2, /// Emit longjmp tables |
| 96 | EHCont = 0x4, /// Emit ehcont tables |
| 97 | All = 0x7 /// Enable all protections |
Reid Kleckner | fd52096 | 2018-02-13 20:32:53 | [diff] [blame] | 98 | }; |
| 99 | |
Zequan Wu | 5bdc5e7 | 2021-02-27 00:38:24 | [diff] [blame] | 100 | enum class ICFLevel { |
| 101 | None, |
| 102 | Safe, // Safe ICF for all sections. |
| 103 | All, // Aggressive ICF for code, but safe ICF for data, similar to MSVC's |
| 104 | // behavior. |
| 105 | }; |
| 106 | |
Zequan Wu | aaf3a8d | 2023-12-05 19:57:45 | [diff] [blame] | 107 | enum class BuildIDHash { |
| 108 | None, |
| 109 | PDB, |
| 110 | Binary, |
| 111 | }; |
| 112 | |
Rui Ueyama | 97dff9e | 2015-06-17 00:16:33 | [diff] [blame] | 113 | // Global configuration. |
| 114 | struct Configuration { |
Nico Weber | 400a1de | 2021-08-24 14:19:21 | [diff] [blame] | 115 | enum ManifestKind { Default, SideBySide, Embed, No }; |
Jacek Caban | ca34812 | 2023-04-28 12:35:38 | [diff] [blame] | 116 | bool is64() const { return llvm::COFF::is64Bit(machine); } |
Rui Ueyama | 24c5fd0 | 2015-06-18 00:12:42 | [diff] [blame] | 117 | |
kkent030315 | fb974e8 | 2025-01-20 21:38:59 | [diff] [blame] | 118 | std::unique_ptr<MemoryBuffer> dosStub; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 119 | llvm::COFF::MachineTypes machine = IMAGE_FILE_MACHINE_UNKNOWN; |
Jacek Caban | f942949 | 2024-11-24 13:33:14 | [diff] [blame] | 120 | bool machineInferred = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 121 | size_t wordsize; |
| 122 | bool verbose = false; |
| 123 | WindowsSubsystem subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 124 | bool noEntry = false; |
| 125 | std::string outputFile; |
| 126 | std::string importName; |
| 127 | bool demangle = true; |
| 128 | bool doGC = true; |
Zequan Wu | 5bdc5e7 | 2021-02-27 00:38:24 | [diff] [blame] | 129 | ICFLevel doICF = ICFLevel::None; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 130 | bool tailMerge; |
| 131 | bool relocatable = true; |
| 132 | bool forceMultiple = false; |
| 133 | bool forceMultipleRes = false; |
| 134 | bool forceUnresolved = false; |
| 135 | bool debug = false; |
Martin Storsjö | 23e6e88 | 2023-12-15 18:01:13 | [diff] [blame] | 136 | bool includeDwarfChunks = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 137 | bool debugGHashes = false; |
Martin Storsjö | 23e6e88 | 2023-12-15 18:01:13 | [diff] [blame] | 138 | bool writeSymtab = false; |
Rui Ueyama | f95ed69 | 2019-11-13 04:53:15 | [diff] [blame] | 139 | bool driver = false; |
| 140 | bool driverUponly = false; |
| 141 | bool driverWdm = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 142 | bool showTiming = false; |
| 143 | bool showSummary = false; |
Tobias Hieta | 33f9342 | 2023-07-12 07:22:06 | [diff] [blame] | 144 | bool printSearchPaths = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 145 | unsigned debugTypes = static_cast<unsigned>(DebugType::None); |
Nico Weber | 67d311a | 2022-11-14 19:23:56 | [diff] [blame] | 146 | llvm::SmallVector<llvm::StringRef, 0> mllvmOpts; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 147 | std::vector<std::string> natvisFiles; |
Eric Astor | a39b14f | 2020-04-07 20:16:22 | [diff] [blame] | 148 | llvm::StringMap<std::string> namedStreams; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 149 | llvm::SmallString<128> pdbAltPath; |
Nico Weber | f964ca8 | 2021-10-30 15:22:55 | [diff] [blame] | 150 | int pdbPageSize = 4096; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 151 | llvm::SmallString<128> pdbPath; |
| 152 | llvm::SmallString<128> pdbSourcePath; |
| 153 | std::vector<llvm::StringRef> argv; |
Rui Ueyama | eb262ce | 2015-06-04 02:12:16 | [diff] [blame] | 154 | |
| 155 | // Symbols in this set are considered as live by the garbage collector. |
Rui Ueyama | 332fc712 | 2019-07-12 06:12:27 | [diff] [blame] | 156 | std::vector<Symbol *> gcroot; |
Rui Ueyama | b41b7e5 | 2015-05-29 16:21:11 | [diff] [blame] | 157 | |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 158 | std::set<std::string> noDefaultLibs; |
| 159 | bool noDefaultLibAll = false; |
Rui Ueyama | d21b00b | 2015-05-31 19:17:14 | [diff] [blame] | 160 | |
Rui Ueyama | 97dff9e | 2015-06-17 00:16:33 | [diff] [blame] | 161 | // True if we are creating a DLL. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 162 | bool dll = false; |
| 163 | StringRef implib; |
Tobias Hieta | eb4eef9 | 2022-04-12 14:06:46 | [diff] [blame] | 164 | bool noimplib = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 165 | std::set<std::string> delayLoads; |
| 166 | std::map<std::string, int> dllOrder; |
Jacek Caban | 99a2354 | 2024-09-11 12:46:40 | [diff] [blame] | 167 | Symbol *arm64ECIcallHelper = nullptr; |
Rui Ueyama | 97dff9e | 2015-06-17 00:16:33 | [diff] [blame] | 168 | |
Miguel A. Arroyo | 5cd6e21 | 2024-11-12 20:30:48 | [diff] [blame] | 169 | llvm::DenseSet<llvm::StringRef> saveTempsArgs; |
Bob Haarman | 69b196d | 2017-02-08 18:36:41 | [diff] [blame] | 170 | |
Reid Kleckner | af2f7da | 2018-02-06 01:58:26 | [diff] [blame] | 171 | // /guard:cf |
Pengfei Wang | 184377d | 2021-04-14 06:21:52 | [diff] [blame] | 172 | int guardCF = GuardCFLevel::Off; |
Reid Kleckner | af2f7da | 2018-02-06 01:58:26 | [diff] [blame] | 173 | |
Rui Ueyama | cd3f99b | 2015-07-24 23:51:14 | [diff] [blame] | 174 | // Used for SafeSEH. |
Reid Kleckner | fe44a53 | 2019-07-16 18:17:33 | [diff] [blame] | 175 | bool safeSEH = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 176 | Symbol *sehTable = nullptr; |
| 177 | Symbol *sehCount = nullptr; |
Martin Storsjö | 745eb02 | 2020-07-27 20:44:41 | [diff] [blame] | 178 | bool noSEH = false; |
Rui Ueyama | cd3f99b | 2015-07-24 23:51:14 | [diff] [blame] | 179 | |
Peter Collingbourne | 526ff15 | 2015-08-14 04:47:07 | [diff] [blame] | 180 | // Used for /opt:lldlto=N |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 181 | unsigned ltoo = 2; |
Scott Linder | 45ee0a9 | 2023-02-15 17:12:47 | [diff] [blame] | 182 | // Used for /opt:lldltocgo=N |
| 183 | std::optional<unsigned> ltoCgo; |
Peter Collingbourne | 526ff15 | 2015-08-14 04:47:07 | [diff] [blame] | 184 | |
Peter Collingbourne | df5783b | 2015-08-28 22:16:09 | [diff] [blame] | 185 | // Used for /opt:lldltojobs=N |
Alexandre Ganea | 0915825 | 2020-03-27 14:20:39 | [diff] [blame] | 186 | std::string thinLTOJobs; |
Bob Haarman | cde5e5b | 2017-02-02 23:58:14 | [diff] [blame] | 187 | // Used for /opt:lldltopartitions=N |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 188 | unsigned ltoPartitions = 1; |
Peter Collingbourne | df5783b | 2015-08-28 22:16:09 | [diff] [blame] | 189 | |
Martin Storsjö | 7a05c09 | 2024-01-04 14:03:21 | [diff] [blame] | 190 | // Used for /lldltocache=path |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 191 | StringRef ltoCache; |
Martin Storsjö | 7a05c09 | 2024-01-04 14:03:21 | [diff] [blame] | 192 | // Used for /lldltocachepolicy=policy |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 193 | llvm::CachePruningPolicy ltoCachePolicy; |
Peter Collingbourne | 052e855e | 2017-09-08 00:50:50 | [diff] [blame] | 194 | |
rojamd | b79e990 | 2020-11-05 19:41:35 | [diff] [blame] | 195 | // Used for /opt:[no]ltodebugpassmanager |
| 196 | bool ltoDebugPassManager = false; |
| 197 | |
Rui Ueyama | 6600eb1 | 2015-07-04 23:37:32 | [diff] [blame] | 198 | // Used for /merge:from=to (e.g. /merge:.rdata=.text) |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 199 | std::map<StringRef, StringRef> merge; |
Rui Ueyama | 6600eb1 | 2015-07-04 23:37:32 | [diff] [blame] | 200 | |
Rui Ueyama | 440138c | 2016-06-20 03:39:39 | [diff] [blame] | 201 | // Used for /section=.name,{DEKPRSW} to set section attributes. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 202 | std::map<StringRef, uint32_t> section; |
Rui Ueyama | 440138c | 2016-06-20 03:39:39 | [diff] [blame] | 203 | |
Rui Ueyama | 24c5fd0 | 2015-06-18 00:12:42 | [diff] [blame] | 204 | // Options for manifest files. |
Nico Weber | 400a1de | 2021-08-24 14:19:21 | [diff] [blame] | 205 | ManifestKind manifest = Default; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 206 | int manifestID = 1; |
Nico Weber | 400a1de | 2021-08-24 14:19:21 | [diff] [blame] | 207 | llvm::SetVector<StringRef> manifestDependencies; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 208 | bool manifestUAC = true; |
| 209 | std::vector<std::string> manifestInput; |
| 210 | StringRef manifestLevel = "'asInvoker'"; |
| 211 | StringRef manifestUIAccess = "'false'"; |
| 212 | StringRef manifestFile; |
Rui Ueyama | 24c5fd0 | 2015-06-18 00:12:42 | [diff] [blame] | 213 | |
Haohai Wen | 2a631a8 | 2023-07-01 00:58:56 | [diff] [blame] | 214 | // used for /dwodir |
| 215 | StringRef dwoDir; |
| 216 | |
Rui Ueyama | 2edb35a | 2015-06-18 19:09:30 | [diff] [blame] | 217 | // Used for /failifmismatch. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 218 | std::map<StringRef, std::pair<StringRef, InputFile *>> mustMatch; |
Rui Ueyama | 8854d8a | 2015-06-04 19:21:24 | [diff] [blame] | 219 | |
Rui Ueyama | 57175aa | 2018-01-27 00:34:46 | [diff] [blame] | 220 | // Used for /order. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 221 | llvm::StringMap<int> order; |
Rui Ueyama | 57175aa | 2018-01-27 00:34:46 | [diff] [blame] | 222 | |
Peter Collingbourne | 6f24fdb | 2017-01-14 03:14:46 | [diff] [blame] | 223 | // Used for /lldmap. |
Sylvain Audi | b91905a | 2020-03-23 21:06:48 | [diff] [blame] | 224 | std::string lldmapFile; |
| 225 | |
| 226 | // Used for /map. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 227 | std::string mapFile; |
Peter Collingbourne | 6f24fdb | 2017-01-14 03:14:46 | [diff] [blame] | 228 | |
Pengxuan Zheng | 7b31756 | 2022-09-20 00:21:21 | [diff] [blame] | 229 | // Used for /mapinfo. |
| 230 | bool mapInfo = false; |
| 231 | |
Bob Haarman | 63efb28 | 2019-07-11 18:03:14 | [diff] [blame] | 232 | // Used for /thinlto-index-only: |
| 233 | llvm::StringRef thinLTOIndexOnlyArg; |
| 234 | |
Ivan Tadeu Ferreira Antunes Filho | 73fd9d3 | 2023-04-04 16:57:53 | [diff] [blame] | 235 | // Used for /thinlto-prefix-replace: |
| 236 | // Replace the prefix in paths generated for ThinLTO, replacing |
| 237 | // thinLTOPrefixReplaceOld with thinLTOPrefixReplaceNew. If |
| 238 | // thinLTOPrefixReplaceNativeObject is defined, replace the prefix of object |
| 239 | // file paths written to the response file given in the |
| 240 | // --thinlto-index-only=${response} option with |
| 241 | // thinLTOPrefixReplaceNativeObject, instead of thinLTOPrefixReplaceNew. |
| 242 | llvm::StringRef thinLTOPrefixReplaceOld; |
| 243 | llvm::StringRef thinLTOPrefixReplaceNew; |
| 244 | llvm::StringRef thinLTOPrefixReplaceNativeObject; |
Bob Haarman | 5011b83 | 2019-07-11 18:48:58 | [diff] [blame] | 245 | |
| 246 | // Used for /thinlto-object-suffix-replace: |
| 247 | std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace; |
| 248 | |
Bob Haarman | 5375b94 | 2019-08-21 18:24:59 | [diff] [blame] | 249 | // Used for /lto-obj-path: |
| 250 | llvm::StringRef ltoObjPath; |
| 251 | |
Yolanda Chen | 4f9c61e | 2021-03-25 02:55:18 | [diff] [blame] | 252 | // Used for /lto-cs-profile-generate: |
| 253 | bool ltoCSProfileGenerate = false; |
| 254 | |
| 255 | // Used for /lto-cs-profile-path |
| 256 | llvm::StringRef ltoCSProfileFile; |
| 257 | |
Yolanda Chen | 8fa16cc | 2021-08-11 16:45:55 | [diff] [blame] | 258 | // Used for /lto-pgo-warn-mismatch: |
| 259 | bool ltoPGOWarnMismatch = true; |
| 260 | |
chrulski-intel | a9fe23c | 2024-03-20 15:02:43 | [diff] [blame] | 261 | // Used for /lto-sample-profile: |
| 262 | llvm::StringRef ltoSampleProfileName; |
| 263 | |
Zequan Wu | 763671f | 2020-07-21 20:46:11 | [diff] [blame] | 264 | // Used for /call-graph-ordering-file: |
| 265 | llvm::MapVector<std::pair<const SectionChunk *, const SectionChunk *>, |
| 266 | uint64_t> |
| 267 | callGraphProfile; |
| 268 | bool callGraphProfileSort = false; |
| 269 | |
| 270 | // Used for /print-symbol-order: |
| 271 | StringRef printSymbolOrder; |
| 272 | |
Alex Brachet | fd9962e | 2022-07-11 21:31:01 | [diff] [blame] | 273 | // Used for /vfsoverlay: |
| 274 | std::unique_ptr<llvm::vfs::FileSystem> vfs; |
| 275 | |
Rui Ueyama | e6a33e1 | 2019-08-07 10:16:21 | [diff] [blame] | 276 | uint64_t align = 4096; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 277 | uint64_t imageBase = -1; |
| 278 | uint64_t fileAlign = 512; |
| 279 | uint64_t stackReserve = 1024 * 1024; |
| 280 | uint64_t stackCommit = 4096; |
| 281 | uint64_t heapReserve = 1024 * 1024; |
| 282 | uint64_t heapCommit = 4096; |
| 283 | uint32_t majorImageVersion = 0; |
| 284 | uint32_t minorImageVersion = 0; |
Martin Storsjö | bc8f3b4 | 2020-10-04 08:52:36 | [diff] [blame] | 285 | // If changing the default os/subsys version here, update the default in |
| 286 | // the MinGW driver accordingly. |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 287 | uint32_t majorOSVersion = 6; |
| 288 | uint32_t minorOSVersion = 0; |
Martin Storsjö | 45c4c54 | 2020-10-03 22:29:45 | [diff] [blame] | 289 | uint32_t majorSubsystemVersion = 6; |
| 290 | uint32_t minorSubsystemVersion = 0; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 291 | uint32_t timestamp = 0; |
| 292 | uint32_t functionPadMin = 0; |
Alexandre Ganea | 356139b | 2023-10-06 02:33:58 | [diff] [blame] | 293 | uint32_t timeTraceGranularity = 0; |
Aleksei Nurmukhametov | 76947e0 | 2023-11-08 20:21:05 | [diff] [blame] | 294 | uint16_t dependentLoadFlags = 0; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 295 | bool dynamicBase = true; |
| 296 | bool allowBind = true; |
Rui Ueyama | a2923b2 | 2020-03-13 10:41:18 | [diff] [blame] | 297 | bool cetCompat = false; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 298 | bool nxCompat = true; |
| 299 | bool allowIsolation = true; |
| 300 | bool terminalServerAware = true; |
| 301 | bool largeAddressAware = false; |
| 302 | bool highEntropyVA = false; |
| 303 | bool appContainer = false; |
| 304 | bool mingw = false; |
| 305 | bool warnMissingOrderSymbol = true; |
| 306 | bool warnLocallyDefinedImported = true; |
| 307 | bool warnDebugInfoUnusable = true; |
Reid Kleckner | deaf121 | 2019-10-29 22:57:40 | [diff] [blame] | 308 | bool warnLongSectionNames = true; |
Martin Storsjö | ce211c5 | 2021-06-17 18:51:37 | [diff] [blame] | 309 | bool warnStdcallFixup = true; |
Rui Ueyama | 136d27a | 2019-07-11 05:40:30 | [diff] [blame] | 310 | bool incremental = true; |
| 311 | bool integrityCheck = false; |
| 312 | bool killAt = false; |
| 313 | bool repro = false; |
| 314 | bool swaprunCD = false; |
| 315 | bool swaprunNet = false; |
Bob Haarman | 63efb28 | 2019-07-11 18:03:14 | [diff] [blame] | 316 | bool thinLTOEmitImportsFiles; |
| 317 | bool thinLTOIndexOnly; |
Alexandre Ganea | 356139b | 2023-10-06 02:33:58 | [diff] [blame] | 318 | bool timeTraceEnabled = false; |
Martin Storsjö | 7f0e6c3 | 2020-04-25 21:49:44 | [diff] [blame] | 319 | bool autoImport = false; |
| 320 | bool pseudoRelocs = false; |
Martin Storsjö | ce211c5 | 2021-06-17 18:51:37 | [diff] [blame] | 321 | bool stdcallFixup = false; |
Qfrost | 3f55853 | 2023-01-02 09:20:15 | [diff] [blame] | 322 | bool writeCheckSum = false; |
Matheus Izvekov | 3923e61 | 2023-10-02 20:54:43 | [diff] [blame] | 323 | EmitKind emit = EmitKind::Obj; |
Martin Storsjö | a67ae8c | 2023-10-20 20:44:44 | [diff] [blame] | 324 | bool allowDuplicateWeak = false; |
Zequan Wu | aaf3a8d | 2023-12-05 19:57:45 | [diff] [blame] | 325 | BuildIDHash buildIDHash = BuildIDHash::None; |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 326 | }; |
| 327 | |
Fangrui Song | 982575fd | 2024-12-04 04:51:50 | [diff] [blame] | 328 | struct COFFSyncStream : SyncStream { |
| 329 | COFFLinkerContext &ctx; |
| 330 | COFFSyncStream(COFFLinkerContext &ctx, DiagLevel level); |
| 331 | }; |
| 332 | |
| 333 | template <typename T> |
| 334 | std::enable_if_t<!std::is_pointer_v<std::remove_reference_t<T>>, |
| 335 | const COFFSyncStream &> |
| 336 | operator<<(const COFFSyncStream &s, T &&v) { |
| 337 | s.os << std::forward<T>(v); |
| 338 | return s; |
| 339 | } |
| 340 | |
| 341 | inline const COFFSyncStream &operator<<(const COFFSyncStream &s, |
| 342 | const char *v) { |
| 343 | s.os << v; |
| 344 | return s; |
| 345 | } |
| 346 | |
| 347 | inline const COFFSyncStream &operator<<(const COFFSyncStream &s, Error v) { |
| 348 | s.os << llvm::toString(std::move(v)); |
| 349 | return s; |
| 350 | } |
| 351 | |
| 352 | // Report a log if -verbose is specified. |
| 353 | COFFSyncStream Log(COFFLinkerContext &ctx); |
| 354 | |
| 355 | // Print a message to stdout. |
| 356 | COFFSyncStream Msg(COFFLinkerContext &ctx); |
| 357 | |
| 358 | // Report a warning. Upgraded to an error if /WX is specified. |
| 359 | COFFSyncStream Warn(COFFLinkerContext &ctx); |
| 360 | |
| 361 | // Report an error that will suppress the output file generation. |
| 362 | COFFSyncStream Err(COFFLinkerContext &ctx); |
| 363 | |
| 364 | // Report a fatal error that exits immediately. This should generally be avoided |
| 365 | // in favor of Err. |
| 366 | COFFSyncStream Fatal(COFFLinkerContext &ctx); |
| 367 | |
| 368 | uint64_t errCount(COFFLinkerContext &ctx); |
| 369 | |
Nico Weber | 7c26641 | 2022-08-08 15:32:26 | [diff] [blame] | 370 | } // namespace lld::coff |
Rui Ueyama | 411c6360 | 2015-05-28 19:09:30 | [diff] [blame] | 371 | |
| 372 | #endif |