-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use std::hash<std::type_index>
, std::equal_to<std::type_index>
everywhere **except when libc++ is in use**
#4319
Merged
rwgk
merged 29 commits into
pybind:master
from
rwgk:internals_std_type_index_modernization
Apr 25, 2023
Merged
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a06949a
Try using `std::hash<std::type_index>`, `std::equal_to<std::type_inde…
9d70eba
Revert "Try using `std::hash<std::type_index>`, `std::equal_to<std::t…
9141519
Use "our own name-based hash and equality functions" for `std::type_i…
ba747dc
Patch in PR #4313: Minimal reproducer for clash when binding types de…
1912670
test_unnamed_namespace_b xfail for clang
d8b7118
`PYBIND11_INTERNALS_VERSION 5`
780d3b2
Add a note to docs/classes.rst
3373b47
For compatibility with Google-internal testing, test_unnamed_namespac…
8f0c28e
Trying "__GLIBCXX__ or Windows", based on observations from Google-in…
883cadf
Try _LIBCPP_VERSION
72a8895
Account for libc++ behavior in tests and documentation.
6f1ddb2
Adjust expectations for Windows Clang (and make code less redundant).
a1175ed
Add WindowsClang to ci.yml
5631d94
Add clang-latest to name that appears in the GitHub Actions web view.
81a4e7b
Tweak the note in classes.rst again.
7075e00
Add `pip install --upgrade pip`, Show env, cosmetic changes
b84a163
Add macos_brew_install_llvm to ci.yml
4f06c06
`test_cross_module_exception_translator` xfail 'Homebrew Clang'
2180d04
Revert back to base version of .github/workflows/ci.yml (the ci.yml c…
d2d2c0a
Merge branch 'master' into internals_std_type_index_modernization
b882060
Fixes for ruff
66e0fac
Merge branch 'master' into internals_std_type_index_modernization
f1c3055
Make updated condition in internals.h dependent on ABI version.
4842b9f
Merge branch 'master' into internals_std_type_index_modernization
0ff73a9
Remove PYBIND11_TEST_OVERRIDE when testing with PYBIND11_INTERNALS_VE…
9f60e9a
Merge branch 'master' into internals_std_type_index_modernization
d0276c0
Selectively exercise cmake `-DPYBIND11_TEST_OVERRIDE`: ubuntu, macos,…
4f4fd04
Merge branch 'master' into internals_std_type_index_modernization
1b4a508
Update skipif for Python 3.12a7 (the WIP needs to be handled in a sep…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "pybind11_tests.h" | ||
|
||
namespace { | ||
struct any_struct {}; | ||
} // namespace | ||
|
||
TEST_SUBMODULE(unnamed_namespace_a, m) { | ||
py::class_<any_struct>(m, "unnamed_namespace_a_any_struct"); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# NOTE: This test relies on pytest SORT ORDER: | ||
# test_unnamed_namespace_a.py imported before test_unnamed_namespace_b.py | ||
|
||
from pybind11_tests import unnamed_namespace_a as m | ||
|
||
|
||
def test_have_class_any_struct(): | ||
assert m.unnamed_namespace_a_any_struct is not None |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "pybind11_tests.h" | ||
|
||
namespace { | ||
struct any_struct {}; | ||
} // namespace | ||
|
||
TEST_SUBMODULE(unnamed_namespace_b, m) { | ||
if (py::detail::get_type_info(typeid(any_struct)) == nullptr) { | ||
py::class_<any_struct>(m, "unnamed_namespace_b_any_struct"); | ||
} else { | ||
m.attr("unnamed_namespace_b_any_struct") = py::none(); | ||
} | ||
m.attr("defined___clang__") = | ||
#if defined(__clang__) | ||
true; | ||
#else | ||
false; | ||
#endif | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# NOTE: This test relies on pytest SORT ORDER: | ||
# test_unnamed_namespace_a.py imported before test_unnamed_namespace_b.py | ||
|
||
import pytest | ||
|
||
from pybind11_tests import unnamed_namespace_b as m | ||
|
||
|
||
@pytest.mark.xfail( | ||
"m.defined___clang__", | ||
reason="Known issue with all clang versions: https://github.com/pybind/pybind11/pull/4316", | ||
strict=True, | ||
) | ||
def test_have_class_any_struct(): | ||
assert m.unnamed_namespace_b_any_struct is not None |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about non_apple_clang Clang15, Clang16? I am actually not sure we test that in our CI surprisingly, but llvm supports Linux, Windows, and MacOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
But:
PYBIND11_INTERNALS_VERSION
.FWIW, initially I thought the problem is elsewhere and it may be an easy fix. I didn't anticipate that it would go in the direction you see now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwgk Is there an issue opened up on the LLVM repo for this bug btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not to my knowledge.
I think it'll be a couple hours work (at least) to create a minimal reproducer for them, assuming that they will not be able to work with a pybind11-based reproducer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4316 (comment)
That platform is actually the worst:
std::type_index
does not work as desired, and cross-module exception translation is broken, even if the exceptions have default visibility (IOW "are exported").There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could test this using the conda-forge compilers (they are vanilla clang on macOS). This also work in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the meantime I solved this (but forgot to note that here):
#4326