godot-cpp icon indicating copy to clipboard operation
godot-cpp copied to clipboard

Avoid `thread_local` on MacOS to prevent issues with hot reload

Open dsnopek opened this issue 1 year ago • 1 comments

Fixes https://github.com/godotengine/godot-cpp/issues/1573

~~This isn't quite right yet. I think the lock_guard for reload is in the right place, but the one in Wrapped::_set_construct_info() is wrong. We need to lock around the whole memnew() operation, not just the part where we set those variables. I'm not sure the best way to do that yet.~~

UPDATE: This might be OK now. I need to get a good test.

This depends on PR https://github.com/godotengine/godot-cpp/pull/1590 because it adds another thread_local, and this way we can address that one too

dsnopek avatar Sep 17 '24 20:09 dsnopek

Now that PR https://github.com/godotengine/godot-cpp/pull/1590 is merged, taking this one out of draft!

dsnopek avatar Oct 17 '24 14:10 dsnopek

Cherry-picked for 4.3 in PR https://github.com/godotengine/godot-cpp/pull/1695

dsnopek avatar Jan 27 '25 23:01 dsnopek

FYI, this PR broke my GDExtension code on macOS, causing the following linker errors:

Linking game.dylib
Undefined symbols for architecture arm64:
  "thread-local wrapper routine for godot::Wrapped::_constructing_extension_class_name", referenced from:
    ...
  "thread-local wrapper routine for godot::Wrapped::_constructing_class_binding_callbacks", referenced from:
    ...

ld: symbol(s) not found for architecture arm64

I've resolved the issue for now by passing the option "use_hot_reload=no" to scons when building godot-cpp.

ArdaE avatar Apr 25 '25 04:04 ArdaE

FYI, this PR broke my GDExtension code on macOS, causing the following linker errors:

MacOS builds with hot reload are still working for me. Perhaps doing a scons -c to clean away old build artifacts would help?

dsnopek avatar Jun 16 '25 16:06 dsnopek