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

Missing function signature when using EM_ASYNC_JS and ASYNCIFY=2 #17890

Closed
brendandahl opened this issue Sep 19, 2022 · 4 comments · Fixed by #17929
Closed

Missing function signature when using EM_ASYNC_JS and ASYNCIFY=2 #17890

brendandahl opened this issue Sep 19, 2022 · 4 comments · Fixed by #17929

Comments

@brendandahl
Copy link
Collaborator

Error message:
Aborted(Assertion failed: Missing __sig for __asyncjs__promise42)

Building with:
emcc -sASSERTIONS -sENVIRONMENT=web -g3 -sASYNCIFY=2 -sEXIT_RUNTIME=1 main.cpp -o a.out.html

main.cpp

#include <stdio.h>
#include <emscripten.h>

EM_ASYNC_JS(int, promise42, (), {
  return new Promise((k,r)=>{setTimeout(()=> {return k(42)},0)});
});

int main() {
  printf("p1\n");
  promise42();
  printf("p2\n");
  return 0;
}

I need to look into why the signatures aren't being generated for EM_ASYNC_JS functions.

@sbc100
Copy link
Collaborator

sbc100 commented Sep 20, 2022

I think I ran into this for wasm64 too.

Do we have enough information to generate those signatures? I'm guessing not... we do have the C signature but its hard to go from that to a __sig in a reliable way I think. Perhaps if we only accepted core C types such as size_t, long, etc, we could map them.. but if they use any custom types or macros it wouldn't be possible.

@sbc100
Copy link
Collaborator

sbc100 commented Sep 20, 2022

Ah yes, here is the same issue but for wasm64: #16975

@brendandahl
Copy link
Collaborator Author

Yeah, if we do it only in the preprocessor that would be brittle. I was thinking we could do something like embind and build an array of the mapped types at compile time and extract them in binaryen. However, when I started looking into that I think I found a better way. We already have the signature of the import defined in Wasm, so we could modify the code that extracts the JS functions and have it also extract the signature of the import.

@brendandahl
Copy link
Collaborator Author

Though I guess those signatures won't match up to the C signatures, but they'd be enough for what I need them for in asyncify.

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

Successfully merging a pull request may close this issue.

2 participants