Skip to content

Commit a5dc19c

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 325291e + fdb1656 commit a5dc19c

Some content is hidden

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

57 files changed

+360
-176
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ See docs/process.md for more on how version tagging works.
2424
- Using `-Oz` or `-Os` will no longer pass `-fno-inline-functions` to clang and
2525
instead rely on clang's normal inline heuristics for these optimization
2626
levels. `-fno-inline-functions` can be passed explicitly if needed.
27+
- C++17 is now the default version of the C++ standard used by the compiler.
28+
This is due to an upstream change in llvm. Use `-std=c++14` (or technically
29+
`-std=gnu++14`) to revert to the previous default.
2730

2831
3.1.21 - 09/09/2022
2932
-------------------

embuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def main():
237237
if do_clear:
238238
library.erase()
239239
if do_build:
240-
library.get_path()
240+
library.build()
241241
elif what == 'sysroot':
242242
if do_clear:
243243
shared.Cache.erase_file('sysroot_install.stamp')

emcc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3165,6 +3165,8 @@ def consume_arg_file():
31653165
elif options.requested_level == 'z':
31663166
options.requested_level = 2
31673167
settings.SHRINK_LEVEL = 2
3168+
else:
3169+
settings.SHRINK_LEVEL = 0
31683170
settings.OPT_LEVEL = validate_arg_level(options.requested_level, 3, 'invalid optimization level: ' + arg, clamp=True)
31693171
elif check_arg('--js-opts'):
31703172
logger.warning('--js-opts ignored when using llvm backend')
@@ -3175,7 +3177,7 @@ def consume_arg_file():
31753177
if '=' in arg:
31763178
settings.LTO = arg.split('=')[1]
31773179
else:
3178-
settings.LTO = "full"
3180+
settings.LTO = 'full'
31793181
elif check_arg('--llvm-lto'):
31803182
logger.warning('--llvm-lto ignored when using llvm backend')
31813183
consume_arg()

emcmake.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# University of Illinois/NCSA Open Source License. Both these licenses can be
55
# found in the LICENSE file.
66

7+
import os
78
import sys
89
from tools import shared
910
from tools import config
@@ -30,7 +31,7 @@ def has_substr(args, substr):
3031
return any(substr in s for s in args)
3132

