Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,3 @@ workflows:
- test-upstream-browser-firefox:
requires:
- build-upstream

3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ See docs/process.md for how version tagging works.
Current Trunk
-------------

- LLVM backend pthread builds no longer use external memory initialization
files, replacing them with passive data segments.

v1.38.39: 07/16/2019
--------------------
- Add support for [address sanitizer](https://clang.llvm.org/docs/AddressSanitizer.html). (#8884)
Expand Down
17 changes: 9 additions & 8 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,16 +1438,17 @@ def check(input_file):
if any(s.startswith('MEM_INIT_METHOD=') for s in settings_changes):
exit_with_error('MEM_INIT_METHOD is not supported in wasm. Memory will be embedded in the wasm binary if threads are not used, and included in a separate file if threads are used.')
if shared.Settings.WASM2JS:
# in wasm2js, keep the mem init in the wasm itself if we can (no pthreads), and if the options
# wouldn't tell a js build to use a separate mem init file
shared.Settings.MEM_INIT_IN_WASM = not shared.Settings.USE_PTHREADS and not options.memory_init_file
# wasm2js does not support passive segments or atomics
if shared.Settings.USE_PTHREADS:
exit_with_error('WASM2JS does not yet support pthreads')
# in wasm2js, keep the mem init in the wasm itself if we can and if the
# options wouldn't tell a js build to use a separate mem init file
shared.Settings.MEM_INIT_IN_WASM = not options.memory_init_file
else:
# wasm normally includes the mem init in the wasm binary. exceptions are pthreads, where we need
# to split it out until we have full bulk memory support, and wasm2js, which behaves more like js.
# wasm includes the mem init in the wasm binary. The exception is
# wasm2js, which behaves more like js.
options.memory_init_file = True
# we will include the mem init data in the wasm, when we don't need the
# mem init file to be loadable by itself
shared.Settings.MEM_INIT_IN_WASM = not shared.Settings.USE_PTHREADS
shared.Settings.MEM_INIT_IN_WASM = True if shared.Settings.WASM_BACKEND else not shared.Settings.USE_PTHREADS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still confusing. I guess it will get simpler once fastcomp is gone, but why should options.memory_init_file not be the inverse of shared.Settings.MEM_INIT_IN_WASM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great question and I don’t know the answer. @kripken did tell me it was complicated, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to simplify this but ran into fastcomp issues with how those are used (in bad ways). it seems more efficient to defer a cleanup til after fastcomp is removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM. This logic was confusing when I first added wasm backend support originally and I made it even worse then.


# WASM_ASYNC_COMPILATION and SWAPPABLE_ASM_MODULE do not have a meaning in MINIMAL_RUNTIME (always async)
if not shared.Settings.MINIMAL_RUNTIME:
Expand Down
1 change: 1 addition & 0 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,7 @@ def link_lld(args, target, opts=[], lto_level=0):

if Settings.USE_PTHREADS:
cmd.append('--shared-memory')
cmd.append('--passive-segments')

for a in Building.llvm_backend_args():
cmd += ['-mllvm', a]
Expand Down