Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Building with build_profile containing only Object, Resource and Image fails to link #1674

Open
Zylann opened this issue Dec 19, 2024 · 0 comments

Comments

@Zylann
Copy link
Collaborator

Zylann commented Dec 19, 2024

Godot version

4.4

godot-cpp version

27ffd8c

System information

Windows, 64-bit, MSVC

Issue description

I started using a build_profile restricting classes to the following:

{
    "enabled_classes": [
        "Object",
        "Resource",
        "Image"
    ]
}

First I was surprised at the sheer amount of classes it still tried to build, only to realize Resource has a method returning a Node*, so I guess it tried to include Node too, which then refers to Window, which refers to Theme, which refers to a bunch of other things.

But then, it fails to link:
https://github.com/Zylann/godot_fast_noise_2/actions/runs/12416475481/job/34665187777

Linking Shared Library project\addons\zylann.fastnoise2\bin\libgdfastnoise2.windows.template_release.x86_64.dll ...
libgodot-cpp.windows.template_release.x86_64.lib(variant.windows.template_release.x86_64.obj) : error LNK2001: unresolved external symbol "public: virtual struct godot::AABB __cdecl godot::VisualInstance3D::_get_aabb(void)const " (?_get_aabb@VisualInstance3D@godot@@UEBA?AUAABB@2@XZ)
libgodot-cpp.windows.template_release.x86_64.lib(variant_internal.windows.template_release.x86_64.obj) : error LNK2001: unresolved external symbol "public: virtual struct godot::AABB __cdecl godot::VisualInstance3D::_get_aabb(void)const " (?_get_aabb@VisualInstance3D@godot@@UEBA?AUAABB@2@XZ)
project\addons\zylann.fastnoise2\bin\libgdfastnoise2.windows.template_release.x86_64.dll : fatal error LNK1120: 1 unresolved externals
scons: *** [project\addons\zylann.fastnoise2\bin\libgdfastnoise2.windows.template_release.x86_64.dll] Error 1120
scons: building terminated because of errors.

Somehow it got to compile code that calls VisualInstance3D::_get_aabb, but my extension doesn't even use nodes.

To workaround it, I have to add VisualInstance3D to the profile (which in total builds 63 classes, so still a good win compared to 744, but far from the 3 I actually use).

For sure maybe a fix should be done to detect that VisualInstance3D is also needed somehow.
But I think that class list is doing too much. Too many classes are picked. Yes, Resource has a method that returns Node. But I don't need to compile Node, because I don't use it, and Node is forward-declared anyways. So GodotCpp should not try to include it to classes it has to compile.
The only classes GodotCpp should implicitely generate, are classes that need to be defined. So pretty much base classes, AFAIK. The rest should not need to be defined (such as methods taking objects or returning objects, because those are forward-declared).

Steps to reproduce

Compile GodotCpp on Windows with the listed build profile.

Minimal reproduction project

N.A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant