Skip to content

Enable real dynamic linking by default#25930

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:shared_flag_part2
Open

Enable real dynamic linking by default#25930
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:shared_flag_part2

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Dec 11, 2025

This change essentially disables FAKE_DYLIBS by default, which in
turn means -shared will now produce dynamic libraries by default.

If you want the old behaviour you now need -sFAKE_DYLIBS.

Comment thread cmake/Modules/Platform/Emscripten.cmake Outdated
@sbc100 sbc100 force-pushed the shared_flag_part2 branch 2 times, most recently from 6e4f78f to 3b0addc Compare December 11, 2025 00:49
@sbc100 sbc100 requested review from dschuff and kripken December 11, 2025 00:50
Comment thread site/source/docs/tools_reference/settings_reference.rst Outdated
Comment thread tools/building.py
Copy link
Copy Markdown
Member

@dschuff dschuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what would happen if we tested this with Binaryen. it doesn't seem prepared to force the Emscripten build to be static (assuming that's the behavior we actually want).

Comment thread test/test_core.py Outdated
@sbc100 sbc100 force-pushed the shared_flag_part2 branch from 3b0addc to 2a98976 Compare May 12, 2026 01:15
@sbc100 sbc100 changed the title Disable FAKE_DYLIBS by default Enable real dynamic linking by default May 12, 2026
@sbc100 sbc100 force-pushed the shared_flag_part2 branch 2 times, most recently from 9fcb66c to 3b9f050 Compare May 12, 2026 01:19
This change essentially disables `FAKE_DYLIBS` by default, which in
turn means `-shared` will now produce dynamic libraries by default.

If you want the old behaviour you now need `-sFAKE_DYLIBS`.
@sbc100 sbc100 force-pushed the shared_flag_part2 branch from 3b9f050 to d2bc4e4 Compare May 12, 2026 04:13
set(CMAKE_SYSTEM_VERSION 1)

set(CMAKE_CROSSCOMPILING TRUE)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradking, sorry to bother you again, but I'm having trouble landing this change because it seems like it interacts badly with the Modules/Platform/Emscripten-Clang.cmake that now exists upstream.

Even if I set set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") I cannot seems to override the setting here:

https://github.com/Kitware/CMake/blob/61510710b12ddff97c2c22e146cdfb399daa2dad/Modules/Platform/Emscripten-Clang.cmake#L14

Basically it seems like the builtin support is somehow kicking in even though I don't want it. Is there some way I can disable the builtin stuff in using the this file?

It looks like there is some attempt to prevent the bad interaction here: https://github.com/Kitware/CMake/blob/61510710b12ddff97c2c22e146cdfb399daa2dad/Modules/Platform/Emscripten.cmake#L8-L12.

But that doesn't seem to stop the Emscripten-Clang.cmake from having its effects.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS isn't meant to be set by toolchain files. CMake needs to be taught that the Emscripten compiler now supports the -shared flag. What will its CMAKE_C_COMPILER_VERSION be?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see you started discussion in the CMake issue at https://gitlab.kitware.com/cmake/cmake/-/work_items/27240#note_1813569. Let's take the conversation there.

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

Successfully merging this pull request may close these issues.

4 participants