Skip to content
Open
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
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ See docs/process.md for more on how version tagging works.
are now moved correctly into `-sLEGACY_GL_EMULATION` mode. In GLES and WebGL,
use the correct API functions `glClearDepthf()` and `glDepthRangef()` instead.
(#28379)
- The `--emrun` linker flag can again be used together with `-sEXIT_RUNTIME=0`,
which was made an error in 3.1.74. `--emrun` still enables `EXIT_RUNTIME` by
default, but if it is explicitly disabled, the runtime is now kept alive
after `main()` returns. `emrun` then captures `stdout` and `stderr` as
before, but the page does not report an exit code to it. (#28407)

7.0.1 - 11/21/26
----------------
Expand Down
7 changes: 5 additions & 2 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,11 @@ Options that are modified or new in *emcc* are listed below:
[link] Enables the generated output to be aware of the emrun
command line tool. This allows "stdout", "stderr" and
"exit(returncode)" capture when running the generated application
through *emrun*. (This enables *EXIT_RUNTIME=1*, allowing normal
runtime exiting with return code passing.)
through *emrun*. (This enables *EXIT_RUNTIME=1* by default,
allowing normal runtime exiting with return code passing. If
"-sEXIT_RUNTIME=0" is passed explicitly, "stdout" and "stderr" are
still captured, but the application does not report an exit code to
*emrun*.)

"--cpuprofiler"
[link] Embeds a simple CPU profiler onto the generated page. Use
Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Options that are modified or new in *emcc* are listed below:

``--emrun``
[link]
Enables the generated output to be aware of the :ref:`emrun <Running-html-files-with-emrun>` command line tool. This allows ``stdout``, ``stderr`` and ``exit(returncode)`` capture when running the generated application through *emrun*. (This enables `EXIT_RUNTIME=1`, allowing normal runtime exiting with return code passing.)
Enables the generated output to be aware of the :ref:`emrun <Running-html-files-with-emrun>` command line tool. This allows ``stdout``, ``stderr`` and ``exit(returncode)`` capture when running the generated application through *emrun*. (This enables `EXIT_RUNTIME=1` by default, allowing normal runtime exiting with return code passing. If ``-sEXIT_RUNTIME=0`` is passed explicitly, ``stdout`` and ``stderr`` are still captured, but the application does not report an exit code to *emrun*.)

``--cpuprofiler``
[link]
Expand Down
12 changes: 12 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -5042,6 +5042,18 @@ def test(cxx, no_exit, assertions, flush=0, keepalive=0, filesystem=1):
def test_no_exit_runtime_strict(self):
self.do_other_test('test_no_exit_runtime_strict.c', cflags=['-sSTRICT'])

@parameterized({
'': ([], True),
'exit_runtime': (['-sEXIT_RUNTIME'], True),
'no_exit_runtime': (['-sEXIT_RUNTIME=0'], False),
})
def test_emrun_exit_runtime(self, args, expect_exit):
# --emrun enables EXIT_RUNTIME by default, so that the page can report its
# exit code to emrun, but EXIT_RUNTIME can still be explicitly disabled.
self.run_process([EMCC, test_file('core/test_atexit.c'), '--emrun'] + args)
output = self.run_js('a.out.js')
self.assertContainedIf('B\nA\n', output, expect_exit)

def test_extra_opt_levels(self):
# Opt levels that we don't tend to test elsewhere
for opt in ('-Og', '-Ofast'):
Expand Down
7 changes: 3 additions & 4 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,9 @@ def phase_linker_setup(linker_args): # ruff: ignore[complex-structure, too-many
options.post_js.append(utils.path_from_root('src/emrun_postjs.js'))
if settings.MINIMAL_RUNTIME:
exit_with_error('--emrun is not compatible with MINIMAL_RUNTIME')
# emrun mode waits on program exit
if user_settings.get('EXIT_RUNTIME') == '0':
exit_with_error('--emrun is not compatible with EXIT_RUNTIME=0')
settings.EXIT_RUNTIME = 1
# emrun mode waits on program exit, unless the user explicitly disabled
# EXIT_RUNTIME. In that case the page does not report an exit code to emrun.
default_setting('EXIT_RUNTIME', 1)
# emrun_postjs.js needs this library function.
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$addOnExit']

Expand Down
Loading