mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
factor out platform_abi_id.h from internals.h (no functional changes)
This commit is contained in:
parent
2617a04e41
commit
87ebc39e98
@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "platform_abi_id.h"
|
||||||
|
|
||||||
#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
|
#if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
|
||||||
# include <pybind11/gil.h>
|
# include <pybind11/gil.h>
|
||||||
@ -264,72 +265,13 @@ struct type_info {
|
|||||||
bool module_local : 1;
|
bool module_local : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// On MSVC, debug and release builds are not ABI-compatible!
|
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
# define PYBIND11_BUILD_TYPE "_debug"
|
|
||||||
#else
|
|
||||||
# define PYBIND11_BUILD_TYPE ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Let's assume that different compilers are ABI-incompatible.
|
|
||||||
/// A user can manually set this string if they know their
|
|
||||||
/// compiler is compatible.
|
|
||||||
#ifndef PYBIND11_COMPILER_TYPE
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_msvc"
|
|
||||||
# elif defined(__INTEL_COMPILER)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_icc"
|
|
||||||
# elif defined(__clang__)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_clang"
|
|
||||||
# elif defined(__PGI)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_pgi"
|
|
||||||
# elif defined(__MINGW32__)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_mingw"
|
|
||||||
# elif defined(__CYGWIN__)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_gcc_cygwin"
|
|
||||||
# elif defined(__GNUC__)
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_gcc"
|
|
||||||
# else
|
|
||||||
# define PYBIND11_COMPILER_TYPE "_unknown"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Also standard libs
|
|
||||||
#ifndef PYBIND11_STDLIB
|
|
||||||
# if defined(_LIBCPP_VERSION)
|
|
||||||
# define PYBIND11_STDLIB "_libcpp"
|
|
||||||
# elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
|
|
||||||
# define PYBIND11_STDLIB "_libstdcpp"
|
|
||||||
# else
|
|
||||||
# define PYBIND11_STDLIB ""
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility.
|
|
||||||
/// On MSVC, changes in _MSC_VER may indicate ABI incompatibility (#2898).
|
|
||||||
#ifndef PYBIND11_BUILD_ABI
|
|
||||||
# if defined(__GXX_ABI_VERSION)
|
|
||||||
# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION)
|
|
||||||
# elif defined(_MSC_VER)
|
|
||||||
# define PYBIND11_BUILD_ABI "_mscver" PYBIND11_TOSTRING(_MSC_VER)
|
|
||||||
# else
|
|
||||||
# define PYBIND11_BUILD_ABI ""
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PYBIND11_INTERNALS_KIND
|
|
||||||
# define PYBIND11_INTERNALS_KIND ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PYBIND11_INTERNALS_ID \
|
#define PYBIND11_INTERNALS_ID \
|
||||||
"__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
|
"__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
|
||||||
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
|
PYBIND11_PLATFORM_ABI_ID "__"
|
||||||
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
|
|
||||||
|
|
||||||
#define PYBIND11_MODULE_LOCAL_ID \
|
#define PYBIND11_MODULE_LOCAL_ID \
|
||||||
"__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
|
"__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
|
||||||
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
|
PYBIND11_PLATFORM_ABI_ID "__"
|
||||||
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
|
|
||||||
|
|
||||||
/// Each module locally stores a pointer to the `internals` data. The data
|
/// Each module locally stores a pointer to the `internals` data. The data
|
||||||
/// itself is shared among modules with the same `PYBIND11_INTERNALS_ID`.
|
/// itself is shared among modules with the same `PYBIND11_INTERNALS_ID`.
|
||||||
|
66
include/pybind11/detail/platform_abi_id.h
Normal file
66
include/pybind11/detail/platform_abi_id.h
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// Copyright (c) 2024 The pybind Community.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
/// On MSVC, debug and release builds are not ABI-compatible!
|
||||||
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
|
# define PYBIND11_BUILD_TYPE "_debug"
|
||||||
|
#else
|
||||||
|
# define PYBIND11_BUILD_TYPE ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Let's assume that different compilers are ABI-incompatible.
|
||||||
|
/// A user can manually set this string if they know their
|
||||||
|
/// compiler is compatible.
|
||||||
|
#ifndef PYBIND11_COMPILER_TYPE
|
||||||
|
# if defined(_MSC_VER)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_msvc"
|
||||||
|
# elif defined(__INTEL_COMPILER)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_icc"
|
||||||
|
# elif defined(__clang__)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_clang"
|
||||||
|
# elif defined(__PGI)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_pgi"
|
||||||
|
# elif defined(__MINGW32__)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_mingw"
|
||||||
|
# elif defined(__CYGWIN__)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_gcc_cygwin"
|
||||||
|
# elif defined(__GNUC__)
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_gcc"
|
||||||
|
# else
|
||||||
|
# define PYBIND11_COMPILER_TYPE "_unknown"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Also standard libs
|
||||||
|
#ifndef PYBIND11_STDLIB
|
||||||
|
# if defined(_LIBCPP_VERSION)
|
||||||
|
# define PYBIND11_STDLIB "_libcpp"
|
||||||
|
# elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
|
||||||
|
# define PYBIND11_STDLIB "_libstdcpp"
|
||||||
|
# else
|
||||||
|
# define PYBIND11_STDLIB ""
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility.
|
||||||
|
/// On MSVC, changes in _MSC_VER may indicate ABI incompatibility (#2898).
|
||||||
|
#ifndef PYBIND11_BUILD_ABI
|
||||||
|
# if defined(__GXX_ABI_VERSION)
|
||||||
|
# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION)
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# define PYBIND11_BUILD_ABI "_mscver" PYBIND11_TOSTRING(_MSC_VER)
|
||||||
|
# else
|
||||||
|
# define PYBIND11_BUILD_ABI ""
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PYBIND11_INTERNALS_KIND
|
||||||
|
# define PYBIND11_INTERNALS_KIND ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PYBIND11_PLATFORM_ABI_ID \
|
||||||
|
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \
|
||||||
|
PYBIND11_BUILD_TYPE
|
Loading…
Reference in New Issue
Block a user