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

Dynamic linking: emscripten_get_now.sig is undefined #17106

Closed
hoodmane opened this issue May 31, 2022 · 6 comments · Fixed by #17123
Closed

Dynamic linking: emscripten_get_now.sig is undefined #17106

hoodmane opened this issue May 31, 2022 · 6 comments · Fixed by #17123

Comments

@hoodmane
Copy link
Contributor

hoodmane commented May 31, 2022

I am running into the following issue when building the cryptography PyO3 module:

RuntimeError: abort(Assertion failed: bad export type for `_emscripten_get_now`: undefined). Build with -s ASSERTIONS=1 for more info.
    at abort (http://127.0.0.1:32797/pyodide.asm.js:10:234384)
    at assert (http://127.0.0.1:32797/pyodide.asm.js:10:224838)
    at Object.reportUndefinedSymbols (http://127.0.0.1:32797/pyodide.asm.js:10:319214)

wasm-objdump shows that we are trying to import emscripten_get_now:

$ cryptography_rust.so -j Import -x | grep emscripten_get_now
 - func[62] sig=57 <env._emscripten_get_now> <- env._emscripten_get_now
 - global[57] i32 mutable=1 <- GOT.func._emscripten_get_now

but resolveGlobalSymbol("emscripten_get_now") returns undefined and so we get an error from reportUndefinedSymbols.

Adding the lines

Module["__emscripten_get_now"] = Module["_emscripten_get_now"];
Module["__emscripten_get_now"].sig = "d";

fixes the problem.

cf pyodide/pyodide#2378

@sbc100
Copy link
Collaborator

sbc100 commented Jun 1, 2022

It looks like that side module is trying to import this symbol with an _ prefix. But that symbols doesn't start with and underscore:

double emscripten_get_now(void);

Do you know where the _emscripten_get_now symbol is coming from? Which object contains that reference? In the native object files non of the symbols should have an _ prefix.

@sbc100
Copy link
Collaborator

sbc100 commented Jun 1, 2022

(perhaps somewhere in the source code that symbols is incorrectly being forward declared with a leading underscore?)

@hoodmane
Copy link
Contributor Author

hoodmane commented Jun 1, 2022

@hoodmane
Copy link
Contributor Author

hoodmane commented Jun 1, 2022

Even if I fix that, there is still an error because there is a GOT entry for emscripten_get_now but Module.resolveGlobalSymbol("emscripten_get_now").sig is undefined:

TypeError: Cannot read properties of undefined (reading 'slice')
    at convertJsFunctionToWasm (pyodide.asm.js:9356:24)
    at addFunctionWasm (pyodide.asm.js:9480:23)
    at Object.reportUndefinedSymbols (pyodide.asm.js:14952:34)

@sbc100
Copy link
Collaborator

sbc100 commented Jun 1, 2022

That sounds like a real bug. Feel free to send a PR adding a __sig attribute to emscripten_get_now (if you don't have time someone else will get it).

@sbc100
Copy link
Collaborator

sbc100 commented Jun 1, 2022

Can you re-title this bug (or open a new one)?

@hoodmane hoodmane changed the title Dynamic linking: resolveGlobalSymbol("emscripten_get_now") is undefined Dynamic linking: emscripten_get_now.sig is undefined Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants