Ralf W. Grosse-Kunstleve
11e858d0da
tu_local_descr with src_loc experiment
2022-06-28 08:42:44 -07:00
Ralf W. Grosse-Kunstleve
3ea37002b1
Eliminate need for PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL
macro.
...
Copying code first developed by @amauryfa. I tried this at an earlier stage, but by itself this was insufficient. In the meantime I added in the TU-local mechanisms: trying again.
Passes local testing:
```
DISABLED std::system_error: ODR VIOLATION DETECTED: pybind11::detail::type_caster<mrc_ns::type_mrc>: SourceLocation1="/usr/local/google/home/rwgk/forked/pybind11/tests/test_type_caster_odr_guard_1.cpp:18", SourceLocation2="/usr/local/google/home/rwgk/forked/pybind11/tests/test_type_caster_odr_guard_2.cpp:19"
C++ Info: Debian Clang 13.0.1 C++17 __pybind11_internals_v4_clang_libstdcpp_cxxabi1002_sh_def__
=========================================================== test session starts ============================================================
platform linux -- Python 3.9.12, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /usr/local/google/home/rwgk/forked/pybind11/tests, configfile: pytest.ini
collected 6 items
test_type_caster_odr_guard_1.py::test_type_mrc_to_python PASSED
test_type_caster_odr_guard_1.py::test_type_mrc_from_python PASSED
test_type_caster_odr_guard_1.py::test_type_caster_odr_registry_values PASSED
test_type_caster_odr_guard_1.py::test_type_caster_odr_violation_detected_counter PASSED
test_type_caster_odr_guard_2.py::test_type_mrc_to_python PASSED
test_type_caster_odr_guard_2.py::test_type_mrc_from_python PASSED
============================================================ 6 passed in 0.01s =============================================================
```
2022-06-28 07:10:20 -07:00
Ralf W. Grosse-Kunstleve
3fc4833433
Add test for stl.h / stl_bind.h mix.
...
Manually verified that the ODR guard detects the ODR violation:
```
C++ Info: Debian Clang 13.0.1 C++17 __pybind11_internals_v4_clang_libstdcpp_cxxabi1002_sh_def__
=========================================================== test session starts ============================================================
platform linux -- Python 3.9.12, pytest-6.2.3, py-1.10.0, pluggy-0.13.1 -- /usr/bin/python3
...
================================================================= FAILURES =================================================================
_____________________________________________ test_type_caster_odr_violation_detected_counter ______________________________________________
def test_type_caster_odr_violation_detected_counter():
...
else:
> assert num_violations == 1
E assert 2 == 1
E +2
E -1
num_violations = 2
test_type_caster_odr_guard_1.py:51: AssertionError
========================================================= short test summary info ==========================================================
FAILED test_type_caster_odr_guard_1.py::test_type_caster_odr_violation_detected_counter - assert 2 == 1
======================================================= 1 failed, 5 passed in 0.08s ========================================================
```
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
4e13032e81
Introduce make_caster_intrinsic<T>
, to be able to undo the 2 changes from load_type
to load_type<T>
. This is to avoid breaking 2 pybind11::detail::load_type()
calls found in the wild (Google global testing).
...
One of the breakages in the wild was: 0f0f600767/python/tensorstore/subscript_method.h (L61)
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
d8280df5d5
assert pybind11_tests.compiler_info is not None
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
491c2c7983
compiler_info MSVC fix. num_violations == 0 condition.
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
0d2bf264c8
Trying a new direction: show compiler info & std for UNEXPECTED: type_caster_odr_violation_detected_count() == 0
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
0c0f322e23
Yet another attempt to handle valgrind behavior.
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
5737b37dd4
Another attempt to handle valgrind behavior.
2022-06-28 00:20:53 -07:00
Ralf W. Grosse-Kunstleve
b10fc2ef15
Attempt to handle valgrind behavior.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
3cc2c9cd45
Apply clang-tidy suggestion.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
262998b317
Report UNEXPECTED: test_type_caster_odr_guard_2.cpp prevailed (but do not fail).
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
1263ce9ee2
Add test_type_caster_odr_registry_values(), test_type_caster_odr_violation_detected_counter()
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
d2bafaeba7
New PYBIND11_TYPE_CASTER_ODR_GUARD_STRICT option (current on by default).
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
21fc6b31c7
Mark tu_local_no_data_always_false operator bool as explicit (clang-tidy). See also: https://stackoverflow.com/questions/39995573/when-can-i-use-explicit-operator-bool-without-a-cast
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
ec8b8b68c7
Remove comments that are (now) more distracting than helpful.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
61a0bb8bd3
Rename test_odr_guard* to test_type_caster_odr_guard*
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
2e6e833929
Move type_caster_odr_guard to type_caster_odr_guard.h
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
1acc9d0555
type_caster_odr_guard_impl() cleanup
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
5d45055a58
Fix ifdef for pragma GCC diagnostic.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
5aaf96a382
Experiment: Try any C++17 compiler.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
590171e6aa
Add new header filename to CMakeLists.txt, test_files.py
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
3d064fcab3
Replace throw err;
to resolve clang-tidy error.
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
ed4b50bb86
IWYU cleanup of detail/type_caster_odr_guard.h
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
6a6eb6cac8
define PYBIND11_DETAIL_ODR_GUARD_IMPL_THROW_DISABLED true in test_odr_guard_1,2.cpp
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
a34771aeda
Move cpp_version_in_use() from cast.h to pybind11_tests.cpp
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
369a3905fa
Restore use of PYBIND11_WERROR
2022-06-28 00:20:52 -07:00
Ralf W. Grosse-Kunstleve
502f3cb969
Report PYBIND11_INTERNALS_ID & C++ Version from pytest_configure()
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
cfd98a7de2
Fix off-by-one in source_file_line_basename()
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
1bf2577e1f
Compatibility with old compilers.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
a8144d971d
Resolve clang-tidy error.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
15db5e5fea
Set PYBIND11_TYPE_CASTER_ODR_GUARD_ON automatically.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
e515940252
Minor cleanup.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
d390918d88
Introduce PYBIND11_TYPE_CASTER_ODR_GUARD_ON (but not set automatically).
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
47c4e7939e
Add source_file_line_basename()
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
0feb0be8c2
Show C++ version along with ODR VIOLATION DETECTED message.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
a598fe6931
Replace C++17 syntax. Compiles with Debian clang 13 C++11 mode, but fails to link. Trying GitHub Actions anyway to see if there are any platforms that support https://en.cppreference.com/w/cpp/language/tu_local before C++20. Note that Debian clang 13 C++17 works locally.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
ca5708ad96
Add new tests to CMakeLists.txt, disable PYBIND11_WERROR
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
b8876ac2af
Strip ./ from source_file_line
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
0f9bb4c892
load_type fixes & follow-on cleanup
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
24d450bf74
Add more PYBIND11_DETAIL_TYPE_CASTER_ACCESS_TRANSLATION_UNIT_LOCAL; resolves "unused" warning when compiling test_custom_type_casters.cpp
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
3a95ae1165
Replace PYBIND11_TYPE_CASTER_UNIQUE_IDENTIFIER with PYBIND11_TYPE_CASTER_SOURCE_FILE_LINE, baked into PYBIND11_TYPE_CASTER macro.
2022-06-28 00:20:51 -07:00
Ralf W. Grosse-Kunstleve
e06518da7d
Add PYBIND11_SOURCE_FILE_LINE macro.
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
1522f57d2d
WIP
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
55530437fc
Small simplification of odr_guard_impl()
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
3718516ff5
Cleanup of tests. Systematically insert if (make_caster<T>::translation_unit_local) {
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
c148a6b324
Copy from cl/454991845 snapshot Jun 14, 5:08 PM
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
9a8489031d
Restore original test_async, test_buffers from current smart_holder HEAD
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
509506955b
VERY MESSY SNAPSHOT of WIP, this was the starting point for cl/454658864, which has more changes on top.
2022-06-28 00:20:50 -07:00
Ralf W. Grosse-Kunstleve
d1960a18cf
Add minimal_real_caster (from PR #3862 ) to test_async, test_buffers
2022-06-28 00:20:50 -07:00