-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emrun-related JS code is broken #23685
Comments
Managed to fix it locally by patching the link tool: diff --git a/tools/link.py b/tools/link.py
index 9440e8908..2e82c0cf4 100644
--- a/tools/link.py
+++ b/tools/link.py
@@ -674,6 +674,8 @@ def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
if user_settings.get('EXIT_RUNTIME') == '0':
exit_with_error('--emrun is not compatible with EXIT_RUNTIME=0')
settings.EXIT_RUNTIME = 1
+ # emrun_postjs.js needs this library function.
+ settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$addOnExit']
if options.cpu_profiler:
options.post_js.append(utils.path_from_root('src/cpuprofiler.js')) |
Thanks so much the fix! Would you like to send a PR. I'll take a look at why that doesn't seem to be covered by our test. |
Sure thing, I'll prepare a PR a bit later. |
Related to #23685 This change fixes the runtime error which causes emrun to be unable to get output from a browser.
Bump. I also get this same error in v4.0.4 of Emscripten with a simple main.cpp:
|
Are you using If not can you see where the undefined reference to |
I believe this specific issue was closes by #23830 |
Yes, I have I searched here and then compared it to my grep locally: $ grep --exclude-dir=.git --exclude-dir=cache -ir 'addOnExit'
upstream/emscripten/test/test_other.py: '-sEXPORTED_RUNTIME_METHODS=baz,addOnExit',
upstream/emscripten/test/test_other.py: import init, { _foo as foo, _bar as bar, baz, qux, addOnExit, HEAP32 } from "./modularize_instance.mjs";
upstream/emscripten/test/test_other.py: assert(typeof addOnExit === 'function'); // exported runtime function with EXPORTED_RUNTIME_METHODS
upstream/emscripten/test/test_other.py:addOnExit(() => console.log("addOnExit"));
upstream/emscripten/test/test_other.py: ['addOnExit', True],
upstream/emscripten/test/test_other.py: '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$addOnPreRun,$addOnInit,$addOnPostCtor,$addOnPreMain,$addOnExit,$addOnPostRun',
upstream/emscripten/src/threadprofiler.js: addOnExit(() => clearInterval(i));
upstream/emscripten/src/threadprofiler.js: addOnExit(() => clearInterval(i));
upstream/emscripten/src/lib/libglut.js: glutInit__deps: ['$Browser', '$addOnExit'],
upstream/emscripten/src/lib/libglut.js: addOnExit(() => {
upstream/emscripten/src/lib/libhtml5.js: '$addOnExit',
upstream/emscripten/src/lib/libhtml5.js: addOnExit(JSEvents.removeAllEventListeners);
upstream/emscripten/src/lib/libcore.js: $addOnExit__deps: ['$onExits'],
upstream/emscripten/src/lib/libcore.js: $addOnExit: (cb) => onExits.unshift(cb),
upstream/emscripten/src/emrun_postjs.js: addOnExit(() => {
upstream/emscripten/tools/link.py: settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$addOnInit', '$addOnExit']
upstream/emscripten/ChangeLog.md: addOnPreRun, addOnInit, addOnPreMain, addOnExit, addOnPostRun, After comparing the two, I found that My
I did grep again and still not in Anyway, I manually edited |
If you want to try out as-yet-unreleased changes you need to |
Okay, but using |
If you want to try changes out that have not yet made it into a release you can use |
emrun cannot get output from a browser (tested for Firefox 135 and Chromium 133) for the apps compiled with emsdk v4.0.3 and v4.0.4:
For the apps compiled with emsdk v4.0.2, emrun works successfully:
Seems like it's caused by calling a non-existing
addOnExit
function from src/emrun_postjs.js. The function was moved in a series of commits:13947f4 Unify more of the minimal runtime and normal runtime initialization code. (#23488)
a4f64a3 Move all addOn functions into a JS library. (#23565)
Version of emscripten/emsdk:
Failing command line in full:
emcc -s ENVIRONMENT=web --emrun main.cpp -o main.html && emrun --verbose main.html
main.cpp:
Update 1: added info about v4.0.4.
Update 2: added info about the
addOnExit
function.Update 3: updated the title.
The text was updated successfully, but these errors were encountered: