Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/src/settings_internal.js
4128 views
1
//
2
// @license
3
// Copyright 2019 The Emscripten Authors
4
// SPDX-License-Identifier: MIT
5
//
6
7
//
8
// Settings in this file work exactly like those in settings.js but are not
9
// set-able from the command line and therefore are not part of the public
10
// ABI. This means that these settings are an internal detail of the toolchain
11
// and can be added/removed/renamed without fear of breaking out users.
12
//
13
14
// List of symbols exported from compiled code
15
// These are raw symbol names and are not mangled to include the leading
16
// underscore.
17
var WASM_EXPORTS = [];
18
19
// Similar to above but only includes the global/data symbols.
20
var WASM_GLOBAL_EXPORTS = [];
21
22
// An array of all symbols exported from all the side modules specified on the
23
// command line.
24
// These are raw symbol names and are not mangled to include the leading
25
// underscore.
26
var SIDE_MODULE_EXPORTS = [];
27
28
// All symbols imported by side modules. These are symbols that the main
29
// module (or other side modules) will need to provide.
30
var SIDE_MODULE_IMPORTS = [];
31
32
// Like EXPORTED_FUNCTIONS, but will not error if symbol is missing.
33
// The start/stop symbols are included by default so that then can be extracted
34
// from the binary and embedded into the generated JS. The PostEmscripten pass
35
// in binaryen will then strip these exports so they will not appear in the
36
// final shipping binary.
37
// They are included here rather than in REQUIRED_EXPORTS because not all
38
// programs contains EM_JS or EM_ASM data section, in which case these symbols
39
// won't exist.
40
var EXPORT_IF_DEFINED = ['__start_em_asm', '__stop_em_asm',
41
'__start_em_lib_deps', '__stop_em_lib_deps',
42
'__start_em_js', '__stop_em_js'];
43
44
// Like EXPORTED_FUNCTIONS, but symbol is required to exist in native code.
45
// This means wasm-ld will fail if these symbols are missing.
46
var REQUIRED_EXPORTS = [];
47
48
// stores the base name of the output file (-o TARGET_BASENAME.js)
49
var TARGET_BASENAME = '';
50
51
// stores the base name (with extension) of the output JS file
52
var TARGET_JS_NAME = '';
53
54
// Indicates that the syscalls (which we see statically) indicate that they need
55
// full filesystem support. Otherwise, when just a small subset are used, we can
56
// get away without including the full filesystem - in particular, if open() is
57
// never used, then we don't actually need to support operations on streams.
58
var SYSCALLS_REQUIRE_FILESYSTEM = true;
59
60
// A list of feature flags to pass to each binaryen invocation (like wasm-opt,
61
// etc.). This is received from wasm-emscripten-finalize, which reads it from
62
// the features section.
63
var BINARYEN_FEATURES = [];
64
65
// Whether EMCC_AUTODEBUG is on, which automatically instruments code for
66
// runtime logging that can help in debugging.
67
var AUTODEBUG = false;
68
69
// Whether we should use binaryen's wasm2js to convert our wasm to JS. Set when
70
// wasm backend is in use with WASM=0 (to enable non-wasm output, we compile to
71
// wasm normally, then compile that to JS).
72
var WASM2JS = false;
73
74
// Whether we should link in the runtime for ubsan.
75
// 0 means do not link ubsan, 1 means link minimal ubsan runtime.
76
// This is not meant to be used with `-s`. Instead, to use ubsan, use clang flag
77
// -fsanitize=undefined. To use minimal runtime, also pass
78
// `-fsanitize-minimal-runtime`.
79
var UBSAN_RUNTIME = 0;
80
81
// Whether we should link in LSan's runtime library. This is intended to be used
82
// by -fsanitize=leak instead of used directly.
83
var USE_LSAN = false;
84
85
// Whether we should link in ASan's runtime library. This is intended to be used
86
// by -fsanitize=leak instead of used directly.
87
var USE_ASAN = false;
88
89
// Whether embind has been enabled.
90
var EMBIND = false;
91
92
// Whether a TypeScript definition file has been requested.
93
var EMIT_TSD = false;
94
95
// This will be true during the generation of code in run_embind_gen. Helpful
96
// for detecting if either TSD file or embind AOT JS generation is running.
97
var EMBIND_GEN_MODE = false;
98
99
// Whether the main() function reads the argc/argv parameters.
100
var MAIN_READS_PARAMS = true;
101
102
var WASI_MODULE_NAME = "wasi_snapshot_preview1";
103
104
// List of JS libraries explicitly linked against. This includes JS specified
105
// on the command line via `-lfoo.js` / `--js-library`. It does not include
106
// implicitly linked libraries added by the JS compiler.
107
var JS_LIBRARIES = [];
108
109
// This will contain the emscripten version. This can be useful in combination
110
// with RETAIN_COMPILER_SETTINGS
111
var EMSCRIPTEN_VERSION = '';
112
113
// Will be set to 0 if -fno-rtti is used on the command line.
114
var USE_RTTI = true;
115
116
// This will contain the optimization level (-Ox).
117
var OPT_LEVEL = 0;
118
119
// This will contain the debug level (-gx).
120
var DEBUG_LEVEL = 0;
121
122
// This will contain the shrink level (1 or 2 for -Os or -Oz, or just 0).
123
var SHRINK_LEVEL = 0;
124
125
// Whether or not to emit the name section in the final wasm binaryen.
126
var EMIT_NAME_SECTION = false;
127
128
// Whether we are emitting a symbol map.
129
var EMIT_SYMBOL_MAP = false;
130
131
// List of symbols explicitly exported by user on the command line.
132
var USER_EXPORTS = [];
133
134
// name of the file containing wasm binary, if relevant
135
var WASM_BINARY_FILE = '';
136
137
// Base URL the source mapfile, if relevant
138
var SOURCE_MAP_BASE = '';
139
140
// If set to 1 then base64 decoding functions will be included in the bundle.
141
// This is set internally when needed (SINGLE_FILE)
142
var SUPPORT_BASE64_EMBEDDING = false;
143
144
// the possible environments the code may run in.
145
var ENVIRONMENT_MAY_BE_WEB = true;
146
var ENVIRONMENT_MAY_BE_WORKER = true;
147
var ENVIRONMENT_MAY_BE_NODE = true;
148
var ENVIRONMENT_MAY_BE_SHELL = true;
149
var ENVIRONMENT_MAY_BE_WEBVIEW = true;
150
151
// Whether to minify import and export names in the minify_wasm_js stage.
152
// Currently always off for MEMORY64.
153
var MINIFY_WASM_IMPORTS_AND_EXPORTS = false;
154
155
// Whether to minify imported module names.
156
var MINIFY_WASM_IMPORTED_MODULES = false;
157
158
// Whether to minify exports from the Wasm module.
159
var MINIFY_WASM_EXPORT_NAMES = true;
160
161
// Used to track whether target environment supports the 'globalThis' attribute.
162
var SUPPORTS_GLOBALTHIS = false;
163
164
// Used to track whether target environment supports the 'Promise.any'.
165
var SUPPORTS_PROMISE_ANY = false;
166
167
// Internal: value of -flto argument (either full or thin)
168
var LTO = 0;
169
170
// Whether we may be accessing the address 2GB or higher. If so, then we need
171
// to interpret incoming i32 pointers as unsigned.
172
//
173
// This setting does not apply (and is never set to true) under MEMORY64, since
174
// in that case we get 64-bit pointers coming through to JS (converting them to
175
// i53 in most cases).
176
var CAN_ADDRESS_2GB = false;
177
178
// Whether to emit DWARF in a separate wasm file on the side (this is not called
179
// "split" because there is already a DWARF concept by that name).
180
// When DWARF is on the side, the main file has no DWARF info, while the side
181
// file, ending in .debug.wasm, has the same wasm binary + all the debug
182
// sections.
183
// This has no effect if DWARF is not being emitted.
184
var SEPARATE_DWARF = false;
185
186
// New WebAssembly exception handling
187
var WASM_EXCEPTIONS = false;
188
189
// Set to true if the program has a main function. By default this is
190
// enabled, but if `--no-entry` is passed, or if `_main` is not part of
191
// EXPORTED_FUNCTIONS then this gets set to 0.
192
var EXPECT_MAIN = true;
193
194
// If true, building against Emscripten's wasm heap memory profiler.
195
var MEMORYPROFILER = false;
196
197
// Set automatically to :
198
// - 1 when using `-gsource-map`
199
// - 2 when using `gsource-map=inline` (embed sources content in souce map)
200
var GENERATE_SOURCE_MAP = 0;
201
202
var GENERATE_DWARF = false;
203
204
// Memory layout. These are only used/set in RELOCATABLE builds. Otherwise
205
// memory layout is fixed in the wasm binary at link time.
206
var STACK_HIGH = 0;
207
var STACK_LOW = 0;
208
var HEAP_BASE = 0;
209
210
// Used internally. set when there is a main() function.
211
// Also set when in a linkable module, as the main() function might
212
// arrive from a dynamically-linked library, and not necessarily
213
// the current compilation unit.
214
// Also set for STANDALONE_WASM since the _start function is needed to call
215
// static ctors, even if there is no user main.
216
var HAS_MAIN = false;
217
218
// Set to true if we are linking as C++ and including C++ stdlibs
219
var LINK_AS_CXX = false;
220
221
// Set when closure compiler may be run: Either emcc will run it, or the user
222
// might run it after emcc. Either way, some JS changes and annotations must be
223
// emitted in that case for closure compiler.
224
var MAYBE_CLOSURE_COMPILER = false;
225
226
// List of closure args for the closure compiler.
227
// This list is populated from the --closure-args argument and can be extended
228
// in ports using settings.CLOSURE_ARGS
229
var CLOSURE_ARGS = [];
230
231
// Set when some minimum browser version triggers doesn't support the minimum
232
// set of JavaScript features. This triggers transpilation using babel.
233
var TRANSPILE = false;
234
235
// A copy of the default the default INCOMING_MODULE_JS_API. (Soon to
236
// include additional items).
237
var ALL_INCOMING_MODULE_JS_API = [];
238
239
// List of all imports that are weak, and therefore allowed to be undefined at
240
// runtime. This is used by the JS compiler to avoid build-time warnings/errors
241
// when weak symbols are undefined. Only applies in the case of dynamic linking
242
// (MAIN_MODULE).
243
var WEAK_IMPORTS = [];
244
245
var STACK_FIRST = false;
246
247
var HAVE_EM_ASM = true;
248
249
var PRE_JS_FILES = [];
250
251
var POST_JS_FILES = [];
252
253
// Set when -pthread / -sPTHREADS is passed
254
var PTHREADS = false;
255
256
var BULK_MEMORY = false;
257
258
var MINIFY_WHITESPACE = true;
259
260
var ASYNCIFY_IMPORTS_EXCEPT_JS_LIBS = [];
261
262
var WARN_DEPRECATED = true;
263
264
// WebGL 2 provides new garbage-free entry points to call to WebGL. Use
265
// those always when possible.
266
// We currently set this to false for certain browser when large memory sizes
267
// (2gb+ or 4gb+) are used
268
var WEBGL_USE_GARBAGE_FREE_APIS = false;
269
270
var INCLUDE_WEBGL1_FALLBACK = true;
271
272
var MINIFICATION_MAP = '';
273
274
var OUTPUT_FORMAT = '';
275
276
// Whether we should load the WASM source map at runtime.
277
// This is enabled automatically when using -gsource-map with sanitizers.
278
var LOAD_SOURCE_MAP = false;
279
280