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

PYBIND11_NAMESPACE consistency fixes. #4043

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Jul 5, 2022

Description

This PR fixes a couple long-standing PYBIND11_NAMESPACE __attribute__((visibility("hidden"))) inconsistencies. The fixes only affect builds with __GNUG__ defined.

Based on experiments under PR #4044, this (currently) only makes a difference in an unusual situation: macOS, NOT using -fvisibility=hidden. However, if someone ventures there, surprises due to inconsistencies can be extremely time-consuming to troubleshoot.

(Discovered while experimenting related to PR #4022.)

Suggested changelog entry:

A couple long-standing ``PYBIND11_NAMESPACE`` ``__attribute__((visibility("hidden")))`` inconsistencies are now fixed (affects only unusual environments).

@rwgk rwgk marked this pull request as ready for review July 6, 2022 20:51
@rwgk rwgk requested review from henryiii and Skylion007 July 6, 2022 20:51
@rwgk
Copy link
Collaborator Author

rwgk commented Jul 6, 2022

Thanks!

@rwgk rwgk merged commit cd08869 into pybind:master Jul 6, 2022
@rwgk rwgk deleted the PYBIND11_NAMESPACE_consistency_fixes branch July 6, 2022 21:29
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Jul 6, 2022
@rwgk
Copy link
Collaborator Author

rwgk commented Jul 6, 2022

Just to note, the one post-merge CI failure is a flake I saw several times before already.

Run cmake --build build2 --target pytest
Microsoft (R) Build Engine version [1](https://github.com/pybind/pybind11/runs/7223230463?check_suite_focus=true#step:18:1)7.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
  cross_module_gil_utils.vcxproj -> D:\a\pybind11\pybind11\build2\tests\cross_module_gil_utils.pypy37-pp73-win_amd64.pyd
  cross_module_interleaved_error_already_set.vcxproj -> D:\a\pybind11\pybind11\build2\tests\cross_module_interleaved_error_already_set.pypy37-pp73-win_amd64.pyd
  pybind11_cross_module_tests.vcxproj -> D:\a\pybind11\pybind11\build2\tests\pybind11_cross_module_tests.pypy37-pp73-win_amd64.pyd
  pybind11_tests.vcxproj -> D:\a\pybind11\pybind11\build2\tests\pybind11_tests.pypy37-pp73-win_amd64.pyd
  ------ pybind11_tests.pypy37-pp73-win_amd64.pyd file size: 22369792 (no change)
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for 'D:\a\pybind11\pybind11\build2\CMakeFiles\c74e89d6f5f1ea[10](https://github.com/pybind/pybind11/runs/7223230463?check_suite_focus=true#step:18:11)8a7628c93f4b5083\pytest.rule;D:\a\pybind[11](https://github.com/pybind/pybind11/runs/7223230463?check_suite_focus=true#step:18:12)\pybind11\tests\CMakeLists.txt' exited with code -107374[18](https://github.com/pybind/pybind11/runs/7223230463?check_suite_focus=true#step:18:19)19. [D:\a\pybind11\pybind11\build2\tests\pytest.vcxproj]

rwgk pushed a commit to rwgk/pybind11 that referenced this pull request Jul 8, 2022
To probe environment/toolchain/platform-specific behavior under the exact same conditions as normal tests.

(An earlier version of this code was used to inform PR pybind#4043.)
@rwgk
Copy link
Collaborator Author

rwgk commented Jul 8, 2022

Pure record keeping, JIC it's useful for something later:

(For reasons that are difficult to explain) I compared XPASS before and after this PR was merged:

Due to the flake mentioned in my previous comment, one result is missing. Apart from that, the XPASS are identical between the two CI workflow logs.

Dumping the current XPASS here while I have them handy (complete list from runs/2625465392):

5______pypy-3.7_____ubuntu-latest_____x64.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
5______pypy-3.7_____ubuntu-latest_____x64.txt:XPASS test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
5______pypy-3.7_____ubuntu-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
5______pypy-3.7_____ubuntu-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
5______pypy-3.7_____ubuntu-latest_____x64.txt:XPASS ../../tests/test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
6______pypy-3.8_____ubuntu-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
6______pypy-3.8_____ubuntu-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
6______pypy-3.8_____ubuntu-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
7______pypy-3.9_____ubuntu-latest_____x64.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
7______pypy-3.9_____ubuntu-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
7______pypy-3.9_____ubuntu-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
12______pypy-3.7_____windows-2022_____x64.txt:  XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
12______pypy-3.7_____windows-2022_____x64.txt:  XPASS test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
12______pypy-3.7_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
12______pypy-3.7_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
12______pypy-3.7_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
13______pypy-3.8_____windows-2022_____x64.txt:  XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
13______pypy-3.8_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
13______pypy-3.8_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
14______pypy-3.9_____windows-2022_____x64.txt:  XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
14______pypy-3.9_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
14______pypy-3.9_____windows-2022_____x64.txt:  XPASS ..\..\tests\test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
19______pypy-3.7_____macos-latest_____x64.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
19______pypy-3.7_____macos-latest_____x64.txt:XPASS test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
19______pypy-3.7_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
19______pypy-3.7_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
19______pypy-3.7_____macos-latest_____x64.txt:XPASS ../../tests/test_exceptions.py::test_python_alreadyset_in_destructor Failure on PyPy 3.8 (7.3.7)
20______pypy-3.8_____macos-latest_____x64.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
20______pypy-3.8_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
20______pypy-3.8_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
21______pypy-3.9_____macos-latest_____x64.txt:XPASS test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
21______pypy-3.9_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy
21______pypy-3.9_____macos-latest_____x64.txt:XPASS ../../tests/test_call_policies.py::test_keep_alive_argument sometimes comes out 1 off on PyPy

rwgk pushed a commit that referenced this pull request Jul 13, 2022
* Add test_namespace_visibility

To probe environment/toolchain/platform-specific behavior under the exact same conditions as normal tests.

(An earlier version of this code was used to inform PR #4043.)

* Disable flake8 in ubench/holder_comparison_*.py, to suppress new & useless diagnostics.

* Disable namespace_visibility_1s.cpp (tosee if that resolves the MSVC and CUDA `test_cross_module_exception_translator` failures).

* Turn off flake8 completely for ubench (the Strip unnecessary `# noqa`s action un-helpfully removed the added noqa).

* Disable test_namespace_visibility completely. Just keep the two .cpp files, only setting the module docstring and doing nothing else.

* Rename test_namespace_visibility.py to test_exc_namespace_visibility.py, so that it is imported by pytest before test_exceptions.py

* Add `set_property(SOURCE namespace_visibility_1s.cpp PROPERTY LANGUAGE CUDA)`

* Add reference to PR #4054

* Complete the documentation (comments in test_exc_namespace_visibility.py).

* Rename namespace_visibility.h to namespace_visibility.inl, as suggested by @charlesbeattie
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Oct 20, 2022
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.

3 participants