Skip to content

Commit fe52d9b

Browse files
authored
Only run --no-exit-runtime when optimizing (#11998)
That pass is a pure optimization: it removes calls to atexit when they would be ignored anyhow (EXIT_RUNTIME == 0). This removes a warning in atexit's implementation that was never actually called before: we used to always run that pass, so if EXIT_RUNTIME == 0 then we never had any calls to atexit anyhow. Now that we only run the pass when optimizing, leaving that warning would be a noticeable change (and it broke some tests actually!) so just remove it. With that, this is essentially NFC except that non-optimized builds may be a little larger (containing calls to atexit that end up doing nothing). Helps WebAssembly/binaryen#3043
1 parent 2461a6e commit fe52d9b

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def backend_binaryen_passes():
589589
if shared.Settings.SAFE_HEAP:
590590
passes += ['--safe-heap']
591591
passes += ['--post-emscripten']
592-
if not shared.Settings.EXIT_RUNTIME:
592+
if shared.Settings.OPT_LEVEL > 0 and not shared.Settings.EXIT_RUNTIME:
593593
passes += ['--no-exit-runtime']
594594
if shared.Settings.OPT_LEVEL > 0 or shared.Settings.SHRINK_LEVEL > 0:
595595
passes += [building.opt_level_to_str(shared.Settings.OPT_LEVEL, shared.Settings.SHRINK_LEVEL)]

src/library.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,6 @@ LibraryManager.library = {
709709
atexit__proxy: 'sync',
710710
atexit__sig: 'iii',
711711
atexit: function(func, arg) {
712-
#if ASSERTIONS
713-
#if EXIT_RUNTIME == 0
714-
warnOnce('atexit() called, but EXIT_RUNTIME is not set, so atexits() will not be called. set EXIT_RUNTIME to 1 (see the FAQ)');
715-
#endif
716-
#endif
717-
718712
#if EXIT_RUNTIME
719713
__ATEXIT__.unshift({ func: func, arg: arg });
720714
#endif

0 commit comments

Comments
 (0)