Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: GNU symbol visibility option #994

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,22 @@ If a file is added to the CMake build system by updating one of the ``CMakeLists
will not explicitly reconfigure the project. Instead, the generated build-system will automatically
detect the change and reconfigure the project after :meth:`skbuild.cmaker.CMaker.make` is called.

.. _symbol_visibility:

Controlling exported symbol visibility
--------------------------------------

When using a GNU based compiler on Linux, scikit-build will reduce the binary size by removing all the native exported methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is part of PythonExtensions, not all of scikit-build, right? Most or all pybind11 and nanobind projects do not use PythonExtensions. Also, FindPythonInterp and FindPythonLibs is being removed (sort-of) from CMake 3.27; users using FindPython won't be affected by this variable either, I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcfr is there another caveot I am missing as to when this would be used?

By default, only the ``PyInit_<moduleName>`` (or ``init<moduleName>``) entry point is exported from the native module.
If you need to preserve native exports in your module, you may set ``SKBUILD_GNU_SKIP_LOCAL_SYMBOL_EXPORT_OVERRIDE`` as a
`CMake option <https://scikit-build.readthedocs.io/en/latest/usage.html#cmake-configure-options>`_
or
`setup.py option <https://scikit-build.readthedocs.io/en/latest/usage.html#scikit-build-options>`_.

Copy link
Contributor

@jcfr jcfr Jun 7, 2023

Choose a reason for hiding this comment

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

Suggested change
Note that for Python >= 3.9, setting the option `SKBUILD_GNU_SKIP_LOCAL_SYMBOL_EXPORT_OVERRIDE` to `ON` allow to ...

It would be nice to further improve to provide some historical contest based on the summary available at #703 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a little more detail as to how this works and on what systems.

Modules built with a GNU based compiler on Linux, can control exports through a `version script <https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_25.html>`_.
For this platform/compiler combination, regardless of the target Python version, scikit-build always creates a version script.
When this option is set to ``OFF``, a version script is created that specifies all local methods to be excluded from export.
When this option is set to ``ON``, a version script is created allowing all local methods to be exported and available in the built module.

Environment variable configuration
----------------------------------
Expand Down
Loading