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