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
6 changes: 6 additions & 0 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3693,11 +3693,17 @@ def test_pthread_gcc_spinlock(self):
'': ([],),
'O3': (['-O3'],),
'minimal_runtime': (['-sMINIMAL_RUNTIME'],),
'single_file': (['-sSINGLE_FILE'],),
})
def test_pthread_create(self, args):
self.btest_exit('pthread/test_pthread_create.c',
args=['-pthread', '-sPTHREAD_POOL_SIZE=8'] + args,
extra_tries=0) # this should be 100% deterministic
files = os.listdir('.')
if '-sSINGLE_FILE' in args:
self.assertEqual(len(files), 1, files)
else:
self.assertEqual(len(files), 4, files)

# Test that preallocating worker threads work.
def test_pthread_preallocates_workers(self):
Expand Down
30 changes: 20 additions & 10 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ def phase_final_emitting(options, state, target, wasm_target):
return

target_dir = os.path.dirname(os.path.abspath(target))
if settings.PTHREADS and not settings.STRICT:
if settings.PTHREADS and not settings.STRICT and not settings.SINGLE_FILE:
worker_file = shared.replace_suffix(target, get_worker_js_suffix())
write_file(worker_file, '''\
// This file is no longer used by emscripten and has been created as a placeholder
Expand Down Expand Up @@ -2535,14 +2535,19 @@ def generate_traditional_runtime_html(target, options, js_target, target_basenam
# Normal code generation path
script.src = base_js_target

# inline script for SINGLE_FILE output
if settings.SINGLE_FILE:
js_contents = script.inline or ''
if script.src:
js_contents += read_file(js_target)
# In SINGLE_FILE mode we either inline the script, or in the case
# of SHARED_MEMORY convert the entire thing into a data URL.
if settings.SHARED_MEMORY:
assert not script.inline
script.src = get_subresource_location(js_target)
else:
js_contents = script.inline or ''
if script.src:
js_contents += read_file(js_target)
script.src = None
script.inline = read_file(js_target)
delete_file(js_target)
script.src = None
script.inline = js_contents
else:
if not settings.WASM_ASYNC_COMPILATION:
# We need to load the wasm file before anything else, since it
Expand Down Expand Up @@ -2819,16 +2824,21 @@ def replacement(self):
"""Returns the script tag to replace the {{{ SCRIPT }}} tag in the target"""
assert (self.src or self.inline) and not (self.src and self.inline)
if self.src:
quoted_src = quote(self.src)
src = self.src
if src.startswith('data:'):
filename = src
else:
src = quote(self.src)
filename = f'./{src}'
if settings.EXPORT_ES6:
return f'''
<script type="module">
import initModule from "./{quoted_src}";
import initModule from "{filename}";
initModule(Module);
</script>
'''
else:
return f'<script async type="text/javascript" src="{quoted_src}"></script>'
return f'<script async type="text/javascript" src="{src}"></script>'
else:
return '<script>\n%s\n</script>' % self.inline

Expand Down
Loading