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

IF YOU ARE EXPERIENCING SYMBOLS BEING STRIPPED NO MATTER WHAT YOU DO AND ARE GETTING LINKER ERRORS, READ THIS #22730

Open
zackees opened this issue Oct 13, 2024 · 0 comments

Comments

@zackees
Copy link

zackees commented Oct 13, 2024

I've been creating an empscripten WASM target for FastLED.

earlier this week today i've been intensively investigating symbols not showing up.

Let me just skip right to the point

Clang is stripping out your symbols before they are getting to the linker. Our exports were in one .cpp file.

Here's what's happening: clang is really aggressive in eliminating object files that aren't being referenced by other objects/libs (as of trzeci/emscripten:1.39.17-upstream).

EMSCRIPTEN_KEEPALIVE appears to be powerless here.. Telling the linker the symbols exist does nothing in orphaned object files. Clang will tree shake the exports out.

Here's a quick solution that worked for this project.

  • Put all your exports into a *.hpp.
  • Include this exports.hpp into one of your main cpp files.

Happy coding!

Repro Case

git clone github.com/fastled/fastled

Check out this commit.
5d0c06e3e8e2a6dc19b21263c2360839ac818c2c

Then run this command:
uv run ci/wasm_compile.py -b examples/wasm

When the build is done a browser window will pop open and you'll see this, missing symbols for extern_setup and extern_loop:

image

Anytime after we applied the fix, you should see something like this:

image

Previous issue(s): #6233

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

1 participant