Update comment (incl. mention of deadsnakes known to not work as intended).

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-07-14 08:10:23 -07:00
parent 02ac969c80
commit 671c2ce0d5

View File

@ -23,19 +23,21 @@ PYBIND11_NAMESPACE_BEGIN(detail)
# define PYBIND11_DESCR_CONSTEXPR const # define PYBIND11_DESCR_CONSTEXPR const
#endif #endif
// type_caster_odr_guard.h requires Translation-Unit-local features // struct src_loc below is to support type_caster_odr_guard.h
// (https://en.cppreference.com/w/cpp/language/tu_local), standardized only with C++20. // (see https://github.com/pybind/pybind11/pull/4022).
// The ODR guard creates ODR violations itself (see WARNINGs below & in // The ODR guard creates ODR violations itself (see WARNINGs below & in
// type_caster_odr_guard.h), but the dedicated test_type_caster_odr_guard_1, // type_caster_odr_guard.h), but is currently the best tool available, and the dedicated
// test_type_caster_odr_guard_2 pair of unit tests passes reliably with almost all // test_type_caster_odr_guard_1, test_type_caster_odr_guard_2 pair of unit tests passes
// tested C++17 & C++20 compilers, and even the exceptions are not due to ODR issues: // reliably on almost all platforms that meet the compiler requirements (C++17, C++20),
// except one (deadsnakes in the GitHub CI).
// In the pybind11 unit tests we want to test the ODR guard in as many environments as possible,
// but it is NOT recommended to turn on the guard in regular builds, production, or
// debug. The guard is meant to be used similar to a sanitizer, to check for type_caster
// ODR violations in binaries that are otherwise already fully tested and assumed to be healthy.
//
// * MSVC 2017 does not support __builtin_FILE(), __builtin_LINE(). // * MSVC 2017 does not support __builtin_FILE(), __builtin_LINE().
// * Intel 2021.6.0.20220226 (g++ 9.4 mode) __builtin_LINE() is unreliable // * Intel 2021.6.0.20220226 (g++ 9.4 mode) __builtin_LINE() is unreliable
// (line numbers vary between translation units). // (line numbers vary between translation units).
// Here we want to test the ODR guard in as many environments as possible, but
// it is NOT recommended to turn on the guard in regular builds, production, or
// debug. The guard is meant to be used similar to a sanitizer, to check for type_caster
// ODR violations in binaries that are otherwise already fully tested and assumed to be healthy.
#if defined(PYBIND11_TYPE_CASTER_ODR_GUARD_ON_IF_AVAILABLE) \ #if defined(PYBIND11_TYPE_CASTER_ODR_GUARD_ON_IF_AVAILABLE) \
&& !defined(PYBIND11_TYPE_CASTER_ODR_GUARD_ON) && !defined(__INTEL_COMPILER) \ && !defined(PYBIND11_TYPE_CASTER_ODR_GUARD_ON) && !defined(__INTEL_COMPILER) \
&& ((defined(_MSC_VER) && _MSC_VER >= 1920) || defined(PYBIND11_CPP17)) && ((defined(_MSC_VER) && _MSC_VER >= 1920) || defined(PYBIND11_CPP17))
@ -44,8 +46,6 @@ PYBIND11_NAMESPACE_BEGIN(detail)
#ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON #ifdef PYBIND11_TYPE_CASTER_ODR_GUARD_ON
// struct src_loc supports type_caster_odr_guard.h
// Not using std::source_location because: // Not using std::source_location because:
// 1. "It is unspecified whether the copy/move constructors and the copy/move // 1. "It is unspecified whether the copy/move constructors and the copy/move
// assignment operators of source_location are trivial and/or constexpr." // assignment operators of source_location are trivial and/or constexpr."