You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

64 lines
2.1 KiB

==================================
Status of Emscripten compatibility
==================================
Hello world test
================
Quick hello world test::
$ ./emcc -s USE_TYPED_ARRAYS=0 \
tests/hello_world.cpp -o /tmp/duk-emcc-test.js
Options needed:
* ``-s USE_TYPED_ARRAYS=0``: needed because Duktape does not yet support
Javascript typed arrays. Without this the Emscripten won't be able to
create an array for simulating memory. Note that without typed arrays,
Emscripten code will run very slow and be very memory inefficient.
Normally this suffices. If you're running Duktape with a small amount of
memory (e.g. when running the Duktape command line tool with the ``-r``
option) you may need to reduce Emscription "virtual memory" size with the
following additional options:
* ``-s TOTAL_MEMORY=2097152``: reduce total memory size to avoid running
out of memory.
* ``-s TOTAL_STACK=524288``: reduce total stack size to fit it into the
reduced memory size.
Trying to run the result, there is an error caused by an invalid RegExp::
$ ./duk /tmp/duk-emcc-test.js
SyntaxError: invalid regexp quantifier (unknown char) (line 181)
duk_lexer.c:1444
This is caused by::
if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
The fix is to escape the braces::
if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
After this the program works::
$ ./duk /tmp/duk-emcc-test.js
hello, world!
Full diff for the fix needed::
--- /tmp/duk-emcc-test.js 2014-01-26 00:28:30.180090902 +0200
+++ /tmp/duk-emcc-test-fixed.js 2014-01-26 00:22:35.932085587 +0200
@@ -178,7 +178,7 @@
isStructType: function isStructType(type) {
if (isPointerType(type)) return false;
if (isArrayType(type)) return true;
- if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
+ if (/<?\{ ?[^}]* ?\}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
// See comment in isStructPointerType()
return type[0] == '%';
},
This diff has been incorporated into ``fix_emscripten.py``.