emscripten-core / emscripten-core/emscripten

Add support for "real" shared libraries when using `-shared`

Open
#14,408 11 comments 3 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

As of today when a user passes `-shared` we actually just a build a normal object file.

See https://github.com/emscripten-core/emscripten/blob/d4b9982cc31d9b41c5e9ca71bd4bc7723dbd2684/emcc.py#L1410

I believe that this was implemented this way as quick way to get some types of programs (largely autoconf-based ones) to build statically even though they were assuming they were building dynamically. For simple programs real dynamic linking is often overkill. Ideally such users would instead use `--disabled-shared` or some such build config to avoid building shared libraries at all. The current implementation of `-shared` is kind of half way house between a normal static build (`--disable-shared`) and actual runtime dynamic linking (supported currently in emscripten via `-s SIDE_MODULE` and `-s MAIN_MODULE`).

Tow possible paths forward:

1. Keep the existing behaviour as is an some kind of new option such as `-s REAL_SHARED_LIBRARIES`. This should start of being opt-in and eventually become the default.

2. Ditch the current behavior and switch the real shared libraries by default. This would end up potentiality breaking user who were relying on the fake shared libraries behaviour, forcing them to either find a way to build statically to use real runtime shared libraries.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.