Uncaught ReferenceError: __setjmp is not defined ??

104 views
Skip to first unread message

Steffen Köhler

unread,
Jan 1, 2015, 11:43:30 AM1/1/15
to emscripte...@googlegroups.com

Hi

When compiling with

emcc -o luac.js luac.o print.o liblua.a

wrap it with
emcc -o luac.html luac.o print.o liblua.a

and run it in Chrome 39,

it comes up with

Uncaught ReferenceError: __setjmp is not defined

which is true, at least I can find only the call in the generated code, but not a declaration of __setjmp().

What I'm doing wrong?

Many thanks in advance & a happy new year :-)

Steffen

Steffen Köhler

unread,
Jan 2, 2015, 9:00:28 AM1/2/15
to emscripte...@googlegroups.com
Update:
In the meantime I discovered that the Ubuntu package still contained an older emscripten version, so I removed and manually installed the latest SDK (1.28). Also I removed all optimizations from my Makefile and made sure that really the fastcomp compiler is used, but nevertheless I get a compilation warning

emcc -O0 -Wall -DLUA_USE_POSIX  -o luac.js  luac.o print.o liblua.a
warning: unresolved symbol: _longjmp
warning: unresolved symbol: _setjmp

and a crash when try to test it in nodejs

nodejs luac.js dummy.luamissing function: _setjmp
-1
-1

/media/ram/lua_c/lua-5.1.5/src/luac.js:84
      throw ex;
            ^
abort() at Error
    at jsStackTrace (/media/ram/lua_c/lua-5.1.5/src/luac.js:987:13)
    at stackTrace (/media/ram/lua_c/lua-5.1.5/src/luac.js:1004:22)
    at abort (/media/ram/lua_c/lua-5.1.5/src/luac.js:49798:25)
    at __setjmp (/media/ram/lua_c/lua-5.1.5/src/luac.js:6215:52)
    at _luaD_rawrunprotected (/media/ram/lua_c/lua-5.1.5/src/luac.js:10970:9)
    at _lua_newstate (/media/ram/lua_c/lua-5.1.5/src/luac.js:22045:10)
    at _luaL_newstate (/media/ram/lua_c/lua-5.1.5/src/luac.js:30546:8)
    at _main (/media/ram/lua_c/lua-5.1.5/src/luac.js:6631:9)
    at Object.asm._main (/media/ram/lua_c/lua-5.1.5/src/luac.js:47916:19)
    at Object.callMain (/media/ram/lua_c/lua-5.1.5/src/luac.js:49674:30)

The program I try to compile is just a command line tool, it's the well known Lua (5.1), but not the interpreter, it's the compiler (luac) instead. I've also seen the Lua example and wonder why the interpreter is working smoothly while the compiler fails, as they both probably have a very similar if not even the same build progress. ?!?

Any idea is highly appreciated :-)

best regards

Steffen

Alon Zakai

unread,
Jan 2, 2015, 2:56:32 PM1/2/15
to emscripte...@googlegroups.com
Fastcomp should reduce setjmp to emscripten_setjmp, and so forth. What shows up in the console when you build with EMCC_DEBUG=1 in the env? (It should say if fastcomp is being used, etc.).

- Alon


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steffen Köhler

unread,
Jan 3, 2015, 4:33:16 AM1/3/15
to emscripte...@googlegroups.com
Hello Alon

thanks for your support! Here's the complete make process as log:

Skript gestartet auf Sa 03 Jan 2015 07:59:41 CET
steffen@steffen-Desktop: ~/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5: emmake make emcc
cd src && make emcc
make[1]: Betrete Verzeichnis '/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src'
make comp MYCFLAGS=-DLUA_USE_POSIX
make[2]: Betrete Verzeichnis '/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src'
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lapi.o lapi.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lcode.o lcode.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ldebug.o ldebug.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ldo.o ldo.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ldump.o ldump.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lfunc.o lfunc.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lgc.o lgc.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o llex.o llex.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lmem.o lmem.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lobject.o lobject.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lopcodes.o lopcodes.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lparser.o lparser.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lstate.o lstate.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lstring.o lstring.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ltable.o ltable.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ltm.o ltm.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lundump.o lundump.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lvm.o lvm.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lzio.o lzio.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lauxlib.o lauxlib.c
lauxlib.c:577:61: warning: while loop has empty body [-Wempty-body]
   while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ;
                                                           ^
lauxlib.c:577:61: note: put the semicolon on a separate line to silence this
      warning
