From d7681b23d3133109be661c9222626159aa18424b Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 15 Sep 2019 20:24:31 +0200 Subject: [PATCH 1/5] notify: fix ABI incompatibility with NDEBUG on Windows On MSVC (not with GCC/clang), adding `static` changes the mangled symbol name, so we shouldn't add that when building with NDEBUG. On GCC/clang, it doesn't, but adding `const` does, and C++11 rules make `constexpr` methods implicitly `const`, so I've removed the `constexpr` variants from NotifyCategoryProxy for now. Hopefully the compiler is still smart enough to compile out any references when compiling with NDEBUG. --- dtool/src/prc/notifyCategory.h | 4 ++-- dtool/src/prc/notifyCategoryProxy.I | 12 ++++++++---- dtool/src/prc/notifyCategoryProxy.h | 5 ----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index 9a2a9fa4e2..db767336b1 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -55,8 +55,8 @@ PUBLISHED: INLINE bool is_spam() const; INLINE bool is_debug() const; #else - constexpr static bool is_spam() { return false; } - constexpr static bool is_debug() { return false; } + constexpr bool is_spam() const { return false; } + constexpr bool is_debug() const { return false; } #endif INLINE bool is_info() const; INLINE bool is_warning() const; diff --git a/dtool/src/prc/notifyCategoryProxy.I b/dtool/src/prc/notifyCategoryProxy.I index fbdac1f0ca..ddd10b772d 100644 --- a/dtool/src/prc/notifyCategoryProxy.I +++ b/dtool/src/prc/notifyCategoryProxy.I @@ -65,26 +65,30 @@ is_on(NotifySeverity severity) { /** * */ -#ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: is_spam() { +#ifdef NOTIFY_DEBUG // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_spam()); -} +#else + return false; #endif +} /** * */ -#ifdef NOTIFY_DEBUG template INLINE bool NotifyCategoryProxy:: is_debug() { +#ifdef NOTIFY_DEBUG // Instruct the compiler to optimize for the usual case. return UNLIKELY(get_unsafe_ptr()->is_debug()); -} +#else + return false; #endif +} /** * diff --git a/dtool/src/prc/notifyCategoryProxy.h b/dtool/src/prc/notifyCategoryProxy.h index 5465529583..5ca79a6594 100644 --- a/dtool/src/prc/notifyCategoryProxy.h +++ b/dtool/src/prc/notifyCategoryProxy.h @@ -71,13 +71,8 @@ public: INLINE bool is_on(NotifySeverity severity); -#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) INLINE bool is_spam(); INLINE bool is_debug(); -#else - constexpr static bool is_spam() { return false; } - constexpr static bool is_debug() { return false; } -#endif INLINE bool is_info(); INLINE bool is_warning(); INLINE bool is_error(); From 5a23821ac1cc8e5ed021f2c32af474e2b6caaa1e Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 16 Sep 2019 03:27:22 +0200 Subject: [PATCH 2/5] notify: work around GCC 4.7 compilation issue with constexpr This can be reverted on master if we can verify that it does work with GCC 4.8. --- dtool/src/prc/notifyCategory.I | 10 ++++++++-- dtool/src/prc/notifyCategory.h | 5 ----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dtool/src/prc/notifyCategory.I b/dtool/src/prc/notifyCategory.I index 20678fbace..74c1965778 100644 --- a/dtool/src/prc/notifyCategory.I +++ b/dtool/src/prc/notifyCategory.I @@ -64,14 +64,17 @@ is_on(NotifySeverity severity) const { return (int)severity >= (int)get_severity(); } -#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) /** * A shorthand way to write is_on(NS_spam). */ INLINE bool NotifyCategory:: is_spam() const { +#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) // Instruct the compiler to optimize for the usual case. return UNLIKELY(is_on(NS_spam)); +#else + return false; +#endif } /** @@ -79,10 +82,13 @@ is_spam() const { */ INLINE bool NotifyCategory:: is_debug() const { +#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) // Instruct the compiler to optimize for the usual case. return UNLIKELY(is_on(NS_debug)); -} +#else + return false; #endif +} /** * A shorthand way to write is_on(NS_info). diff --git a/dtool/src/prc/notifyCategory.h b/dtool/src/prc/notifyCategory.h index db767336b1..96d2897921 100644 --- a/dtool/src/prc/notifyCategory.h +++ b/dtool/src/prc/notifyCategory.h @@ -51,13 +51,8 @@ PUBLISHED: // to present a consistent interface to our scripting language, so during // the interrogate pass (that is, when CPPPARSER is defined), we still // pretend they're nonstatic. -#if defined(NOTIFY_DEBUG) || defined(CPPPARSER) INLINE bool is_spam() const; INLINE bool is_debug() const; -#else - constexpr bool is_spam() const { return false; } - constexpr bool is_debug() const { return false; } -#endif INLINE bool is_info() const; INLINE bool is_warning() const; INLINE bool is_error() const; From f4926bff20e9abbc3a4f41d2c91285eb803fffe0 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 16 Sep 2019 03:31:11 +0200 Subject: [PATCH 3/5] Fix a variety of ABI compatibility issues We need third-party extensions that link with the Panda3D libraries to continue to work when shipping them with the optimized libraries that deploy-ng uses. To do this, we need the optimized build not to omit symbols that these extensions might depend on. --- dtool/src/dtoolbase/memoryBase.h | 8 ----- panda/src/express/dcast.cxx | 4 +-- panda/src/express/dcast.h | 6 ++-- panda/src/pstatclient/pStatClient.cxx | 44 +++++++++++++++++++++++++-- panda/src/pstatclient/pStatClient.h | 26 ++++++++++++++++ 5 files changed, 73 insertions(+), 15 deletions(-) diff --git a/dtool/src/dtoolbase/memoryBase.h b/dtool/src/dtoolbase/memoryBase.h index b6545ff66e..d1d9f00ca5 100644 --- a/dtool/src/dtoolbase/memoryBase.h +++ b/dtool/src/dtoolbase/memoryBase.h @@ -23,8 +23,6 @@ // MemoryBase; this macro is provided to resolve problems with multiple // inheritance or some such. -#ifndef USE_MEMORY_NOWRAPPERS - #define ALLOC_MEMORY_BASE \ inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \ return PANDA_MALLOC_SINGLE(size); \ @@ -51,12 +49,6 @@ inline void operator delete[](void *, void *) { \ } -#else // USE_MEMORY_NOWRAPPERS - -#define ALLOC_MEMORY_BASE - -#endif // USE_MEMORY_NOWRAPPERS - /** * This class is intended to be the base class of all objects in Panda that * might be allocated and deleted via the new and delete operators. It diff --git a/panda/src/express/dcast.cxx b/panda/src/express/dcast.cxx index 63265fec6f..890468588b 100644 --- a/panda/src/express/dcast.cxx +++ b/panda/src/express/dcast.cxx @@ -21,7 +21,6 @@ #include // for IsBadWritePtr() #endif -#ifdef DO_DCAST /** * This function performs the actual check that the indicated TypedObject * pointer is of the intended type. @@ -29,6 +28,7 @@ bool _dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr) { +#ifdef DO_DCAST if (get_verify_dcast()) { if (ptr == nullptr) { // This is allowed these days. It used to be an error, but what the @@ -54,7 +54,7 @@ _dcast_verify(TypeHandle want_handle, size_t want_size, return false; } } +#endif // DO_DCAST return true; } -#endif // DO_DCAST diff --git a/panda/src/express/dcast.h b/panda/src/express/dcast.h index a234f2bbc7..db27852671 100644 --- a/panda/src/express/dcast.h +++ b/panda/src/express/dcast.h @@ -62,12 +62,12 @@ INLINE WantType *_dcast_ref(WantType *&, TypedObject *ptr); template INLINE const WantType *_dcast_ref(WantType *&, const TypedObject *ptr); -#ifdef DO_DCAST -// _dcast_verify performs the actual verification. +// _dcast_verify performs the actual verification. This is an empty function +// when DO_DCAST is not set, but we still need to define it for ABI +// compatibility reasons. EXPCL_PANDA_EXPRESS bool _dcast_verify(TypeHandle want_handle, size_t want_size, const TypedObject *ptr); -#endif // DO_DCAST #define DCAST_INTO_V(to_pointer, from_pointer) \ { \ diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index a0ddb2ae38..606801e124 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -12,6 +12,8 @@ */ #include "pStatClient.h" +#include "pStatCollector.h" +#include "pStatThread.h" #ifdef DO_PSTATS // This file only defines anything interesting if DO_PSTATS is defined. @@ -19,8 +21,6 @@ #include "pStatClientImpl.h" #include "pStatClientControlMessage.h" #include "pStatServerControlMessage.h" -#include "pStatCollector.h" -#include "pStatThread.h" #include "config_pstatclient.h" #include "pStatProperties.h" #include "thread.h" @@ -1222,4 +1222,44 @@ InternalThread(const string &name, const string &sync_name) : { } +#else // DO_PSTATS + +PStatThread PStatClient:: +get_main_thread() const { + return PStatThread((PStatClient *)this, 0); +} + +PStatThread PStatClient:: +get_current_thread() const { + return get_main_thread(); +} + +PStatCollector PStatClient:: +make_collector_with_relname(int parent_index, std::string relname) { + return PStatCollector(); +} + +PStatClient *PStatClient:: +get_global_pstats() { + static PStatClient global_pstats; + return &global_pstats; +} + +void PStatClient:: +start(int collector_index, int thread_index) { +} + +void PStatClient:: +start(int collector_index, int thread_index, double as_of) { +} + +void PStatClient:: +stop(int collector_index, int thread_index) { +} + +void PStatClient:: +stop(int collector_index, int thread_index, double as_of) { +} + + #endif // DO_PSTATS diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index bdcdb4eb20..2d7e76f2bb 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -266,6 +266,12 @@ public: ~PStatClient() { } PUBLISHED: + std::string get_collector_name(int index) const { return std::string(); } + std::string get_collector_fullname(int index) const { return std::string(); } + + PStatThread get_main_thread() const; + PStatThread get_current_thread() const; + INLINE static bool connect(const std::string & = std::string(), int = -1) { return false; } INLINE static void disconnect() { } INLINE static bool is_connected() { return false; } @@ -273,6 +279,26 @@ PUBLISHED: INLINE static void main_tick() { } INLINE static void thread_tick(const std::string &) { } + + static PStatClient *get_global_pstats(); + +private: + // These are used by inline PStatCollector methods, so they need to be + // stubbed out for ABI compatibility. + PStatCollector make_collector_with_relname(int parent_index, std::string relname); + + bool is_active(int collector_index, int thread_index) const { return false; } + bool is_started(int collector_index, int thread_index) const { return false; } + + void start(int collector_index, int thread_index); + void start(int collector_index, int thread_index, double as_of); + void stop(int collector_index, int thread_index); + void stop(int collector_index, int thread_index, double as_of); + + void clear_level(int collector_index, int thread_index) { } + void set_level(int collector_index, int thread_index, double level) { } + void add_level(int collector_index, int thread_index, double increment) { } + double get_level(int collector_index, int thread_index) const { return 0.0; } }; #endif // DO_PSTATS From 7fa373bd6a1892cbce58322ae053b1a3b1c322f6 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 16 Sep 2019 21:07:13 +0200 Subject: [PATCH 4/5] makepanda: fix custom --python-incdir and --python-libdir on macOS --- makepanda/makepandacore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 932210f9c7..7040d34851 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -2159,7 +2159,7 @@ def SdkLocatePython(prefer_thirdparty_python=False): SDK["PYTHONEXEC"] = tp_python + "/bin/" + SDK["PYTHONVERSION"] SDK["PYTHON"] = tp_python + "/include/" + SDK["PYTHONVERSION"] - elif GetTarget() == 'darwin': + elif GetTarget() == 'darwin' and not PkgHasCustomLocation("PYTHON"): # On macOS, search for the Python framework directory matching the # version number of our current Python version. sysroot = SDK.get("MACOSX", "") From 343c808fc486063bae05a82b173d915eeb854c58 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 16 Sep 2019 21:08:51 +0200 Subject: [PATCH 5/5] dtoolbase: fix repeated calls to TypeRegistry::ptr() in register_type --- dtool/src/dtoolbase/register_type.I | 68 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/dtool/src/dtoolbase/register_type.I b/dtool/src/dtoolbase/register_type.I index 0bd43e1501..f1108fc0ca 100644 --- a/dtool/src/dtoolbase/register_type.I +++ b/dtool/src/dtoolbase/register_type.I @@ -25,37 +25,41 @@ register_type(TypeHandle &type_handle, const std::string &name) { INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); - TypeRegistry::ptr()->record_derivation(type_handle, parent4); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); + registry->record_derivation(type_handle, parent4); } } @@ -71,40 +75,40 @@ register_dynamic_type(const std::string &name) { } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); - TypeRegistry::ptr()->record_derivation(type_handle, parent4); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); + registry->record_derivation(type_handle, parent4); return type_handle; }