Using CLAPACK (Fortran-to-C autoconverted code) in emscripten?

125 views
Skip to first unread message

nickw

unread,
Jul 26, 2021, 9:50:26 AM7/26/21
to emscripten-discuss

Hi,

I am investigating using Emscripten to provide a web interface to an augmented reality system,. PTAM (https://www.robots.ox.ac.uk/~gk/PTAM/)

I have written a small test application which just initialises the library. At the link stage I get this error:

```
[ 50%] Linking CXX executable ptam_wasm.js
[parse exception: attempted pop from empty stack / beyond block start boundary at 122228 (at 0:122228)]
Fatal: error in parsing input
em++: error: '/home/nick/src/emsdk/upstream/bin/wasm-emscripten-finalize --minimize-wasm-changes --dyncalls-i64 ptam_wasm.wasm -o ptam_wasm.wasm --detect-features' failed (returned 1)
CMakeFiles/ptam_wasm.dir/build.make:112: recipe for target 'ptam_wasm.js' failed
make[2]: *** [ptam_wasm.js] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ptam_wasm.dir/all' failed
make[1]: *** [CMakeFiles/ptam_wasm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
emmake: error: 'make' failed (returned 2)
```

This error appears to have been reported occasionally at other times, but without a definite cause other than Emscripten trying to deal with code which it cannot process.

Doing a bit of analysis to locate the problem by commenting out the PTAM code until I find a call which produces the error when uncommented and not when commented, I find that a function in the CLAPACK library (C conversion of maths library LAPACK) is the source of the problem.

CLAPACK is C code auto-generated from Fortran (http://www.netlib.org/clapack/)

Looking at the code, it seems somewhat non-standard in style, being autogenerated by `f2c`.

Does emscripten have a known problem with this type of code? Has anyone else tried using emscripten with CLAPACK?

Thanks,
Nick


nickw

unread,
Jul 26, 2021, 9:57:29 AM7/26/21
to emscripten-discuss

To follow up on this and give a little more info, the function causing the problem in CLAPACK is the dgesvd_() function within file dgesvd.c

Unusual (to my eyes) coding styles from this auto-generated code include function declarations within the body of another function, something I have not encountered before.

nickw

unread,
Jul 31, 2021, 3:28:47 PM7/31/21
to emscripten-discuss

Sorted this in the end.. digging a bit deeper revealed the problem eventually, in the CLAPACK library some function declarations returned int when the implenentation (in the f2c library) had them returning void.
Reply all
Reply to author
Forward
0 new messages