Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unable to recreate GDExtension instance with hot reloading enabled #1673

Open
LouChiSoft opened this issue Dec 13, 2024 · 8 comments
Open

Unable to recreate GDExtension instance with hot reloading enabled #1673

LouChiSoft opened this issue Dec 13, 2024 · 8 comments
Labels
Milestone

Comments

@LouChiSoft
Copy link

LouChiSoft commented Dec 13, 2024

Godot version

4.3-stable (Double precision)

godot-cpp version

4.3-stable (Double precision)

System information

Windows 10, R9 7900, RX 7900XT

Issue description

Debug compile for Windows 10, using CMake included via FetchContent and enabling hot reloading via GODOT_ENABLE_HOT_RELOAD set to ON or YES results in a Unable to recreate GDExtension instance - does this extension support hot reloading? error when rebuilding the project.

I've verified that the gdextension file has reloading enabled by adding a status message to the godot-cpp cmake file to print out the value of GODOT_ENABLE_HOT_RELOAD and make sure that it propagates from the top level which it does.

Steps to reproduce

  • Clone this project: https://github.com/LouChiSoft/GDFlecs
  • Optional: Add a status print to the godot-cpp CMakeLists.txt inside the build folder and print the value of GODOT_ENABLE_HOT_RELOAD from inside the CMakeLists to ensure that the value is set properly
  • Configure with: cmake -B ./build -DPRECISION="double"
  • Build with: cmake --build ./build --config Debug --parallel *desired thread count*
  • Run with Godot 4.3.stable.double
  • Make a code change and rebuild
  • Make Godot the active window and Unable to recreate GDExtension instance - does this extension support hot reloading? should be in the output

Minimal reproduction project

https://github.com/LouChiSoft/GDFlecs

@LouChiSoft
Copy link
Author

Hi, I was wondering if anyone had managed to have a look at this yet?

@dsnopek
Copy link
Collaborator

dsnopek commented Dec 20, 2024

It sounds like HOT_RELOAD_ENABLED isn't defined when building your extension. I had thought the cmake configuration in the 4.3 branch did do that, but I haven't had a chance to double check

@LouChiSoft
Copy link
Author

Is HOT_RELOAD_ENABLED different from GODOT_ENABLE_HOT_RELOAD? GODOT_ENABLE_HOT_RELOAD is the one in the comments at the top of the CMake file for Godot-cpp

@enetheru
Copy link
Collaborator

enetheru commented Jan 12, 2025

@LouChiSoft

in CMake:
GODOT_ENABLE_HOT_RELOAD is not a valid flag, and is not used anywhere.

GODOT_USE_HOT_RELOAD is the option for the cmake build, can be specified as part of the cmake configuration process like
cmake <path to source> -DGODOT_HOT_RELOAD=ON or added to your cmake scripts, or in a preset file, etc..

HOT_RELOAD_ENABLED is the cpp define added to the compiler command when compiling the extension, however it may not be the only thing needed to create a hot-reloadable library, for example gcc requires -fno-gnu-unique (After reviewing the build tools it appears to be the only other requirement).

In SCons the equivalent flag is use_hot_reload

@enetheru
Copy link
Collaborator

also, if the flag is not specified, then only the template_debug and editor builds define HOT_RELOAD_ENABLED

@LouChiSoft
Copy link
Author

GODOT_ENABLE_HOT_RELOAD is not a valid flag, and is not used anywhere.

Are you sure, I literally copied it from the CMakeLists.txt file from within the _deps folder for godot-cpp in my build folder. Screenshot from git tag godot-4.3-stable:

Image

for example gcc requires -fno-gnu-unique (After reviewing the build tools it appears to be the only other requirement).

For now I am using MSVC and Windows, do you know of any MSVC specific flags I need to use?

@enetheru
Copy link
Collaborator

Are you sure, I literally copied it from the CMakeLists.txt file from within the _deps folder for godot-cpp in my build folder. Screenshot from git tag godot-4.3-stable:

My bad, I was thinking master branch, sorry.

The old 4.3 and lower cmake code is so bad it was the reason I decided to contribute.

I can offer no help it's that bad, and recommend backporting all cmake/build system related changes from master instead. Fingers crossed it all gets cherry picked in the future. I maintain my own branch of 4.3 with backported changes for this reason.

@LouChiSoft
Copy link
Author

Ah, I can see where the confusion came from then. If the CMake for 4.3 is really that bad I will take a look at the main. Although 4.4 might have come out by the time I am free to work on my project again. Hopefully with 4.4 it will be easier to setup

@dsnopek dsnopek added the cmake label Jan 21, 2025
@dsnopek dsnopek added this to the 4.x milestone Jan 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants