Skip to content

Commit 7517158

Browse files
authored
Enable stdio flushing warning even with NO_FILESYSTEM (Followup to 16130) (#16143)
1 parent 93bc9fd commit 7517158

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

emcc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,14 +1984,13 @@ def default_setting(name, new_default):
19841984
'$handleException'
19851985
]
19861986

1987-
if settings.FILESYSTEM and not settings.STANDALONE_WASM:
1987+
if not settings.STANDALONE_WASM and (settings.EXIT_RUNTIME or settings.ASSERTIONS):
19881988
# We use __stdio_exit to shut down musl's stdio subsystems and flush
19891989
# streams on exit.
19901990
# We only include it if the runtime is exitable, or when ASSERTIONS
19911991
# (ASSERTIONS will check that streams do not need to be flushed,
19921992
# helping people see when they should have enabled EXIT_RUNTIME)
1993-
if settings.EXIT_RUNTIME or settings.ASSERTIONS:
1994-
settings.EXPORT_IF_DEFINED += ['__stdio_exit']
1993+
settings.EXPORT_IF_DEFINED += ['__stdio_exit']
19951994

19961995
if settings.SUPPORT_ERRNO:
19971996
# so setErrNo JS library function can report errno back to C

tests/test_other.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,18 +3607,19 @@ def test_no_exit_runtime_warnings_flush(self):
36073607
''')
36083608
warning = 'stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1'
36093609

3610-
def test(cxx, no_exit, assertions, flush, keepalive):
3610+
def test(cxx, no_exit, assertions, flush=0, keepalive=0, filesystem=1):
36113611
if cxx:
36123612
cmd = [EMXX, 'code.cpp']
36133613
else:
36143614
cmd = [EMCC, 'code.c']
3615-
# TODO: also check FILESYSTEM=0 here. it never worked though, buffered output was not emitted at shutdown
3616-
print('%s: no_exit=%d assertions=%d flush=%d keepalive=%d' % (cmd[1], no_exit, assertions, flush, keepalive))
3615+
print('%s: no_exit=%d assertions=%d flush=%d keepalive=%d filesystem=%d' % (cmd[1], no_exit, assertions, flush, keepalive, filesystem))
36173616
cmd += ['-sEXIT_RUNTIME=%d' % (1 - no_exit), '-sASSERTIONS=%d' % assertions]
36183617
if flush:
36193618
cmd += ['-DFLUSH']
36203619
if keepalive:
36213620
cmd += ['-DKEEPALIVE']
3621+
if not filesystem:
3622+
cmd += ['-sNO_FILESYSTEM']
36223623
self.run_process(cmd)
36233624
output = self.run_js('a.out.js')
36243625
exit = 1 - no_exit
@@ -3628,13 +3629,14 @@ def test(cxx, no_exit, assertions, flush, keepalive):
36283629

36293630
# Run just one test with KEEPALIVE set. In this case we don't expect to see any kind
36303631
# of warning becasue we are explictly requesting the runtime stay alive for later use.
3631-
test(cxx=0, no_exit=1, assertions=1, flush=0, keepalive=1)
3632+
test(cxx=0, no_exit=1, assertions=1, keepalive=1)
3633+
test(cxx=0, no_exit=1, assertions=1, filesystem=0)
36323634

36333635
for cxx in [0, 1]:
36343636
for no_exit in [0, 1]:
36353637
for assertions in [0, 1]:
36363638
for flush in [0, 1]:
3637-
test(cxx, no_exit, assertions, flush, 0)
3639+
test(cxx, no_exit, assertions, flush)
36383640

36393641
def test_fs_after_main(self):
36403642
for args in [[], ['-O1']]:

0 commit comments

Comments
 (0)