Skip to content

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

Open

Description

@Zylann

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

Activity

  1. enetheru commented on Jan 11, 2025

    @enetheru
    Collaborator

    is this still a problem after #1680 is merged?

  2. Zylann commented on Jan 11, 2025

    @Zylann
    CollaboratorAuthor

    Probably not. The original PR #1675 did fix it, but the implementation changed so I will have to re-test it.

  3. added
    bug
    topic:buildsystem
    on Jan 21, 2025
  4. added this to the 4.x milestone on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtopic:buildsystem

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions