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

error on undefined main symbol by default #9640

Closed
sbc100 opened this issue Oct 14, 2019 · 3 comments
Closed

error on undefined main symbol by default #9640

sbc100 opened this issue Oct 14, 2019 · 3 comments

Comments

@sbc100
Copy link
Collaborator

sbc100 commented Oct 14, 2019

Currently emscripten tries to make the main symbol optional, so that some programs (in particular library that export functions but have no entry point) can be built with no main all.

While this feature is convenient if make the code in emscripten more complicated since there is no way to know ahead of time (before linking) if a program has an entry point or not. In particualar there are two places in the codebase were we try to detect if main is present. The first is HAS_MAIN in jsifier, and the second is Building.link_lld. In both cases we get false positives because main is often in EXPORTED_FUNCTIONS even when there is no main.

My proposed solution is to force such users to pass a certain link flag (e.g. -mno-entry or -fno-entry) which will allow emscripten to know what type of program is being built.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 14, 2019

The cost here is that some users will see undefined symbol: main in their builds and be forces to add -fno-entry.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 14, 2019

See #9635

sbc100 added a commit that referenced this issue Oct 14, 2019
sbc100 added a commit that referenced this issue May 16, 2020
Unlike without STANDALONE_WASM users are expected to either define
a main or explicitly opt out.
This change and paves to way to moving to llvm's new main mangling
method: https://reviews.llvm.org/D70700

Fixes:  #9640
sbc100 added a commit that referenced this issue May 18, 2020
Unlike without STANDALONE_WASM users are expected to either define
a main or explicitly opt out.
This change and paves to way to moving to llvm's new main mangling
method: https://reviews.llvm.org/D70700

Fixes:  #9640
@sbc100 sbc100 closed this as completed in fcfa4d8 May 18, 2020
@parksj10
Copy link

parksj10 commented Jan 26, 2021

@sbc100 I'm getting a main export error:

error: undefined symbol: main

and the following compiling options:

rm lttb.wasm
emcc ./lttb.cpp \
  --bind \
  --optimize=3 \
  -Wl,--export-all \
  -Wl,--allow-undefined \
  -s ALLOW_MEMORY_GROWTH=1 \
  -o lttb.wasm

EDIT:----

Adding --no-entry to compilation options solved the error (leaving post up so others can reference, please ignore!)

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