emscripten-core / emscripten-core/emscripten

Dynamic linking breaks with exportet non-JavaScript Identifiers

Open
#27,611 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi,
I'm working on support for GNUStep/Objective-C.

When building an Objective-C library as a SIDE_MODULE, emscripten may create JavaScript declarations for exported symbols.
This is a problem for Objective-C, since it needs to export compiler-generated globals, such as `.objc_ctor` and the Objective-C class metadata.
Emscripten then tries to declare the exported symbols as JavaScript variables.

This is essentially a broader version of the issue that was fixed here: https://github.com/emscripten-core/emscripten/pull/25922, because the previous fixes still do not solve the problem for emscripten's dynamic linking.

I don't know enough about the dynamic linking internals to fix this myself, so I'd appreciate some guidance.
Perhaps it would be possible to either:
- "mangle" invalid JS identifiers, for example by treating $ as an escape character and replacing `.` with `$dot` and `$` with `$$` or something like that
- Avoid declaring JavaScript variables and object-properties with the same name as the exported symbols

Best,
Hendrik

Contributor guide

Open the contributing guide

Research direction

Start by reviewing PR #25922 and tracing the dynamic-linking path for exported symbols when an Objective-C library is built as a SIDE_MODULE. Reproduce the failure with compiler-generated symbols such as `.objc_ctor` and Objective-C class metadata, then verify that dynamic linking handles these exports without invalid JavaScript declarations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, objective-c, wasm
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.