blob: 796610e5e72b7ff02b153836fc21139a2fe88d91 [file] [log] [blame]
Sam Cleggc94d3932017-11-17 18:14:091//===- Config.h -------------------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:563// 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 Cleggc94d3932017-11-17 18:14:096//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_WASM_CONFIG_H
10#define LLD_WASM_CONFIG_H
11
12#include "llvm/ADT/StringRef.h"
Rui Ueyama7d5a1372017-11-29 22:21:3713#include "llvm/ADT/StringSet.h"
Sam Cleggc94d3932017-11-17 18:14:0914#include "llvm/BinaryFormat/Wasm.h"
Sam Cleggc729c1b2018-05-30 18:07:5215#include "llvm/Support/CachePruning.h"
Sam Cleggc94d3932017-11-17 18:14:0916
Sam Cleggc94d3932017-11-17 18:14:0917namespace lld {
18namespace wasm {
19
Sam Clegg206884b2020-05-01 16:14:5920// 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.
24enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportFuncs };
25
Sam Clegga1282a32019-05-08 16:20:0526// 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 Cleggc94d3932017-11-17 18:14:0930struct Configuration {
Sam Clegg25134072020-10-07 21:48:3731 bool bsymbolic;
Rui Ueyama136d27a2019-07-11 05:40:3032 bool checkFeatures;
33 bool compressRelocations;
34 bool demangle;
35 bool disableVerify;
Dan Gohman46a32682020-06-12 19:05:4036 bool experimentalPic;
Rui Ueyama136d27a2019-07-11 05:40:3037 bool emitRelocs;
38 bool exportAll;
39 bool exportDynamic;
40 bool exportTable;
Jacob Gravelle92ed86d2019-08-27 22:58:2141 bool growableTable;
Rui Ueyama136d27a2019-07-11 05:40:3042 bool gcSections;
43 bool importMemory;
44 bool sharedMemory;
Rui Ueyama136d27a2019-07-11 05:40:3045 bool importTable;
Wouter van Oortmerssen29f8c9f2020-07-06 20:34:1646 llvm::Optional<bool> is64;
Rui Ueyama136d27a2019-07-11 05:40:3047 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 Livelyc496d842020-04-03 23:18:2957 uint64_t globalBase;
58 uint64_t initialMemory;
59 uint64_t maxMemory;
60 uint64_t zStackSize;
Rui Ueyama136d27a2019-07-11 05:40:3061 unsigned ltoPartitions;
62 unsigned ltoo;
63 unsigned optimize;
Alexandre Ganea09158252020-03-27 14:20:3964 llvm::StringRef thinLTOJobs;
Arthur Eubanks1314a492020-12-01 20:22:2765 bool ltoNewPassManager;
66 bool ltoDebugPassManager;
Sam Clegg206884b2020-05-01 16:14:5967 UnresolvedPolicy unresolvedSymbols;
Sam Clegga1282a32019-05-08 16:20:0568
Rui Ueyama136d27a2019-07-11 05:40:3069 llvm::StringRef entry;
Sam Cleggcc2da552020-03-27 23:52:2770 llvm::StringRef mapFile;
Rui Ueyama136d27a2019-07-11 05:40:3071 llvm::StringRef outputFile;
72 llvm::StringRef thinLTOCacheDir;
Sam Cleggc94d3932017-11-17 18:14:0973
Rui Ueyama136d27a2019-07-11 05:40:3074 llvm::StringSet<> allowUndefinedSymbols;
75 llvm::StringSet<> exportedSymbols;
Sam Clegga6f40642021-04-05 15:00:3076 std::vector<llvm::StringRef> requiredExports;
Rui Ueyama136d27a2019-07-11 05:40:3077 std::vector<llvm::StringRef> searchPaths;
78 llvm::CachePruningPolicy thinLTOCachePolicy;
79 llvm::Optional<std::vector<std::string>> features;
Sam Cleggbfb75342018-11-15 00:37:2180
Sam Clegga1282a32019-05-08 16:20:0581 // The following config options do not directly correspond to any
82 // particualr command line options.
83
Sam Cleggbfb75342018-11-15 00:37:2184 // True if we are creating position-independent code.
Rui Ueyama136d27a2019-07-11 05:40:3085 bool isPic;
Sam Clegg1a1df722019-08-27 04:19:3486
Andy Wingo4fc25572021-02-12 19:01:4187 // 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 Clegg1a1df722019-08-27 04:19:3491 // The table offset at which to place function addresses. We reserve zero
Kazuaki Ishizaki7ae3d332020-01-06 18:21:0592 // for the null function pointer. This gets set to 1 for executables and 0
Sam Clegg1a1df722019-08-27 04:19:3493 // for shared libraries (since they always added to a dynamic offset at
94 // runtime).
95 uint32_t tableBase = 0;
Sam Cleggc94d3932017-11-17 18:14:0996};
97
98// The only instance of Configuration struct.
Rui Ueyama136d27a2019-07-11 05:40:3099extern Configuration *config;
Sam Cleggc94d3932017-11-17 18:14:09100
101} // namespace wasm
102} // namespace lld
103
104#endif