1 warning generated.
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lbaselib.o lbaselib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ldblib.o ldblib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o liolib.o liolib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lmathlib.o lmathlib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o loslib.o loslib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o ltablib.o ltablib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o lstrlib.o lstrlib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o loadlib.o loadlib.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o linit.o linit.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o # DLL needs all object files
ranlib liblua.a
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o luac.o luac.c
emcc -O2 -Wall -DLUA_USE_POSIX   -c -o print.o print.c
emcc -o luac  luac.o print.o liblua.a 
make[2]: Verlasse Verzeichnis '/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src'
make[1]: Verlasse Verzeichnis '/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src'
steffen@steffen-Desktop:~/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5$ cd src/
steffen@steffen-Desktop:~/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src$ EMCC_DEBUG=1 emcc -O2 -Wall -DLUA_USE_POSIX  -o luac.js  luac.o  print.o liblua.a
DEBUG    root: PYTHON not defined in ~/.emscripten, using "/usr/bin/python2"
DEBUG    root: JAVA not defined in ~/.emscripten, using "java"
WARNING  root: invocation: /home/steffen/bin/emsdk_portable/emscripten/master/emcc -O2 -Wall -DLUA_USE_POSIX -o luac.js luac.o print.o liblua.a  (in /home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src)
INFO     root: (Emscripten: Running sanity checks)
DEBUG    root: compiling to bitcode
DEBUG    root: emcc step "parse arguments and setup" took 0.00 seconds
DEBUG    root: using bitcode file: luac.o
DEBUG    root: using bitcode file: print.o
DEBUG    root: using library file: liblua.a
DEBUG    root: emcc step "bitcodeize inputs" took 0.00 seconds
DEBUG    root: emcc step "process inputs" took 0.00 seconds
DEBUG    root: will generate JavaScript
DEBUG    root: including libcextra
DEBUG    root: including libc
DEBUG    root: emcc step "calculate system libraries" took 0.20 seconds
DEBUG    root: linking: ['luac.o', 'print.o', 'liblua.a', '/home/steffen/.emscripten_cache/libcextra.bc', '/home/steffen/.emscripten_cache/libc.bc']
DEBUG    root: adding object /home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/luac.o to link
DEBUG    root: adding object /home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/print.o to link
DEBUG    root: considering archive /home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/liblua.a
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lapi.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/ldebug.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/ldo.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/ldump.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lfunc.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lgc.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lmem.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lobject.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lopcodes.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lparser.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lstate.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lstring.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/ltable.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/ltm.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lundump.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lvm.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lzio.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lauxlib.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/lcode.o to link
DEBUG    root: adding object /tmp/emscripten_temp/ar_output_1150_0/llex.o to link
DEBUG    root: done running loop of archive /home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/liblua.a
DEBUG    root: adding object /home/steffen/.emscripten_cache/libcextra.bc to link
DEBUG    root: adding object /home/steffen/.emscripten_cache/libc.bc to link
DEBUG    root: emcc: llvm-linking: ['/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/luac.o', '/home/steffen/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src/print.o', '/tmp/emscripten_temp/ar_output_1150_0/lapi.o', '/tmp/emscripten_temp/ar_output_1150_0/ldebug.o', '/tmp/emscripten_temp/ar_output_1150_0/ldo.o', '/tmp/emscripten_temp/ar_output_1150_0/ldump.o', '/tmp/emscripten_temp/ar_output_1150_0/lfunc.o', '/tmp/emscripten_temp/ar_output_1150_0/lgc.o', '/tmp/emscripten_temp/ar_output_1150_0/lmem.o', '/tmp/emscripten_temp/ar_output_1150_0/lobject.o', '/tmp/emscripten_temp/ar_output_1150_0/lopcodes.o', '/tmp/emscripten_temp/ar_output_1150_0/lparser.o', '/tmp/emscripten_temp/ar_output_1150_0/lstate.o', '/tmp/emscripten_temp/ar_output_1150_0/lstring.o', '/tmp/emscripten_temp/ar_output_1150_0/ltable.o', '/tmp/emscripten_temp/ar_output_1150_0/ltm.o', '/tmp/emscripten_temp/ar_output_1150_0/lundump.o', '/tmp/emscripten_temp/ar_output_1150_0/lvm.o', '/tmp/emscripten_temp/ar_output_1150_0/lzio.o', '/tmp/emscripten_temp/ar_output_1150_0/lauxlib.o', '/tmp/emscripten_temp/ar_output_1150_0/lcode.o', '/tmp/emscripten_temp/ar_output_1150_0/llex.o', '/home/steffen/.emscripten_cache/libcextra.bc', '/home/steffen/.emscripten_cache/libc.bc'] to /tmp/tmpbK245A/luac.bc
DEBUG    root: emcc step "link" took 0.45 seconds
DEBUG    root: saving intermediate processing steps to /tmp/emscripten_temp
DEBUG    root: emcc: LLVM opts: -strip-debug -internalize -internalize-public-api-list=main,malloc,free,malloc,malloc,free,malloc,free,free -globaldce -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt -disable-vectorize
DEBUG    root: emcc step "post-link" took 0.17 seconds
DEBUG    root: LLVM => JS
DEBUG    root: PYTHON not defined in ~/.emscripten, using "/usr/bin/python2"
DEBUG    root: JAVA not defined in ~/.emscripten, using "java"
DEBUG    root: not building relooper to js, using it in c++ backend
DEBUG    root: emscript: llvm backend: /home/steffen/bin/emsdk_portable/clang/fastcomp/build_master_32/bin/llc /tmp/tmpbK245A/luac.bc -march=js -filetype=asm -o /tmp/emscripten_temp/tmpuaJTqS.4.js -O2 -emscripten-max-setjmps=20
DEBUG    root:   emscript: llvm backend took 0.341075897217 seconds
DEBUG    root: emscript: js compiler glue
warning: unresolved symbol: _longjmp
warning: unresolved symbol: _setjmp
DEBUG    root:   emscript: glue took 0.401837110519 seconds
DEBUG    root: asm text sizes[[1146387, 18251, 25], 801, 273, 2249, 0, 646, 574, 552, 234, 1571, 1018]
DEBUG    root:   emscript: final python processing took 0.0139589309692 seconds
DEBUG    root: emcc step "emscript (llvm=>js)" took 0.89 seconds
DEBUG    root: wrote memory initialization to luac.js.mem
DEBUG    root: emcc step "source transforms" took 0.02 seconds
DEBUG    root: running js post-opts
DEBUG    root: applying js optimization passes: ['asm', 'eliminate', 'simplifyExpressions', 'simplifyIfs', 'registerize', 'minifyNames', 'cleanup', 'asmLastOpts', 'last', 'minifyWhitespace']
chunkification: num funcs: 256 actual num chunks: 3 chunk size range: 470823 - 231185
splitting up js optimization into 3 chunks, using 3 cores  (total: 1.11 MB)
.
.
.
running cleanup on shell code
DEBUG    root: emcc step "js opts" took 2.21 seconds
DEBUG    root: emcc step "final emitting" took 0.01 seconds
DEBUG    root: total time: 3.95 seconds
steffen@steffen-Desktop: ~/Desktop/workcopies/oobd/trunk/tools/blockly/lua_compile/lua-5.1.5/src$ exit
exit

