2017-11-18 02:14:09 +08:00
|
|
|
//===- Config.h -------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-11-18 02:14:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_CONFIG_H
|
|
|
|
#define LLD_WASM_CONFIG_H
|
|
|
|
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
2017-11-30 06:21:37 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "llvm/BinaryFormat/Wasm.h"
|
2018-05-31 02:07:52 +08:00
|
|
|
#include "llvm/Support/CachePruning.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
2019-05-09 00:20:05 +08:00
|
|
|
// This struct contains the global configuration for the linker.
|
|
|
|
// Most fields are direct mapping from the command line options
|
|
|
|
// and such fields have the same name as the corresponding options.
|
|
|
|
// Most fields are initialized by the driver.
|
2017-11-18 02:14:09 +08:00
|
|
|
struct Configuration {
|
2017-11-29 04:27:21 +08:00
|
|
|
bool AllowUndefined;
|
2019-03-26 12:11:05 +08:00
|
|
|
bool CheckFeatures;
|
2018-09-27 08:46:54 +08:00
|
|
|
bool CompressRelocations;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool Demangle;
|
2018-05-31 02:07:52 +08:00
|
|
|
bool DisableVerify;
|
2018-06-07 09:27:07 +08:00
|
|
|
bool ExportAll;
|
2018-09-28 05:06:25 +08:00
|
|
|
bool ExportDynamic;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool ExportTable;
|
2018-01-31 09:45:47 +08:00
|
|
|
bool GcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool ImportMemory;
|
2018-11-07 01:59:32 +08:00
|
|
|
bool SharedMemory;
|
2018-03-28 20:53:29 +08:00
|
|
|
bool ImportTable;
|
[WebAssembly] Add a flag to control merging data segments
Merging data segments produces smaller code sizes because each segment
has some boilerplate. Therefore, merging data segments is generally the
right approach, especially with wasm where binaries are typically
delivered over the network.
However, when analyzing wasm binaries, it can be helpful to get a
conservative picture of which functions are using which data
segments[0]. Perhaps there is a large data segment that you didn't
expect to be included in the wasm, introduced by some library you're
using, and you'd like to know which library it was. In this scenario,
merging data segments only makes the analysis worse.
Alternatively, perhaps you will remove some dead functions by-hand[1]
that can't be statically proven dead by the compiler or lld, and
removing these functions might make some data garbage collect-able, and
you'd like to run `--gc-sections` again so that this now-unused data can
be collected. If the segments were originally merged, then a single use
of the merged data segment will entrench all of the data.
[0] https://github.com/rustwasm/twiggy
[1] https://github.com/fitzgen/wasm-snip
Patch by Nick Fitzgerald!
Differential Revision: https://reviews.llvm.org/D46417
llvm-svn: 332013
2018-05-11 02:23:51 +08:00
|
|
|
bool MergeDataSegments;
|
2018-11-15 08:37:21 +08:00
|
|
|
bool Pie;
|
2018-01-31 09:45:47 +08:00
|
|
|
bool PrintGcSections;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool Relocatable;
|
2018-05-31 02:07:52 +08:00
|
|
|
bool SaveTemps;
|
2018-11-15 08:37:21 +08:00
|
|
|
bool Shared;
|
2017-11-29 04:27:21 +08:00
|
|
|
bool StripAll;
|
|
|
|
bool StripDebug;
|
2018-05-04 01:21:53 +08:00
|
|
|
bool StackFirst;
|
2019-02-06 10:35:18 +08:00
|
|
|
bool Trace;
|
2017-11-29 04:27:21 +08:00
|
|
|
uint32_t GlobalBase;
|
|
|
|
uint32_t InitialMemory;
|
|
|
|
uint32_t MaxMemory;
|
|
|
|
uint32_t ZStackSize;
|
2018-05-31 02:07:52 +08:00
|
|
|
unsigned LTOPartitions;
|
|
|
|
unsigned LTOO;
|
|
|
|
unsigned Optimize;
|
|
|
|
unsigned ThinLTOJobs;
|
2019-05-09 00:20:05 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
llvm::StringRef Entry;
|
|
|
|
llvm::StringRef OutputFile;
|
2018-05-31 02:07:52 +08:00
|
|
|
llvm::StringRef ThinLTOCacheDir;
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2017-11-30 06:21:37 +08:00
|
|
|
llvm::StringSet<> AllowUndefinedSymbols;
|
2017-11-29 04:27:21 +08:00
|
|
|
std::vector<llvm::StringRef> SearchPaths;
|
2018-05-31 02:07:52 +08:00
|
|
|
llvm::CachePruningPolicy ThinLTOCachePolicy;
|
2019-03-26 12:11:05 +08:00
|
|
|
llvm::Optional<std::vector<std::string>> Features;
|
2018-11-15 08:37:21 +08:00
|
|
|
|
2019-05-09 00:20:05 +08:00
|
|
|
// The following config options do not directly correspond to any
|
|
|
|
// particualr command line options.
|
|
|
|
|
2018-11-15 08:37:21 +08:00
|
|
|
// True if we are creating position-independent code.
|
|
|
|
bool Pic;
|
2017-11-18 02:14:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// The only instance of Configuration struct.
|
|
|
|
extern Configuration *Config;
|
|
|
|
|
|
|
|
} // namespace wasm
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|