Remove SHARED
from pybind11_add_module
(take two) to avoid segfaults on macOS with Python statically linked with libpython
#1418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rebases #1305 on top of the latest rolling. #1305 was blocked on some kind of CI failure on Windows, I want to understand if this is still the case or not.
To give a bit more of context, removing
SHARED
frompybind11_add_module
ensures that the built extension is compiled asMODULE
(default setting forpybind11_add_module
) and that can be loaded fine (i.e. without segfaults) on macOS with Python versions that statically linked libpython.conda-forge
is an example of distribution that provides a Python version that statically links libpython for performance reasons, and other distributions are also considering switching to statically linking libpython for performance reasons (see astral-sh/python-build-standalone#540 for example).As already mentioned in #1305, there should be no downside in building
_rclpy_pybind11
asMODULE
, unless somewhere_rclpy_pybind11
is linked as a shared libraries viatarget_link_libraries
instead ofdlopen
-ed by python, but I don't think there is any use case for which that make sense, and I could not find any such usage of_rclpy_pybind11
in public repos.