Skip to content

Commit

Permalink
Add new --emit-minification-map flag and use it in metadce tests (ems…
Browse files Browse the repository at this point in the history
…cripten-core#22428)

This greatly increases the utility of the output files for these tests.
  • Loading branch information
sbc100 authored Aug 21, 2024
1 parent 4ec07a2 commit 4182c11
Show file tree
Hide file tree
Showing 43 changed files with 218 additions and 174 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

3.1.65 (in development)
-----------------------
- A new `--emit-minification-map` command line flag was added, which can be used
to emit a minifiction map in the case that import/export minification is
performed (this happens at higher optimization levels). (#22428)
- Remove `Module['quit']` handling. This could be used to override the internal
method for shutting down the program, but it was neither documented nor
tested. Programs that want to intercept the shutting down of a program can
Expand Down
6 changes: 6 additions & 0 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ Options that are modified or new in *emcc* are listed below:
"[name].js.symbols" (with WASM symbols) and
"[name].wasm.js.symbols" (with ASM.js symbols)

"--emit-minification-map <file>"
[link] In cases where emscripten performs import/export minificiton
this option can be used to output a file that maps minified names
back to their original names. The format of this file is single
line per import/export of the form "<minname>:<origname>".

"-flto"
[compile+link] Enables link-time optimizations (LTO).

Expand Down
2 changes: 2 additions & 0 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,8 @@ def consume_arg_file():
elif check_flag('--emit-symbol-map'):
options.emit_symbol_map = True
settings.EMIT_SYMBOL_MAP = 1
elif check_arg('--emit-minification-map'):
settings.MINIFICATION_MAP = consume_arg()
elif check_arg('--embed-file'):
options.embed_files.append(consume_arg())
elif check_arg('--preload-file'):
Expand Down
9 changes: 9 additions & 0 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,15 @@ Options that are modified or new in *emcc* are listed below:

.. 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)

.. _emcc-emit-minification-map:

``--emit-minification-map <file>``
[link]
In cases where emscripten performs import/export minificiton this option can
be used to output a file that maps minified names back to their original
names. The format of this file is single line per import/export of the form
``<minname>:<origname>``.

.. _emcc-lto:

``-flto``
Expand Down
2 changes: 2 additions & 0 deletions src/settings_internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@ var WARN_DEPRECATED = true;
var WEBGL_USE_GARBAGE_FREE_APIS = false;

var INCLUDE_WEBGL1_FALLBACK = true;

var MINIFICATION_MAP = '';
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_files_js_fs.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
e
f
g
h
e (memory)
f (__wasm_call_ctors)
g (main)
h (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_files_js_fs.imports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a.a
a.b
a.c
a.d
a (fd_write)
b (fd_read)
c (fd_close)
d (__syscall_openat)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_files_js_fs.sent
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (fd_write)
b (fd_read)
c (fd_close)
d (__syscall_openat)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_files_wasmfs.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
q
r
s
t
q (memory)
r (__wasm_call_ctors)
s (main)
t (__indirect_function_table)
32 changes: 16 additions & 16 deletions test/other/metadce/test_metadce_files_wasmfs.imports
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
a.a
a.b
a.c
a.d
a.e
a.f
a.g
a.h
a.i
a.j
a.k
a.l
a.m
a.n
a.o
a.p
a (emscripten_date_now)
b (emscripten_err)
c (getentropy)
d (emscripten_resize_heap)
e (emscripten_out)
f (_wasmfs_stdin_get_char)
g (_wasmfs_get_preloaded_path_name)
h (_wasmfs_get_preloaded_parent_path)
i (_wasmfs_get_preloaded_file_size)
j (_wasmfs_get_preloaded_file_mode)
k (_wasmfs_get_preloaded_child_path)
l (_wasmfs_get_num_preloaded_files)
m (_wasmfs_get_num_preloaded_dirs)
n (_wasmfs_copy_preloaded_file_data)
o (_emscripten_memcpy_js)
p (_abort_js)
32 changes: 16 additions & 16 deletions test/other/metadce/test_metadce_files_wasmfs.sent
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
a (emscripten_date_now)
b (emscripten_err)
c (getentropy)
d (emscripten_resize_heap)
e (emscripten_out)
f (_wasmfs_stdin_get_char)
g (_wasmfs_get_preloaded_path_name)
h (_wasmfs_get_preloaded_parent_path)
i (_wasmfs_get_preloaded_file_size)
j (_wasmfs_get_preloaded_file_mode)
k (_wasmfs_get_preloaded_child_path)
l (_wasmfs_get_num_preloaded_files)
m (_wasmfs_get_num_preloaded_dirs)
n (_wasmfs_copy_preloaded_file_data)
o (_emscripten_memcpy_js)
p (_abort_js)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_hello_O3.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c
d
e
f
c (memory)
d (__wasm_call_ctors)
e (main)
f (__indirect_function_table)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_O3.imports
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a.a
a.b
a (fd_write)
b (_emscripten_memcpy_js)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_O3.sent
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a
b
a (fd_write)
b (_emscripten_memcpy_js)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_hello_Os.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c
d
e
f
c (memory)
d (__wasm_call_ctors)
e (main)
f (__indirect_function_table)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_Os.imports
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a.a
a.b
a (fd_write)
b (_emscripten_memcpy_js)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_Os.sent
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a
b
a (fd_write)
b (_emscripten_memcpy_js)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_hello_Oz.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
b
c
d
e
b (memory)
c (__wasm_call_ctors)
d (main)
e (__indirect_function_table)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Oz.imports
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a.a
a (fd_write)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_hello_Oz.sent
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a
a (fd_write)
6 changes: 3 additions & 3 deletions test/other/metadce/test_metadce_hello_export_nothing.exports
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
a
b
c
a (memory)
b (__wasm_call_ctors)
c (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_hello_wasmfs.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c
d
e
f
c (memory)
d (__wasm_call_ctors)
e (main)
f (__indirect_function_table)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_wasmfs.imports
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a.a
a.b
a (fd_write)
b (_emscripten_memcpy_js)
4 changes: 2 additions & 2 deletions test/other/metadce/test_metadce_hello_wasmfs.sent
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a
b
a (fd_write)
b (_emscripten_memcpy_js)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_libcxxabi_message_O3.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (main)
d (__indirect_function_table)
10 changes: 5 additions & 5 deletions test/other/metadce/test_metadce_mem_O3.exports
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
b
c
d
e
f
b (memory)
c (__wasm_call_ctors)
d (__main_argc_argv)
e (__indirect_function_table)
f (_emscripten_stack_alloc)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.imports
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a.a
a (emscripten_resize_heap)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3.sent
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a
a (emscripten_resize_heap)
10 changes: 5 additions & 5 deletions test/other/metadce/test_metadce_mem_O3_grow.exports
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
b
c
d
e
f
b (memory)
c (__wasm_call_ctors)
d (__main_argc_argv)
e (__indirect_function_table)
f (_emscripten_stack_alloc)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.imports
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a.a
a (emscripten_resize_heap)
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_mem_O3_grow.sent
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a
a (emscripten_resize_heap)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_minimal_64.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (add)
d (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_minimal_O3.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (add)
d (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_minimal_Os.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (add)
d (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_minimal_Os_mr.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (add)
d (__indirect_function_table)
6 changes: 3 additions & 3 deletions test/other/metadce/test_metadce_minimal_Oz-ctors.exports
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
a
b
c
a (memory)
b (add)
c (__indirect_function_table)
8 changes: 4 additions & 4 deletions test/other/metadce/test_metadce_minimal_Oz.exports
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
a
b
c
d
a (memory)
b (__wasm_call_ctors)
c (add)
d (__indirect_function_table)
34 changes: 17 additions & 17 deletions test/other/metadce/test_metadce_minimal_pthreads.exports
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
A
B
C
D
E
F
p
q
r
s
t
u
v
w
x
y
z
A (_emscripten_thread_exit)
B (_emscripten_check_mailbox)
C (emscripten_stack_set_limits)
D (_emscripten_stack_restore)
E (_emscripten_stack_alloc)
F (emscripten_stack_get_current)
p (__wasm_call_ctors)
q (add)
r (main)
s (__indirect_function_table)
t (_emscripten_tls_init)
u (pthread_self)
v (_emscripten_proxy_main)
w (_emscripten_thread_init)
x (_emscripten_thread_crashed)
y (_emscripten_run_on_main_thread_js)
z (_emscripten_thread_free_data)
30 changes: 15 additions & 15 deletions test/other/metadce/test_metadce_minimal_pthreads.imports
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
a.a
a.b
a.c
a.d
a.e
a.f
a.g
a.h
a.i
a.j
a.k
a.l
a.m
a.n
a.o
a (memory)
b (emscripten_get_now)
c (exit)
d (_emscripten_thread_set_strongref)
e (fd_write)
f (emscripten_runtime_keepalive_check)
g (emscripten_resize_heap)
h (emscripten_exit_with_live_runtime)
i (emscripten_check_blocking_allowed)
j (_emscripten_thread_mailbox_await)
k (_emscripten_thread_cleanup)
l (_emscripten_receive_on_main_thread_js)
m (_emscripten_notify_mailbox_postmessage)
n (_emscripten_init_main_thread_js)
o (__pthread_create_js)
Loading

0 comments on commit 4182c11

Please sign in to comment.