Closed sbc100 closed 4 years ago
The cost here is that some users will see undefined symbol: main
in their builds and be forces to add -fno-entry
.
See #9635
@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!)
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 nomain
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 isHAS_MAIN
in jsifier, and the second isBuilding.link_lld
. In both cases we get false positives becausemain
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.