static inline is bad. Generates way too much code that the linker is unable to optimize and remove on final link. This causes these symbols from every class in godot-cpp to be included in the final link, even if completely unused by the lib. Removing changes a basic shared library from being ~1.5MB on almost all platforms to now ~200kB.

pull/1621/head
Jordan Schidlowsky 2024-10-09 15:11:20 -06:00
parent 6facde3c29
commit ddd03ee818
3 changed files with 7 additions and 3 deletions

View File

@ -219,7 +219,7 @@ public:
// Used exclusively in the bindings to recreate the Ref Godot encapsulates in return values, // Used exclusively in the bindings to recreate the Ref Godot encapsulates in return values,
// without adding to the refcount. // without adding to the refcount.
inline static Ref<T> _gde_internal_constructor(Object *obj) { static Ref<T> _gde_internal_constructor(Object *obj) {
Ref<T> r; Ref<T> r;
r.reference = (T *)obj; r.reference = (T *)obj;
return r; return r;

View File

@ -77,7 +77,7 @@ protected:
GDExtensionObjectPtr owner; GDExtensionObjectPtr owner;
RecreateInstance *next; RecreateInstance *next;
}; };
inline static RecreateInstance *recreate_instance = nullptr; static RecreateInstance *recreate_instance;
#endif #endif
void _notification(int p_what) {} void _notification(int p_what) {}
@ -408,7 +408,7 @@ private:
// Don't use this for your classes, use GDCLASS() instead. // Don't use this for your classes, use GDCLASS() instead.
#define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \ #define GDEXTENSION_CLASS_ALIAS(m_class, m_alias_for, m_inherits) /******************************************************************************************************************/ \
private: \ private: \
inline static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \ static ::godot::internal::EngineClassRegistration<m_class> _gde_engine_class_registration_helper; \
void operator=(const m_class &p_rval) {} \ void operator=(const m_class &p_rval) {} \
friend class ::godot::ClassDB; \ friend class ::godot::ClassDB; \
friend class ::godot::Wrapped; \ friend class ::godot::Wrapped; \

View File

@ -42,6 +42,10 @@ namespace godot {
thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr; thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr;
thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr; thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr;
#ifdef HOT_RELOAD_ENABLED
Wrapped::RecreateInstance *Wrapped::recreate_instance = nullptr;
#endif
const StringName *Wrapped::_get_extension_class_name() { const StringName *Wrapped::_get_extension_class_name() {
return nullptr; return nullptr;
} }