Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module.cwrap not finding symbols #849

Closed
j4m3z0r opened this issue Feb 13, 2013 · 2 comments
Closed

Module.cwrap not finding symbols #849

j4m3z0r opened this issue Feb 13, 2013 · 2 comments

Comments

@j4m3z0r
Copy link
Contributor

j4m3z0r commented Feb 13, 2013

Have been trying to get Module.cwrap to work. Followed the instructions on https://github.com/kripken/emscripten/wiki/Interacting-with-code -- I ran

./emcc tests/hello_function.cpp -o function.html

Loaded that in Chrome, entered

int_sqrt = Module.cwrap('int_sqrt', 'number', ['number'])

into the Javascript Console and got this error:

Assertion failed: Cannot call unknown function int_sqrt (perhaps LLVM optimizations or closure removed it?):
Error
    at abort (file:///tmp/function.html:568:32)
    at assert (file:///tmp/function.html:575:5)
    at getCFunc (file:///tmp/function.html:612:56)
    at Object.cwrap (file:///tmp/function.html:658:14)
    at <anonymous>:2:19
    at Object.InjectedScript._evaluateOn (<anonymous>:505:39)
    at Object.InjectedScript._evaluateAndWrap (<anonymous>:464:52)
    at Object.InjectedScript.evaluate (<anonymous>:400:21)
@j4m3z0r
Copy link
Contributor Author

j4m3z0r commented Feb 13, 2013

(re-posting from right github account -- sorry. Now I can close!)

Ok, so this can probably be reduced to a documentation bug. If you invoke emcc like so:

./emcc -s EXPORTED_FUNCTIONS="['_int_sqrt']" -o /tmp/function.html tests/hello_function.cpp

Then it does indeed work as advertised. I assume that something has changed in the behavior of either LLVM or Emscripten that causes this to be necessary now, whereas previously these functions were not stripped.

Probably just updating the documentation on https://github.com/kripken/emscripten/wiki/Interacting-with-code to cite the EXPORTED_FUNCTIONS argument as mandatory for this kind of thing will suffice.

@j4m3z0r j4m3z0r closed this as completed Feb 13, 2013
@kripken
Copy link
Member

kripken commented Feb 19, 2013

This is probably LLVM doing more aggressive code elimination now. Thanks, i'll update the docs there about this.

logue added a commit to logue/libmp3lame-js that referenced this issue Dec 4, 2013
-s EXPORTED_FUNCTIONS switch does not definded. So, minified code was not able to run...
emscripten-core/emscripten#849
axodox pushed a commit to axodox/emscripten that referenced this issue Mar 18, 2023
When linking with `-o filename` (such as in various CMake build checks), the parameter passed to the linker is a temporary file, and it is passed as a bare filename (i.e. relative path without a `'/'`). In such cases, `outdir` would have been the empty string, and the final `tar` command would fail (actually the call to `subprocess.check_call(…)` is what fails).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants