cee-dee / emscripten-tests Goto Github PK
View Code? Open in Web Editor NEWContains test-cases on the emscripten framework.
Contains test-cases on the emscripten framework.
Within directory embind-test-01, compile with
emcc --bind -o test.js test.cpp
and open up test.html within Firefox-browser. Then, within the console you see "11" and "hello".
Then, compile with
emcc --bind -o test.js test.cpp -O2
and open up test.html within Firefox-browser. Then, within the console you see "TypeError: Module.MyClass is not a constructor"
I'm using the portable SDK. "./emsdk list" gives:
The following individual tools exist:
clang-incoming-32bit
clang-incoming-64bit
clang-master-32bit
X clang-master-64bit INSTALLED
emscripten-1.29.0
emscripten-1.30.0
emscripten-incoming-32bit
emscripten-master-32bit
emscripten-incoming-64bit
X emscripten-master-64bit INSTALLED
The following Emscripten SDK versions are available:
sdk-incoming-32bit
sdk-incoming-64bit
sdk-master-32bit
X sdk-master-64bit INSTALLED
Items marked with * are activated for the current user.
Any ideas why this is happening?
Follow the build-instructions in emscripten-tests/libjpeg-01/README.txt. The resulting JavaScript will be of a size of about 4 MB, because it is built using -O0, without using the closure-compiler.
For increasing execution-speed and for reducing the size, I'd like to compile with at least -O2, better with -Oz.
So far I've found no way to this. It tried just calling emcc with -O2/-Oz instead of -O0. I additionally tried to compile libjpeg with emmake make -e CPPFLAGS=-Oz, before compiling with emcc -Oz, but that did not work either. I get exceptions like this all the time:
uncaught exception: abort(0) at jsStackTrace@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:1:21746
stackTrace@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:1:21929
abort@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:15:35454
nullFunc_vii@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:1:192767
im@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:8:33536
he@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:29651
$d@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:11423
Qd@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:4413
Pd@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:3870
ud@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:868
Id@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:5:2636
pl@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js:8:31500
dynCall_viiii_5@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js line 1 > Function:2:12
DecodeImage$initialize@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/DecodeImage.js line 1 > Function:8:1
processJpgArray@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/loadJpgs.html:28:9
loadJpgFile/fileReader.onload@file:///home/user/emscripten/jpeg-components/ipl-wrapper/emscripten-tests/libjpeg-01/src/loadJpgs.html:99:11
"Invalid function pointer '0' called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)" DecodeImage.js:1:2539
"This pointer might make sense in another type signature: vi: 0 viii: 0 v: 0 viiii: 0 viiiii: 0 viiiiii: 0 viiiiiii: 0 ii: 0 iii: 0 i: 0 iiii: 0 iiiii: 0 iiiiii: 0 iiiiiii: 0 " DecodeImage.js:1:2539
0 DecodeImage.js:1:2460
#0
Any ideas how to fix this?
Work within the directory webidl-test-01. First, create the glue-code:
python tools/webidl_binder.py test.idl glue
Then compile:
emcc test.cpp my_glue_wrapper.cpp --post-js glue.js -o test.js -Oz
Open test.html in Firefox-browser, you'll see "11" in the console, which is the expected output.
Then, compile with
emcc test.cpp my_glue_wrapper.cpp --post-js glue.js -o test.js -Oz --closure 1
Open test.html in Firefox-browser, you'll see "ReferenceError: Module is not defined".
I'm using the portable SDK. "./emsdk list" gives:
The following individual tools exist:
clang-incoming-32bit
clang-incoming-64bit
clang-master-32bit
X clang-master-64bit INSTALLED
emscripten-1.29.0
emscripten-1.30.0
emscripten-incoming-32bit
emscripten-master-32bit
emscripten-incoming-64bit
X emscripten-master-64bit INSTALLED
The following Emscripten SDK versions are available:
sdk-incoming-32bit
sdk-incoming-64bit
sdk-master-32bit
X sdk-master-64bit INSTALLED
Items marked with * are activated for the current user.
Well, the workflow is a bit more complicated than with embind-test-01, but at least compiler-optimization can be enabled. But unfortunately, using the closure-compiler for further reduction of size, does not work.
Any ideas why this is happening?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.