Skip to content

Commit 4182c11

Browse files
authored
Add new --emit-minification-map flag and use it in metadce tests (#22428)
This greatly increases the utility of the output files for these tests.
1 parent 4ec07a2 commit 4182c11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+218
-174
lines changed

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.65 (in development)
2222
-----------------------
23+
- A new `--emit-minification-map` command line flag was added, which can be used
24+
to emit a minifiction map in the case that import/export minification is
25+
performed (this happens at higher optimization levels). (#22428)
2326
- Remove `Module['quit']` handling. This could be used to override the internal
2427
method for shutting down the program, but it was neither documented nor
2528
tested. Programs that want to intercept the shutting down of a program can

docs/emcc.txt

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ Options that are modified or new in *emcc* are listed below:
240240
"[name].js.symbols" (with WASM symbols) and
241241
"[name].wasm.js.symbols" (with ASM.js symbols)
242242

243+
"--emit-minification-map <file>"
244+
[link] In cases where emscripten performs import/export minificiton
245+
this option can be used to output a file that maps minified names
246+
back to their original names. The format of this file is single
247+
line per import/export of the form "<minname>:<origname>".
248+
243249
"-flto"
244250
[compile+link] Enables link-time optimizations (LTO).
245251

emcc.py

+2
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,8 @@ def consume_arg_file():
12861286
elif check_flag('--emit-symbol-map'):
12871287
options.emit_symbol_map = True
12881288
settings.EMIT_SYMBOL_MAP = 1
1289+
elif check_arg('--emit-minification-map'):
1290+
settings.MINIFICATION_MAP = consume_arg()
12891291
elif check_arg('--embed-file'):
12901292
options.embed_files.append(consume_arg())
12911293
elif check_arg('--preload-file'):

site/source/docs/tools_reference/emcc.rst

+9
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ Options that are modified or new in *emcc* are listed below:
241241

242242
.. note:: When used with ``-sWASM=2``, two symbol files are created. ``[name].js.symbols`` (with WASM symbols) and ``[name].wasm.js.symbols`` (with ASM.js symbols)
243243

244+
.. _emcc-emit-minification-map:
245+
246+
``--emit-minification-map <file>``
247+
[link]
248+
In cases where emscripten performs import/export minificiton this option can
249+
be used to output a file that maps minified names back to their original
250+
names. The format of this file is single line per import/export of the form
251+
``<minname>:<origname>``.
252+
244253
.. _emcc-lto:
245254

246255
``-flto``

src/settings_internal.js

+2
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,5 @@ var WARN_DEPRECATED = true;
267267
var WEBGL_USE_GARBAGE_FREE_APIS = false;
268268

269269
var INCLUDE_WEBGL1_FALLBACK = true;
270+
271+
var MINIFICATION_MAP = '';
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
e
2-
f
3-
g
4-
h
1+
e (memory)
2+
f (__wasm_call_ctors)
3+
g (main)
4+
h (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a.a
2-
a.b
3-
a.c
4-
a.d
1+
a (fd_write)
2+
b (fd_read)
3+
c (fd_close)
4+
d (__syscall_openat)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (fd_write)
2+
b (fd_read)
3+
c (fd_close)
4+
d (__syscall_openat)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
q
2-
r
3-
s
4-
t
1+
q (memory)
2+
r (__wasm_call_ctors)
3+
s (main)
4+
t (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
a.a
2-
a.b
3-
a.c
4-
a.d
5-
a.e
6-
a.f
7-
a.g
8-
a.h
9-
a.i
10-
a.j
11-
a.k
12-
a.l
13-
a.m
14-
a.n
15-
a.o
16-
a.p
1+
a (emscripten_date_now)
2+
b (emscripten_err)
3+
c (getentropy)
4+
d (emscripten_resize_heap)
5+
e (emscripten_out)
6+
f (_wasmfs_stdin_get_char)
7+
g (_wasmfs_get_preloaded_path_name)
8+
h (_wasmfs_get_preloaded_parent_path)
9+
i (_wasmfs_get_preloaded_file_size)
10+
j (_wasmfs_get_preloaded_file_mode)
11+
k (_wasmfs_get_preloaded_child_path)
12+
l (_wasmfs_get_num_preloaded_files)
13+
m (_wasmfs_get_num_preloaded_dirs)
14+
n (_wasmfs_copy_preloaded_file_data)
15+
o (_emscripten_memcpy_js)
16+
p (_abort_js)
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
a
2-
b
3-
c
4-
d
5-
e
6-
f
7-
g
8-
h
9-
i
10-
j
11-
k
12-
l
13-
m
14-
n
15-
o
16-
p
1+
a (emscripten_date_now)
2+
b (emscripten_err)
3+
c (getentropy)
4+
d (emscripten_resize_heap)
5+
e (emscripten_out)
6+
f (_wasmfs_stdin_get_char)
7+
g (_wasmfs_get_preloaded_path_name)
8+
h (_wasmfs_get_preloaded_parent_path)
9+
i (_wasmfs_get_preloaded_file_size)
10+
j (_wasmfs_get_preloaded_file_mode)
11+
k (_wasmfs_get_preloaded_child_path)
12+
l (_wasmfs_get_num_preloaded_files)
13+
m (_wasmfs_get_num_preloaded_dirs)
14+
n (_wasmfs_copy_preloaded_file_data)
15+
o (_emscripten_memcpy_js)
16+
p (_abort_js)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
c
2-
d
3-
e
4-
f
1+
c (memory)
2+
d (__wasm_call_ctors)
3+
e (main)
4+
f (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a.a
2-
a.b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a
2-
b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
c
2-
d
3-
e
4-
f
1+
c (memory)
2+
d (__wasm_call_ctors)
3+
e (main)
4+
f (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a.a
2-
a.b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a
2-
b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
b
2-
c
3-
d
4-
e
1+
b (memory)
2+
c (__wasm_call_ctors)
3+
d (main)
4+
e (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a.a
1+
a (fd_write)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a
1+
a (fd_write)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
a
2-
b
3-
c
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
c
2-
d
3-
e
4-
f
1+
c (memory)
2+
d (__wasm_call_ctors)
3+
e (main)
4+
f (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a.a
2-
a.b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
a
2-
b
1+
a (fd_write)
2+
b (_emscripten_memcpy_js)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (main)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
b
2-
c
3-
d
4-
e
5-
f
1+
b (memory)
2+
c (__wasm_call_ctors)
3+
d (__main_argc_argv)
4+
e (__indirect_function_table)
5+
f (_emscripten_stack_alloc)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a.a
1+
a (emscripten_resize_heap)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a
1+
a (emscripten_resize_heap)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
b
2-
c
3-
d
4-
e
5-
f
1+
b (memory)
2+
c (__wasm_call_ctors)
3+
d (__main_argc_argv)
4+
e (__indirect_function_table)
5+
f (_emscripten_stack_alloc)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a.a
1+
a (emscripten_resize_heap)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a
1+
a (emscripten_resize_heap)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (add)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (add)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (add)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (add)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
a
2-
b
3-
c
1+
a (memory)
2+
b (add)
3+
c (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a
2-
b
3-
c
4-
d
1+
a (memory)
2+
b (__wasm_call_ctors)
3+
c (add)
4+
d (__indirect_function_table)
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
A
2-
B
3-
C
4-
D
5-
E
6-
F
7-
p
8-
q
9-
r
10-
s
11-
t
12-
u
13-
v
14-
w
15-
x
16-
y
17-
z
1+
A (_emscripten_thread_exit)
2+
B (_emscripten_check_mailbox)
3+
C (emscripten_stack_set_limits)
4+
D (_emscripten_stack_restore)
5+
E (_emscripten_stack_alloc)
6+
F (emscripten_stack_get_current)
7+
p (__wasm_call_ctors)
8+
q (add)
9+
r (main)
10+
s (__indirect_function_table)
11+
t (_emscripten_tls_init)
12+
u (pthread_self)
13+
v (_emscripten_proxy_main)
14+
w (_emscripten_thread_init)
15+
x (_emscripten_thread_crashed)
16+
y (_emscripten_run_on_main_thread_js)
17+
z (_emscripten_thread_free_data)
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
a.a
2-
a.b
3-
a.c
4-
a.d
5-
a.e
6-
a.f
7-
a.g
8-
a.h
9-
a.i
10-
a.j
11-
a.k
12-
a.l
13-
a.m
14-
a.n
15-
a.o
1+
a (memory)
2+
b (emscripten_get_now)
3+
c (exit)
4+
d (_emscripten_thread_set_strongref)
5+
e (fd_write)
6+
f (emscripten_runtime_keepalive_check)
7+
g (emscripten_resize_heap)
8+
h (emscripten_exit_with_live_runtime)
9+
i (emscripten_check_blocking_allowed)
10+
j (_emscripten_thread_mailbox_await)
11+
k (_emscripten_thread_cleanup)
12+
l (_emscripten_receive_on_main_thread_js)
13+
m (_emscripten_notify_mailbox_postmessage)
14+
n (_emscripten_init_main_thread_js)
15+
o (__pthread_create_js)

0 commit comments

Comments
 (0)