Skript beendet: Sa 03 Jan 2015 08:02:57 CET

Bruce Mitchener

unread,
Jan 3, 2015, 5:16:57 AM1/3/15
to emscripte...@googlegroups.com
Did you try just using setjmp rather than _setjmp?

Sent from my iPhone
--

Steffen Köhler

unread,
Jan 3, 2015, 5:22:12 AM1/3/15
to emscripte...@googlegroups.com


Am Samstag, 3. Januar 2015 11:16:57 UTC+1 schrieb Bruce Mitchener:
Did you try just using setjmp rather than _setjmp?

Hello Bruce

I've to admit that I've no clue where in the sources this command is used and how to change it.. - I'm  just a poor "end user" who wants to transfer the lua compiler functionality into a online web page to allow easy script generation for an embedded system. But how the lua compiler works by itself, I've no idea.... :-|


Steffen Köhler

unread,
Jan 3, 2015, 9:46:49 AM1/3/15
to emscripte...@googlegroups.com

Hi Bruce,
after thinking twice about it: Do you mean I should change the call in the generated js? I'll give it a trial next :-)

--
You received this message because you are subscribed to a topic in the Google Groups "emscripten-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/emscripten-discuss/5-0m2GZH6jw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to emscripten-disc...@googlegroups.com.

Bruce Mitchener

unread,
Jan 3, 2015, 9:55:58 AM1/3/15
to emscripte...@googlegroups.com
You can find it and change it in the C that you're compiling.

 - Bruce


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Steffen Köhler

unread,
Jan 3, 2015, 12:27:21 PM1/3/15
to emscripte...@googlegroups.com
Hello Bruce

originally I was worry if I'm able to find and fix in the sources, but finally I've made it :-)

The compilation is working now- many thanks for your support!

best regards

Steffen

Bruce Mitchener

unread,
Jan 3, 2015, 6:52:47 PM1/3/15
to emscripte...@googlegroups.com
I looked into this a bit when I got home and before sleeping...

The actual big that should be addressed is in emscripten. I will file a bug report or submit a pull request that fixes it.

I am glad that you have a workaround for now. :)

 - Bruce

Sent from my iPhone

Alon Zakai

unread,
Jan 5, 2015, 4:14:44 PM1/5/15
to emscripte...@googlegroups.com
Thanks, looking forward to seeing that, as I am still confused what's going on here :)

- Alon

Reply all
Reply to author
Forward
0 new messages