mirror of
https://github.com/pybind/pybind11.git
synced 2025-02-16 13:47:53 +00:00
Make static internals ptr pybind version specific
Under gcc, the `static internals *internals_ptr` is shared across .so's, which breaks for obvious reasons. This commit fixes it by moving the static pointer declaration into a pybind-version-templated function.
This commit is contained in:
parent
731a9f6cea
commit
a4d0d95e2e
@ -43,8 +43,15 @@ struct type_info {
|
||||
bool default_holder : 1;
|
||||
};
|
||||
|
||||
// Store the static internals pointer in a version-specific function so that we're guaranteed it
|
||||
// will be distinct for modules compiled for different pybind11 versions. Without this, some
|
||||
// compilers (i.e. gcc) can use the same static pointer storage location across different .so's,
|
||||
// even though the `get_internals()` function itself is local to each shared object.
|
||||
template <int = PYBIND11_VERSION_MAJOR, int = PYBIND11_VERSION_MINOR>
|
||||
internals *&get_internals_ptr() { static internals *internals_ptr = nullptr; return internals_ptr; }
|
||||
|
||||
PYBIND11_NOINLINE inline internals &get_internals() {
|
||||
static internals *internals_ptr = nullptr;
|
||||
internals *&internals_ptr = get_internals_ptr();
|
||||
if (internals_ptr)
|
||||
return *internals_ptr;
|
||||
handle builtins(PyEval_GetBuiltins());
|
||||
|
Loading…
Reference in New Issue
Block a user