3233
# Append the Emscripten toolchain file if the user didn't specify one.
33-
if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE'):
34+
if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE') and 'CMAKE_TOOLCHAIN_FILE' not in os.environ:
3435
args.append('-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root('cmake/Modules/Platform/Emscripten.cmake'))
3536

3637
if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'):

emrun.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def serve_forever(self, timeout=0.5):
534534
while self.is_running:
535535
now = tick()
536536
# Did user close browser?
537-
if not emrun_options.no_browser and not is_browser_process_alive():
537+
if emrun_options.run_browser and not is_browser_process_alive():
538538
logv("Shutting down because browser is no longer alive")
539539
delete_emrun_safe_firefox_profile()
540540
if not emrun_options.serve_after_close:
@@ -1450,9 +1450,7 @@ def list_processes_by_name(exe_full_path):
14501450
return pids
14511451

14521452

1453-
def run():
1454-
global browser_process, browser_exe, processname_killed_atexit, emrun_options, emrun_not_enabled_nag_printed
1455-
usage_str = """\
1453+
usage_str = """\
14561454
emrun [emrun_options] filename.html -- [html_cmdline_options]
14571455
14581456
where emrun_options specifies command line options for emrun itself, whereas
@@ -1462,6 +1460,9 @@ def run():
14621460
arguments to your page, remember to add `--` between arguments
14631461
to emrun itself and arguments to your page.
14641462
"""
1463+
1464+
1465+
def parse_args():
14651466
parser = argparse.ArgumentParser(usage=usage_str)
14661467

14671468
parser.add_argument('--kill_start', action='store_true',
@@ -1475,11 +1476,13 @@ def run():
14751476
'--browser=/path/to/browser, to avoid emrun being '
14761477
'detached from the browser process it spawns.')
14771478

1478-
parser.add_argument('--no_server', action='store_true',
1479+
parser.add_argument('--no_server', dest='run_server', action='store_false',
1480+
default=True,
14791481
help='If specified, a HTTP web server is not launched '
14801482
'to host the page to run.')
14811483

1482-
parser.add_argument('--no_browser', action='store_true',
1484+
parser.add_argument('--no_browser', dest='run_browser', action='store_false',
1485+
default=True,
14831486
help='If specified, emrun will not launch a web browser '
14841487
'to run the page.')
14851488

@@ -1577,7 +1580,13 @@ def run():
15771580

15781581
parser.add_argument('cmdlineparams', nargs='*')
15791582

1580-
options = emrun_options = parser.parse_args()
1583+
return parser.parse_args()
1584+
1585+
1586+
def run():
1587+
global browser_process, browser_exe, processname_killed_atexit, emrun_options, emrun_not_enabled_nag_printed
1588+
1589+
options = emrun_options = parse_args()
15811590

15821591
if options.android:
15831592
global ADB
@@ -1605,9 +1614,9 @@ def run():
16051614

16061615
if not options.serve and (options.system_info or options.browser_info):
16071616
# Don't run if only --system_info or --browser_info was passed.
1608-
options.no_server = options.no_browser = True
1617+
options.run_server = options.run_browser = False
16091618

1610-
if not options.serve and not (options.no_server and options.no_browser):
1619+
if not options.serve and (options.run_server or options.run_browser):
16111620
logi(usage_str)
16121621
logi('')
16131622
logi('Type emrun --help for a detailed list of available options.')
@@ -1639,14 +1648,14 @@ def run():
16391648
url = 'http://' + hostname + ':' + str(options.port) + '/' + url
16401649

16411650
os.chdir(serve_dir)
1642-
if not options.no_server:
1643-
if options.no_browser:
1644-
logi('Web server root directory: ' + os.path.abspath('.'))
1645-
else:
1651+
if options.run_server:
1652+
if options.run_browser:
16461653
logv('Web server root directory: ' + os.path.abspath('.'))
1654+
else:
1655+
logi('Web server root directory: ' + os.path.abspath('.'))
16471656

16481657
if options.android:
1649-
if not options.no_browser or options.browser_info:
1658+
if options.run_browser or options.browser_info:
16501659
if not options.browser:
16511660
loge("Running on Android requires that you explicitly specify the browser to run with --browser <id>. Run emrun --android --list_browsers to obtain a list of installed browsers you can use.")
16521661
return 1
@@ -1691,7 +1700,7 @@ def run():
16911700
if options.browser:
16921701
options.browser = unwrap(options.browser)
16931702

1694-
if not options.no_browser or options.browser_info:
1703+
if options.run_browser or options.browser_info:
16951704
browser = find_browser(str(options.browser))
16961705
if not browser:
16971706
loge('Unable to find browser "' + str(options.browser) + '"! Check the correctness of the passed --browser=xxx parameter!')
@@ -1713,7 +1722,7 @@ def run():
17131722
browser_args += ['--enable-nacl', '--enable-pnacl', '--disable-restore-session-state', '--enable-webgl', '--no-default-browser-check', '--no-first-run', '--allow-file-access-from-files']
17141723
if options.private_browsing:
17151724
browser_args += ['--incognito']
1716-
# if options.no_server:
1725+
# if not options.run_server:
17171726
# browser_args += ['--disable-web-security']
17181727
elif 'firefox' in browser_exe.lower():
17191728
processname_killed_atexit = 'firefox'
@@ -1752,7 +1761,7 @@ def run(cmd):
17521761
# Create temporary Firefox profile to run the page with. This is important to
17531762
# run after kill_browser_process()/kill_start op above, since that cleans up
17541763
# the temporary profile if one exists.
1755-
if processname_killed_atexit == 'firefox' and options.safe_firefox_profile and not options.no_browser and not options.android:
1764+
if processname_killed_atexit == 'firefox' and options.safe_firefox_profile and options.run_browser and not options.android:
17561765
profile_dir = create_emrun_safe_firefox_profile()
17571766

17581767
browser += ['-no-remote', '--profile', profile_dir.replace('\\', '/')]
@@ -1784,21 +1793,22 @@ def run(cmd):
17841793
else:
17851794
browser_stderr_handle = open(options.log_stderr, 'a')
17861795

1787-
if not options.no_server:
1796+
if options.run_server:
17881797
logv('Starting web server: http://%s:%i/' % (options.hostname, options.port))
17891798
httpd = HTTPWebServer((options.hostname, options.port), HTTPHandler)
17901799

1791-
if not options.no_browser:
1800+
if options.run_browser:
17921801
logv("Starting browser: %s" % ' '.join(browser))
17931802
# if browser[0] == 'cmd':
17941803
# Workaround an issue where passing 'cmd /C start' is not able to detect
17951804
# when the user closes the page.
17961805
# serve_forever = True
1797-
global previous_browser_processes
1798-
logv(browser_exe)
1799-
previous_browser_processes = list_processes_by_name(browser_exe)
1800-
for p in previous_browser_processes:
1801-
logv('Before spawning web browser, found a running ' + os.path.basename(browser_exe) + ' browser process id: ' + str(p['pid']))
1806+
if browser_exe:
1807+
global previous_browser_processes
1808+
logv(browser_exe)
1809+
previous_browser_processes = list_processes_by_name(browser_exe)
1810+
for p in previous_browser_processes:
1811+
logv('Before spawning web browser, found a running ' + os.path.basename(browser_exe) + ' browser process id: ' + str(p['pid']))
18021812
browser_process = subprocess.Popen(browser, env=subprocess_env())
18031813
logv('Launched browser process with pid=' + str(browser_process.pid))
18041814
if options.kill_exit:
@@ -1807,7 +1817,7 @@ def run(cmd):
18071817
# represent a browser and no point killing it.
18081818
if options.android:
18091819
browser_process = None
1810-
elif not options.no_server:
1820+
elif options.run_server:
18111821
logi('Now listening at http://%s:%i/' % (options.hostname, options.port))
18121822

18131823
if browser_process:
@@ -1818,7 +1828,7 @@ def run(cmd):
18181828
if not options.browser:
18191829
logv('Try passing the --browser=/path/to/browser option to avoid this from occurring. See https://github.com/emscripten-core/emscripten/issues/3234 for more discussion.')
18201830

1821-
if not options.no_server:
1831+
if options.run_server:
18221832
try:
18231833
httpd.serve_forever()
18241834
except KeyboardInterrupt:
@@ -1827,7 +1837,7 @@ def run(cmd):
18271837

18281838
logv('Closed web server.')
18291839

1830-
if not options.no_browser:
1840+
if options.run_browser:
18311841
if options.kill_exit:
18321842
kill_browser_process()
18331843
else:

emscripten.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,8 @@ def emscript(in_wasm, out_wasm, outfile_js, memfile):
430430

431431
def remove_trailing_zeros(memfile):
432432
mem_data = utils.read_binary(memfile)
433-
end = len(mem_data)
434-
while end > 0 and (mem_data[end - 1] == b'\0' or mem_data[end - 1] == 0):
435-
end -= 1
436-
utils.write_binary(memfile, mem_data[:end])
433+
mem_data = mem_data.rstrip(b'\0')
434+
utils.write_binary(memfile, mem_data)
437435

438436

439437
@ToolchainProfiler.profile()

site/source/docs/api_reference/preamble.js.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Calling compiled C functions from JavaScript
9999
100100
.. note::
101101
- ``cwrap`` uses the C stack for temporary values. If you pass a string then it is only "alive" until the call is complete. If the code being called saves the pointer to be used later, it may point to invalid data. If you need a string to live forever, you can create it, for example, using ``_malloc`` and :js:func:`stringToUTF8`. However, you must later delete it manually!
102-
- LLVM optimizations can inline and remove functions, after which you will not be able to "wrap" them. Similarly, function names minified by the *Closure Compiler* are inaccessible. In either case, the solution is to add the functions to the ``EXPORTED_FUNCTIONS`` list when you invoke *emcc* :
102+
- To wrap a function it must be exported by adding it to the ``EXPORTED_FUNCTIONS`` list when you invoke *emcc*. If a function is not exported, optimizations may remove it, and ``cwrap`` will not be able to find it at runtime. (In builds with ``ASSERTIONS`` enabled, ``cwrap`` will show an error in such a situation; in release builds without assertions, trying to wrap a non-existent function will error, either by returning `undefined` or by returning a function that will error when actually called, depending on how ``cwrap`` optimizes.)
103103
- ``cwrap`` does not actually call compiled code (only calling the wrapper it returns does that). That means that it is safe to call ``cwrap`` early, before the runtime is fully initialized (but calling the returned wrapped function must wait for the runtime, of course, like calling compiled code in general).
104104

105105
.. code-block:: none

site/source/docs/porting/simd.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ The following table highlights the availability and expected performance of diff
557557
* - _mm_loadu_si16
558558
- ❌ emulated with const+scalar load+replace lane
559559
* - _mm_madd_epi16
560-
- ✅ wasm_dot_s_i32x4_i16x8
560+
- ✅ wasm_i32x4_dot_i16x8
561561
* - _mm_maskmoveu_si128
562562
- ❌ scalarized
563563
* - _mm_max_epi16

src/library_eventloop.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ LibraryJSEventLoop = {
7070
// emscripten_set_immediate_loop() if application links to both of them.
7171
},
7272

73+
emscripten_set_immediate__sig: 'ipp',
7374
emscripten_set_immediate__deps: ['$polyfillSetImmediate', '$callUserCallback'],
7475
emscripten_set_immediate: function(cb, userData) {
7576
polyfillSetImmediate();
@@ -82,12 +83,14 @@ LibraryJSEventLoop = {
8283
});
8384
},
8485

86+
emscripten_clear_immediate__sig: 'vi',
8587
emscripten_clear_immediate__deps: ['$polyfillSetImmediate'],
8688
emscripten_clear_immediate: function(id) {
8789
{{{ runtimeKeepalivePop(); }}}
8890
emClearImmediate(id);
8991
},
9092

93+
emscripten_set_immediate_loop__sig: 'vpp' ,
9194
emscripten_set_immediate_loop__deps: ['$polyfillSetImmediate', '$callUserCallback'],
9295
emscripten_set_immediate_loop: function(cb, userData) {
9396
polyfillSetImmediate();
@@ -104,6 +107,7 @@ LibraryJSEventLoop = {
104107
return emSetImmediate(tick);
105108
},
106109

110+
emscripten_set_timeout__sig: 'ipdp',
107111
emscripten_set_timeout__deps: ['$callUserCallback'],
108112
emscripten_set_timeout: function(cb, msecs, userData) {
109113
{{{ runtimeKeepalivePush() }}}
@@ -115,10 +119,12 @@ LibraryJSEventLoop = {
115119
}, msecs);
116120
},
117121

122+
emscripten_clear_timeout__sig: 'vi',
118123
emscripten_clear_timeout: function(id) {
119124
clearTimeout(id);
120125
},
121126

127+
emscripten_set_timeout_loop__sig: 'vpdp',
122128
emscripten_set_timeout_loop__deps: ['$callUserCallback'],
123129
emscripten_set_timeout_loop: function(cb, msecs, userData) {
124130
function tick() {
@@ -139,6 +145,7 @@ LibraryJSEventLoop = {
139145
return setTimeout(tick, 0);
140146
},
141147

148+
emscripten_set_interval__sig: 'ipdp',
142149
emscripten_set_interval__deps: ['$callUserCallback'],
143150
emscripten_set_interval: function(cb, msecs, userData) {
144151
{{{ runtimeKeepalivePush() }}}
@@ -149,6 +156,7 @@ LibraryJSEventLoop = {
149156
}, msecs);
150157
},
151158

159+
emscripten_clear_interval__sig: 'vi',
152160
emscripten_clear_interval: function(id) {
153161
{{{ runtimeKeepalivePop() }}}
154162
clearInterval(id);

src/library_syscall.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ var SyscallsLibrary = {
121121
#endif // SYSCALLS_REQUIRE_FILESYSTEM
122122
},
123123

124-
_mmap_js__sig: 'ppiiipp',
124+
_mmap_js__sig: 'ipiiippp',
125125
_mmap_js__deps: ['$SYSCALLS',
126126
#if FILESYSTEM && SYSCALLS_REQUIRE_FILESYSTEM
127127
'$FS',
128128
#endif
129129
],
130-
_mmap_js: function(len, prot, flags, fd, off, allocated) {
130+
_mmap_js: function(len, prot, flags, fd, off, allocated, addr) {
131131
#if FILESYSTEM && SYSCALLS_REQUIRE_FILESYSTEM
132132
var stream = SYSCALLS.getStreamFromFD(fd);
133133
var res = FS.mmap(stream, len, off, prot, flags);
@@ -136,7 +136,8 @@ var SyscallsLibrary = {
136136
#if CAN_ADDRESS_2GB
137137
ptr >>>= 0;
138138
#endif
139-
return ptr;
139+
{{{ makeSetValue('addr', 0, 'ptr', '*') }}};
140+
return 0;
140141
#else // no filesystem support; report lack of support
141142
return -{{{ cDefine('ENOSYS') }}};
142143
#endif

0 commit comments

Comments
 (0)