Giter VIP home page Giter VIP logo

emscripten-tests's People

Contributors

cee-dee avatar

Watchers

 avatar

emscripten-tests's Issues

embind-test-01: when compiling with -O2 referencing C++ classes/methods from JavaScript does not work anymore

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?

libjpeg-01: Compilation with anything beyond -O0 results in unusable JavaScript code

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?

webidl-test-01: when compiling with -Oz --closure 1 referencing C++ classes/methods from JavaScript does not work anymore

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.