Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Dec 11, 2025

This means that -shared will now produce a dynamic library by default.

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


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

Choose a reason for hiding this comment

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

@bradking should I just delete line instead? (i.e. does this default to true?)

Choose a reason for hiding this comment

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

Yes, the CMakeGenericSystem module initializes the property to TRUE. It doesn't need to be set here.

This means that `-shared` will now produce a dynamic library by default.

If you want the old behaviour you now need `-sFAKE_DYLIBS`.
@sbc100 sbc100 requested review from dschuff and kripken December 11, 2025 00:50
to behave like :ref:`SIDE_MODULE` and produce and dynamically linked
library.
This setting changes the behaviour of the ``-shared`` flag. When set to true
you get the old emscripten behaivour where the ``-shared`` flag actually
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
you get the old emscripten behaivour where the ``-shared`` flag actually
you get the old emscripten behaviour where the ``-shared`` flag actually

cmd.append(stub)

if not settings.FAKE_DYLIBS:
cmd.append('-Bdynamic')
Copy link
Member

Choose a reason for hiding this comment

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

Before this was just for main module - why is it different?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm.. yes I guess this part of the change would be removing the need for -sMAIN_MODULE (i.e. implicitly building a main module when dynamic libraries are present). Maybe that should be left for a followup.

Copy link
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).


# Verify that building with -sSIDE_MODULE is essentailly the same as building with `-shared -fPIC -sFAKE_DYLIBS=0`.
flags = ['-shared', '-fPIC', '-sFAKE_DYLIBS=0']
# Verify that building with -sSIDE_MODULE is essentailly the same as building with `-shared -fPIC`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Verify that building with -sSIDE_MODULE is essentailly the same as building with `-shared -fPIC`
# Verify that building with -sSIDE_MODULE is essentially the same as building with `-shared -fPIC`

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