Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PYBIND11_PLATFORM_ABI_ID
Modernization Continued (platforms other t…
…han MSVC) (#5439) * THIS IS JUST A START: First attempt to combine information from PR #4953 and PR #5437 * 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. * style: pre-commit fixes * 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. * 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. * Change `usecxx11` to `use_cxx11_abi` for correspondence with `_GLIBCXX_USE_CXX11_ABI` (similarly to `gxx_abi` for `__GXX_ABI_VERSION`). * `PYBIND11_COMPILER_TYPE` overhaul, mainly: replace `_icc`, `_clang`, `_gcc` with `_system` * Add NVHPC (__PGI) to the list of compilers compatible with system compiler. See comment by @robertmaynard: #5439 (comment) * Fix oversight: remove __NVCOMPILER elif branch in PYBIND11_BUILD_ABI block. Also add comment pointing to this PR (#5439). * Revert "Fix oversight: remove __NVCOMPILER elif branch in PYBIND11_BUILD_ABI block." This reverts commit d412303. * Revert "Add NVHPC (__PGI) to the list of compilers compatible with system compiler." This reverts commit 9fc9515. * Define NVHPC PYBIND11_BUILD_ABI using __GNUC__, __GNUC_MINOR__, _GLIBCXX_USE_CXX11_ABI * Use _GLIBCXX_USE_CXX11_ABI to detect libstdc++, then assume that NVHPC is always in the 1xxx ABI family. * Enhance NVHPC comment and limited future proofing. * The `PYBIND11_STDLIB` is obsolete but kept around to maintain backward compatibility. * Move `PYBIND11_BUILD_TYPE` down in the file, so that the order of macro definitions is the same as in the list defining `PYBIND11_PLATFORM_ABI_ID` * Introduce `PYBIND11_COMPILER_TYPE_LEADING_UNDERSCORE`: This makes it possible to achieve these two goals: * Avoid the leading underscore in `PYBIND11_PLATFORM_ABI_ID` (see #5439 (comment)) * Maintain backward compatibility for use cases as reported under #5439 (comment) `PYBIND11_INTERNALS_KIND` is removed in this commit to ensure that `PYBIND11_COMPILER_TYPE` is the first element of the `PYBIND11_PLATFORM_ABI_ID`, so that `PYBIND11_COMPILER_TYPE_LEADING_UNDERSCORE` can meaningfully be used as a prefix for `PYBIND11_PLATFORM_ABI_ID` in pybind11/detail/internals.h. * Apply suggestion by @isuruf, with revised comments (code is as suggested). * Make determination of `PYBIND11_COMPILER_TYPE` `"macos"` or `"glibc"` more general. The main motivation is to resolve these "Manylinux on 🐍 3.13t • GIL" and "Pyodide wheel" failures: ``` /__w/pybind11/pybind11/include/pybind11/conduit/pybind11_platform_abi_id.h:35:10: error: #error "Unknown PYBIND11_COMPILER_TYPE: PLEASE REVISE THIS CODE." 35 | # error "Unknown PYBIND11_COMPILER_TYPE: PLEASE REVISE THIS CODE." | ^~~~~ ``` (All other CI jobs succeeded.) Further thought: Essentially, under Linux and macOS the `PYBIND11_COMPILER_TYPE` is only for informational purposes. ABI compatibility is determined by the libstdc++ or libc++ ABI version. * Add `PYBIND11_COMPILER_TYPE` `emscripten` * Add `PYBIND11_COMPILER_TYPE` `graalvm` * Revert "Add `PYBIND11_COMPILER_TYPE` `graalvm`" This reverts commit 75da5fb. * Revert "Add `PYBIND11_COMPILER_TYPE` `emscripten`" This reverts commit e34dc8b. * Revert "Make determination of `PYBIND11_COMPILER_TYPE` `"macos"` or `"glibc"` more general." This reverts commit 41daaa4. * Revert "Apply suggestion by @isuruf, with revised comments (code is as suggested)." This reverts commit ca9e699. * Remove `defined(__INTEL_COMPILER)` as suggested by @hpkfft under #5439 (comment) --------- Co-authored-by: Marcus D. Hanwell <marcus@cryos.net> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information