Remove SHARED from pybind11_add_module (take two) to avoid segfaults on macOS with Python statically linked with libpython#1418
Closed
traversaro wants to merge 1 commit intoros2:rollingfrom
Closed
Conversation
…S with Python statically linked with libpython Signed-off-by: Silvio Traversaro <silvio@traversaro.it>
Collaborator
fujitatomoya
left a comment
There was a problem hiding this comment.
@traversaro thanks for the ping.
since #1305 is original PR, i just rebased that one, and restarted the CI.
Author
Perfect, thanks! |
This was referenced Feb 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
SHAREDfrompybind11_add_moduleensures 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-forgeis 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_pybind11asMODULE, unless somewhere_rclpy_pybind11is linked as a shared libraries viatarget_link_librariesinstead 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_pybind11in public repos.