diff --git a/docs/compiling.rst b/docs/compiling.rst index 2b543be0be..4294fb9334 100644 --- a/docs/compiling.rst +++ b/docs/compiling.rst @@ -582,13 +582,13 @@ using ``pip`` or ``conda``. If it hasn't, you can also manually specify ``-I /include`` together with the Python includes path ``python3-config --includes``. -On macOS: the build command is almost the same but it also requires passing -the ``-undefined dynamic_lookup`` flag so as to ignore missing symbols when -building the module: +On macOS: the build command is almost the same but it also requires passing the +``-undefined dynamic_lookup -Wl,no_fixup_chains`` flag to ignore missing symbols +when building the module: .. code-block:: bash - $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) + $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup -Wl,no_fixup_chains $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) In general, it is advisable to include several additional build parameters that can considerably reduce the size of the created binary. Refer to section diff --git a/tools/pybind11Common.cmake b/tools/pybind11Common.cmake index 0c985bc8e5..f83485881d 100644 --- a/tools/pybind11Common.cmake +++ b/tools/pybind11Common.cmake @@ -75,7 +75,8 @@ if(CMAKE_VERSION VERSION_LESS 3.13) set_property( TARGET pybind11::python_link_helper APPEND - PROPERTY INTERFACE_LINK_LIBRARIES "$<$:-undefined dynamic_lookup>") + PROPERTY INTERFACE_LINK_LIBRARIES + "$<$:-undefined dynamic_lookup -no_fixup_chains>") else() # link_options was added in 3.13+ # This is safer, because you are ensured the deduplication pass in CMake will not consider @@ -83,7 +84,8 @@ else() set_property( TARGET pybind11::python_link_helper APPEND - PROPERTY INTERFACE_LINK_OPTIONS "$<$:LINKER:-undefined,dynamic_lookup>") + PROPERTY INTERFACE_LINK_OPTIONS + "$<$:LINKER:-undefined,dynamic_lookup,-no_fixup_chains>") endif() # ------------------------ Windows extras -------------------------