From 14f8425ce62fde83735f9504d9966e628e5b43b8 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 10 Nov 2024 15:27:14 -0800 Subject: [PATCH 1/5] THIS IS JUST A START: First attempt to combine information from PR #4953 and PR #5437 --- .../pybind11/conduit/pybind11_platform_abi_id.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index a7733bcf5..f1179e69a 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -54,9 +54,7 @@ #endif #ifndef PYBIND11_BUILD_ABI -# if defined(__GXX_ABI_VERSION) // Linux/OSX. -# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_PLATFORM_ABI_ID_TOSTRING(__GXX_ABI_VERSION) -# elif defined(_MSC_VER) // See PR #4953. +# if defined(_MSC_VER) // See PR #4953. # if defined(_MT) && defined(_DLL) // Corresponding to CL command line options /MD or /MDd. # if (_MSC_VER) / 100 == 19 # define PYBIND11_BUILD_ABI "_md_mscver19" @@ -72,8 +70,17 @@ # error "Unknown major version for MSC_VER: PLEASE REVISE THIS CODE." # endif # endif -# elif defined(__NVCOMPILER) // NVHPC (PGI-based). -# define PYBIND11_BUILD_ABI "" // TODO: What should be here, to prevent UB? +# elif defined(__NVCOMPILER) // NVHPC (PGI-based). +# define PYBIND11_BUILD_ABI "" // TODO: What should be here, to prevent UB? +# elif defined(_LIBCPP_ABI_VERSION) // https://libcxx.llvm.org/DesignDocs/ABIVersioning.html +# define PYBIND11_BUILD_ABI "_libcpp" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) +# elif defined(__GXX_ABI_VERSION) +# if __GXX_ABI_VERSION >= 1002 && defined(_GLIBCXX_USE_CXX11_ABI) +# define PYBIND11_BUILD_ABI \ + "_usecxx11" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) +# else +# error "Unknown platform or compiler (__GXX_ABI_VERSION): PLEASE REVISE THIS CODE." +# endif # else # error "Unknown platform or compiler: PLEASE REVISE THIS CODE." # endif From b72c42d489c46db317c23c1af6c1065585cf1996 Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Wed, 20 Nov 2024 16:37:16 -0500 Subject: [PATCH 2/5] Include GXX_ABI and USE_CXX in the identifier Further constrain to GXX_ABI 1002 or greater and less than 2000, hopefully future proof by summarizing that as `1` along with CXX11 on or off. --- include/pybind11/conduit/pybind11_platform_abi_id.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index f1179e69a..30743e112 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -75,9 +75,9 @@ # elif defined(_LIBCPP_ABI_VERSION) // https://libcxx.llvm.org/DesignDocs/ABIVersioning.html # define PYBIND11_BUILD_ABI "_libcpp" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) # elif defined(__GXX_ABI_VERSION) -# if __GXX_ABI_VERSION >= 1002 && defined(_GLIBCXX_USE_CXX11_ABI) +# if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 && defined(_GLIBCXX_USE_CXX11_ABI) # define PYBIND11_BUILD_ABI \ - "_usecxx11" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) + "_gxx_abi_1_usecxx11_" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) # else # error "Unknown platform or compiler (__GXX_ABI_VERSION): PLEASE REVISE THIS CODE." # endif From 8369fdce4ba1c338bc2d5eb57238e2215dc2905d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:39:53 +0000 Subject: [PATCH 3/5] style: pre-commit fixes --- include/pybind11/conduit/pybind11_platform_abi_id.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index 30743e112..54c809753 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -75,7 +75,8 @@ # elif defined(_LIBCPP_ABI_VERSION) // https://libcxx.llvm.org/DesignDocs/ABIVersioning.html # define PYBIND11_BUILD_ABI "_libcpp" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) # elif defined(__GXX_ABI_VERSION) -# if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 && defined(_GLIBCXX_USE_CXX11_ABI) +# if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 \ + && defined(_GLIBCXX_USE_CXX11_ABI) # define PYBIND11_BUILD_ABI \ "_gxx_abi_1_usecxx11_" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) # else From 476c322fec2f2136b498229ec75b8f4b7a139bce Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Wed, 20 Nov 2024 19:44:36 -0500 Subject: [PATCH 4/5] Use `gxx_abi_1xxx` and simplify the Clang string After discussions with Ralf Grosse-Kunstleve we think these would make good identifiers that are concise and clear. --- include/pybind11/conduit/pybind11_platform_abi_id.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index 54c809753..9f173c91d 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -73,12 +73,12 @@ # elif defined(__NVCOMPILER) // NVHPC (PGI-based). # define PYBIND11_BUILD_ABI "" // TODO: What should be here, to prevent UB? # elif defined(_LIBCPP_ABI_VERSION) // https://libcxx.llvm.org/DesignDocs/ABIVersioning.html -# define PYBIND11_BUILD_ABI "_libcpp" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) +# define PYBIND11_BUILD_ABI "_abi" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) # elif defined(__GXX_ABI_VERSION) # if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 \ && defined(_GLIBCXX_USE_CXX11_ABI) # define PYBIND11_BUILD_ABI \ - "_gxx_abi_1_usecxx11_" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) + "_gxx_abi_1xxx_usecxx11_" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) # else # error "Unknown platform or compiler (__GXX_ABI_VERSION): PLEASE REVISE THIS CODE." # endif From 271720fde97f72d0c0002619114bd9edea5bc95f Mon Sep 17 00:00:00 2001 From: "Marcus D. Hanwell" Date: Wed, 20 Nov 2024 20:10:08 -0500 Subject: [PATCH 5/5] Error if `_GLIBCXX_USE_CXX11_ABI` is not defined Within the `__GXX_ABI_VERSION` block this should always be defined, guard against unexpected defines and make the error obvious. --- include/pybind11/conduit/pybind11_platform_abi_id.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/pybind11/conduit/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h index 9f173c91d..7e9b801d3 100644 --- a/include/pybind11/conduit/pybind11_platform_abi_id.h +++ b/include/pybind11/conduit/pybind11_platform_abi_id.h @@ -75,8 +75,10 @@ # elif defined(_LIBCPP_ABI_VERSION) // https://libcxx.llvm.org/DesignDocs/ABIVersioning.html # define PYBIND11_BUILD_ABI "_abi" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_LIBCPP_ABI_VERSION) # elif defined(__GXX_ABI_VERSION) -# if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 \ - && defined(_GLIBCXX_USE_CXX11_ABI) +# if __GXX_ABI_VERSION >= 1002 && __GXX_ABI_VERSION < 2000 +# if !defined(_GLIBCXX_USE_CXX11_ABI) +# error "UNEXPECTED: _GLIBCXX_USE_CXX11_ABI not defined" +# endif # define PYBIND11_BUILD_ABI \ "_gxx_abi_1xxx_usecxx11_" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_GLIBCXX_USE_CXX11_ABI) # else