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

Standalone programs without main are broken #9635

Closed
kripken opened this issue Oct 12, 2019 · 1 comment · Fixed by #9641
Closed

Standalone programs without main are broken #9635

kripken opened this issue Oct 12, 2019 · 1 comment · Fixed by #9641

Comments

@kripken
Copy link
Member

kripken commented Oct 12, 2019

STR:

#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE void foo() {}

=>

$ ./emcc a.cpp -o a.wasm
error: undefined symbol: main
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`

@sbc100 Is that related to the recent crt1 changes perhaps?

@sbc100
Copy link
Collaborator

sbc100 commented Oct 14, 2019

Hmm, this seems to be because of the way EXPORTED_FUNCTIONS works. We have the default value in src/settings.js which includes '_main' by default. Then we have the command line -s EXPORTED_FUNCTIONS. I'd forgotten by emscriptens normal behaviour is to only mention undefined symbols that come from the user, not from src/settings.js defaults.

This means that we can't seem a 'main' exists just because 'main' is part of EXPORTED_FUNCTIONS. This means that var HAS_MAIN in jsifier.js isn't occurate and nor is use_start_function in Builder.link_lld.

I suggest that we add a command line flag to signal that a program has no main. We could either use -s EXPORTED_FUNCTIONS=[] or a more explicit flag such as -mno-entry?

If we really want to maintain backwards compat we could also make the reference to main in crt1 a weak ref?

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