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

added ninja tool for scons #52793

Closed
wants to merge 1 commit into from

Conversation

dmoody256
Copy link
Contributor

@dmoody256 dmoody256 commented Sep 17, 2021

This is a project localized version from the scons builtin tool I have in my branch (plus some latest cherry picks from mongodb): https://github.com/dmoody256/scons/tree/ninja_scons_daemon

The origin of this tool has been used extensively in the mognodb build by all its developers over the last several years. This is a bleeding edge version featuring a scons daemon which facilitates callback building to scons. This bleeding edge version will make its way in to scons mainline probably within a few months.

Hopefully godot can start using it and we can flush out any issues so that the mainline version will work out of the box for godot.

Using the tool is simple by just passing use_ninja=yes on the scons build command, and a ninja file will be generated.
From there you can just run ninja to build. Anytime you change a SConstruct or SCsub or generator py files, it should regenerate ninja file automatically.

Note that the scons daemon is launched by ninja and is running scons in the background waiting for ninja to send build commands that only scons know how to deal with. This would be any kind of SCons function action or more complicated actions. The daemon uses the SCons environment variable NINJA_SCONS_DAEMON_KEEP_ALIVE to determine how many seconds the scons daemon should stay awake without receiving a command from ninja. The default is 1800 seconds. A new daemon will be used when the ninja file is regenerated.

Also note this requires using scons 4.2.

Also note that things built directly by ninja will not use SCons cache, but the callback nodes are still able to.

I look forward to providing support and bugfix to any issues the godot devs may find when using this tool.

.gitignore Outdated Show resolved Hide resolved
@dmoody256
Copy link
Contributor Author

dmoody256 commented Sep 17, 2021

@Calinou Should I add a github action for building with ninja?

@Calinou
Copy link
Member

Calinou commented Sep 17, 2021

@Calinou Should I add a github action for building with ninja?

Godot's CI is pretty busy as it is, so I would prefer replacing one of the current CI workflows to use Ninja instead of the default SCons setup.

@dmoody256
Copy link
Contributor Author

Im not that well versed with github actions so hopefully I set it up right.

@dmoody256
Copy link
Contributor Author

okay fixed the ninja ci in
9a61435

@dmoody256
Copy link
Contributor Author

I think also the optimizations for MD5-timestamp and implicit cache should be removed. In my opinion they are not worth it, they save a a very small amount of time but can lead to very painful and time consuming headaches if the user is not fully aware what is going on. With ninja solving the incremental build speed issue, the scons build should be reserved for absolute build correctness.

@akien-mga
Copy link
Member

akien-mga commented Sep 22, 2021

I think also the optimizations for MD5-timestamp and implicit cache should be removed. In my opinion they are not worth it, they save a a very small amount of time but can lead to very painful and time consuming headaches if the user is not fully aware what is going on. With ninja solving the incremental build speed issue, the scons build should be reserved for absolute build correctness.

I would move this to a dedicated PR so that it can be reviewed and merged independently. I do think removing these might be good, they seem to cause more harm than gain.


How does using Ninja impact build time, and caching for CI?

If it's faster on both scratch builds and incremental builds, it might be worth it to switch the whole CI over to using ninja, so that it goes faster. This requires having it play nice with the current SCons cache feature though.

SConstruct Outdated Show resolved Hide resolved
SConstruct Outdated
@@ -1,6 +1,6 @@
#!/usr/bin/env python

EnsureSConsVersion(3, 0, 0)
EnsureSConsVersion(4, 2, 0)
EnsurePythonVersion(3, 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR specifically, but a note to self: SCons 4.2.0 is deprecated Python 3.5 support, so we might want to follow suit and get ready for 4.3.0 by bumping this to 3.6 (and then start porting the codebase to finally benefit from f-strings).

Copy link
Contributor Author

@dmoody256 dmoody256 Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in
d0a5ed1

SConstruct Outdated Show resolved Hide resolved
@dmoody256
Copy link
Contributor Author

I would move this to a dedicated PR so that it can be reviewed and merged independently. I do think removing these might be good, they seem to cause more harm than gain.

Sure, will do.

How does using Ninja impact build time, and caching for CI?

scons testing upstream show that there is not much difference in a clean build, on average ninja is slightly faster (~5%). However this testing is with a very basic C test project. It would be worth doing some comparisons with Godot. I'll get started on that.

If it's faster on both scratch builds and incremental builds, it might be worth it to switch the whole CI over to using ninja, so that it goes faster. This requires having it play nice with the current SCons cache feature though.

The ninja tool does not currently support using scons cache, it is planned feature and I have some ideas how to go about it, but it probably has an ETA of >6 months. In the meantime, the ninja tool does support the ccache tool I PR'ed and made reference to above. Mongodb exclusively uses pure scons builds in its CI to leverage SCons cache. I think it would be advantageous to do the same for Godot. If you really want ninja in the CI for posterity, I would say setting up ccache to work in the CI along with ninja would be a good idea.

@akien-mga
Copy link
Member

Mongodb exclusively uses pure scons builds in its CI to leverage SCons cache. I think it would be advantageous to do the same for Godot. If you really want ninja in the CI for posterity, I would say setting up ccache to work in the CI along with ninja would be a good idea.

That makes sense. I think we should do like mongodb here and not use ninja in CI, at least in this PR. We can reassess once cache support is improved and if it can be made to play nice with the current GitHub Actions cache.

@dmoody256
Copy link
Contributor Author

Some metrics:

Intel(R) Xeon(R) Platinum 8124M CPU @ 3.00GHz (16 cores)
32 GB ram
Ubuntu 18.04
NVM filesystem

command:
scons -j16 verbose=true tools=yes tests=yes target=release_debug warnings=extra werrro=yes debug_symbols=no module_text_server_fb_enabled=yes

ninja:
scons ninja generation: 5.8s
ninja build: 8m9s

pure scons:
8m11s

@dmoody256
Copy link
Contributor Author

dmoody256 commented Sep 22, 2021

That makes sense. I think we should do like mongodb here and not use ninja in CI, at least in this PR. We can reassess once cache support is improved and if it can be made to play nice with the current GitHub Actions cache.

removed ninja CI in
d0a5ed1

Comment on lines +205 to +207
from SCons.Script.Main import _load_site_scons_dir

_load_site_scons_dir(".", "misc/scons")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this way, you can pass env_base.Tool("scons_ninja", toolpath=["misc/scons"]), and this way get rid of the extraneous site_tools/ folder (so it's misc/scons/scons_ninja). misc/scons is our "site_tools" already.


from SCons import __version__ as scons_raw_version

if env_base._get_major_minor_revision(scons_raw_version) >= (4, 2, 0) and sys.version_info >= (3, 6):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The python version check shouldn't be needed after #53829.

@akien-mga
Copy link
Member

akien-mga commented Oct 27, 2021

I rebased this branch on latest master here: https://github.com/akien-mga/godot/tree/add_scons_ninja_tool
And did the couple nitpicks I suggested above.

I also amended the commit message to be somewhat more explicit, as I like the Git history to give relevant details additionally to the PR discussion.

I started doing some testing, my early results are a bit confusing but I'll have to test more thoroughly tomorrow:

  • First ninja build had like 2000 steps and took 13 min
  • Second ninja build (without any change) had ~1000 steps and took 9 min
  • Third ninja build had 70 steps and took 21 s
  • Fourth ninja build and further all had 2 steps and took ~0.2s (what I'd expect of 2nd and 3rd rebuilds too)
  • Then after a git pull --rebase to include two recently merged PRs (which shouldn't have a big impact on incremental rebuild), I got again 1010 steps (though this time I regenerated the ninja.build, maybe I shouldn't have).

Also, the error message when the ninja python module is not installed was not the clearest (mentioned not being able to find ninja binary, which was installed in /usr/bin/ninja). Since it's specifically about the python module I'd suggest changing it and giving a hint to the user that they can install it with pip.

@akien-mga
Copy link
Member

akien-mga commented Oct 28, 2021

My tests yesterday were done while trying to use the fast mold linker instead of GNU gold, which could have impacted the behavior. So now I'm trying with the simplest options scons p=linuxbsd use_ninja=yes to avoid interference from other things. Not using any cache system either, just plain in-place build.

Here's what I did and got as result:

$ scons p=linuxbsd use_ninja=yes
$ ninja  // 2059 steps
$ ninja  // 880 steps
$ ninja  // 934 steps
$ ninja  // 818 steps, giving up...
$ ninja  // 818 steps again, giving up...

I did not touch any file between each ninja call, so I'm a bit puzzled by the results.

Full logs
[akien@cauldron godot.git (add_scons_ninja_tool)]$ scons p=linuxbsd use_ninja=yes
/usr/bin/scons p=linuxbsd use_ninja=yes 2>&1 | tee -a build.log
scons: Reading SConscript files ...
Note: Building a debug binary (which will run slowly). Use `target=release_debug` to build an optimized release binary.
Checking for C header file mntent.h... yes
scons: done reading SConscript files.
scons: Building targets ...
Generating: build.ninja
scons: done building targets.
[Time elapsed: 00:00:05.650]

[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[1/1] Reconnect depfile to build.ninja
[176/2059] Compiling core/object/method_bind.linuxbsd.tools.64.o
core/object/method_bind.cpp:42:2: warning: #warning This needs proper class name and argument type for hashing [-Wcpp]
   42 | #warning This needs proper class name and argument type for hashing
      |  ^~~~~~~
[252/2059] Compiling editor/create_dialog.linuxbsd.tools.64.o
editor/create_dialog.cpp:689:2: warning: #warning cannot forward drag data to a non control, must be fixed [-Wcpp]
  689 | #warning cannot forward drag data to a non control, must be fixed
      |  ^~~~~~~
[303/2059] Compiling editor/editor_node.linuxbsd.tools.64.o
editor/editor_node.cpp:6625:2: warning: #warning needs to be reimplemented [-Wcpp]
 6625 | #warning needs to be reimplemented
      |  ^~~~~~~
[377/2059] Compiling editor/plugins/node_3d_editor_plugin.linuxbsd.tools.64.o
editor/plugins/node_3d_editor_plugin.cpp:4370:2: warning: #warning this needs to be fixed [-Wcpp]
 4370 | #warning this needs to be fixed
      |  ^~~~~~~
[415/2059] Compiling editor/project_export.linuxbsd.tools.64.o
editor/project_export.cpp:1036:2: warning: #warning must reimplement drag forward [-Wcpp]
 1036 | #warning must reimplement drag forward
      |  ^~~~~~~
[560/2059] Compiling modules/gltf/gltf_document.linuxbsd.tools.64.o
modules/gltf/gltf_document.cpp:2535:2: warning: #warning line loop and triangle fan are not supported and need to be converted to lines and triangles [-Wcpp]
 2535 | #warning line loop and triangle fan are not supported and need to be converted to lines and triangles
      |  ^~~~~~~
[638/2059] Compiling platform/linuxbsd/display_server_x11.linuxbsd.tools.64.o
platform/linuxbsd/display_server_x11.cpp:791:2: warning: #warning Need to get from proper window [-Wcpp]
  791 | #warning Need to get from proper window
      |  ^~~~~~~
platform/linuxbsd/display_server_x11.cpp:4044:2: warning: #warning Forcing vulkan rendering driver because OpenGL not implemented yet [-Wcpp]
 4044 | #warning Forcing vulkan rendering driver because OpenGL not implemented yet
      |  ^~~~~~~
[669/2059] Compiling scene/2d/sprite_2d.linuxbsd.tools.64.o
scene/2d/sprite_2d.cpp:318:2: warning: #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that) [-Wcpp]
  318 | #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
      |  ^~~~~~~
[675/2059] Compiling scene/2d/skeleton_2d.linuxbsd.tools.64.o
scene/2d/skeleton_2d.cpp:192:2: warning: #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin [-Wcpp]
  192 | #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
      |  ^~~~~~~
[741/2059] Compiling scene/gui/color_picker.linuxbsd.tools.64.o
scene/gui/color_picker.cpp:1042:2: warning: #warning show modal no longer works, needs to be converted to a popup [-Wcpp]
 1042 | #warning show modal no longer works, needs to be converted to a popup
      |  ^~~~~~~
[869/2059] Compiling servers/rendering/renderer_rd/pipeline_cache_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/pipeline_cache_rd.cpp:74:2: warning: #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion [-Wcpp]
   74 | #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
      |  ^~~~~~~
[877/2059] Compiling servers/rendering/renderer_rd/renderer_compositor_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_compositor_rd.cpp:107:2: warning: #warning TODO: likely pass a bool to swap buffers to avoid display? [-Wcpp]
  107 | #warning TODO: likely pass a bool to swap buffers to avoid display?
      |  ^~~~~~~
[879/2059] Compiling servers/rendering/renderer_rd/renderer_canvas_render_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp:1053:2: warning: #warning TODO obtain from framebuffer format eventually when this is implemented [-Wcpp]
 1053 | #warning TODO obtain from framebuffer format eventually when this is implemented
      |  ^~~~~~~
[896/2059] Compiling servers/rendering/renderer_rd/renderer_storage_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_storage_rd.cpp:195:2: warning: #warning TODO need to make a function in Image to swap bits for this [-Wcpp]
  195 | #warning TODO need to make a function in Image to swap bits for this
      |  ^~~~~~~
servers/rendering/renderer_rd/renderer_storage_rd.cpp:5485:2: warning: #warning Should use display refresh rate for all this [-Wcpp]
 5485 | #warning Should use display refresh rate for all this
      |  ^~~~~~~
[1705/2059] Compiling scene/resources/animation.linuxbsd.tools.64.o
scene/resources/animation.cpp:4043:2: warning: #warning Debugging packet push, disable this code in production to gain a bit more import performance. [-Wcpp]
 4043 | #warning Debugging packet push, disable this code in production to gain a bit more import performance.
      |  ^~~~~~~
scene/resources/animation.cpp:4712:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4712 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4857:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4857 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4929:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4929 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4965:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4965 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
[1724/2059] Compiling scene/resources/mesh.linuxbsd.tools.64.o
scene/resources/mesh.cpp:1306:2: warning: #warning need to add binding to add_surface using future MeshSurfaceData object [-Wcpp]
 1306 | #warning need to add binding to add_surface using future MeshSurfaceData object
      |  ^~~~~~~
[1800/2059] Compiling scene/resources/visual_shader.linuxbsd.tools.64.o
scene/resources/visual_shader.cpp:1242:2: warning: #warning everything needs to be cleared here [-Wcpp]
 1242 | #warning everything needs to be cleared here
      |  ^~~~~~~
[2057/2059] Compiling drivers/vulkan/rendering_device_vulkan.linuxbsd.tools.64.o
drivers/vulkan/rendering_device_vulkan.cpp:1708:2: warning: #warning TODO check for support via RenderingDevice to enable on mobile when possible [-Wcpp]
 1708 | #warning TODO check for support via RenderingDevice to enable on mobile when possible
      |  ^~~~~~~
[2059/2059] Linking bin/godot.linuxbsd.tools.64
[171/880] Compiling drivers/vulkan/rendering_device_vulkan.linuxbsd.tools.64.o
drivers/vulkan/rendering_device_vulkan.cpp:1708:2: warning: #warning TODO check for support via RenderingDevice to enable on mobile when possible [-Wcpp]
 1708 | #warning TODO check for support via RenderingDevice to enable on mobile when possible
      |  ^~~~~~~
[175/880] Compiling editor/create_dialog.linuxbsd.tools.64.o
editor/create_dialog.cpp:689:2: warning: #warning cannot forward drag data to a non control, must be fixed [-Wcpp]
  689 | #warning cannot forward drag data to a non control, must be fixed
      |  ^~~~~~~
[233/880] Compiling editor/editor_node.linuxbsd.tools.64.o
editor/editor_node.cpp:6625:2: warning: #warning needs to be reimplemented [-Wcpp]
 6625 | #warning needs to be reimplemented
      |  ^~~~~~~
[308/880] Compiling editor/plugins/node_3d_editor_plugin.linuxbsd.tools.64.o
editor/plugins/node_3d_editor_plugin.cpp:4370:2: warning: #warning this needs to be fixed [-Wcpp]
 4370 | #warning this needs to be fixed
      |  ^~~~~~~
[341/880] Compiling editor/project_export.linuxbsd.tools.64.o
editor/project_export.cpp:1036:2: warning: #warning must reimplement drag forward [-Wcpp]
 1036 | #warning must reimplement drag forward
      |  ^~~~~~~
[458/880] Compiling modules/gltf/gltf_document.linuxbsd.tools.64.o
modules/gltf/gltf_document.cpp:2535:2: warning: #warning line loop and triangle fan are not supported and need to be converted to lines and triangles [-Wcpp]
 2535 | #warning line loop and triangle fan are not supported and need to be converted to lines and triangles
      |  ^~~~~~~
[582/880] Compiling platform/linuxbsd/display_server_x11.linuxbsd.tools.64.o
platform/linuxbsd/display_server_x11.cpp:791:2: warning: #warning Need to get from proper window [-Wcpp]
  791 | #warning Need to get from proper window
      |  ^~~~~~~
platform/linuxbsd/display_server_x11.cpp:4044:2: warning: #warning Forcing vulkan rendering driver because OpenGL not implemented yet [-Wcpp]
 4044 | #warning Forcing vulkan rendering driver because OpenGL not implemented yet
      |  ^~~~~~~
[616/880] Compiling scene/2d/sprite_2d.linuxbsd.tools.64.o
scene/2d/sprite_2d.cpp:318:2: warning: #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that) [-Wcpp]
  318 | #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
      |  ^~~~~~~
[620/880] Compiling scene/2d/skeleton_2d.linuxbsd.tools.64.o
scene/2d/skeleton_2d.cpp:192:2: warning: #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin [-Wcpp]
  192 | #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
      |  ^~~~~~~
[684/880] Compiling scene/gui/color_picker.linuxbsd.tools.64.o
scene/gui/color_picker.cpp:1042:2: warning: #warning show modal no longer works, needs to be converted to a popup [-Wcpp]
 1042 | #warning show modal no longer works, needs to be converted to a popup
      |  ^~~~~~~
[754/880] Compiling scene/resources/mesh.linuxbsd.tools.64.o
scene/resources/mesh.cpp:1306:2: warning: #warning need to add binding to add_surface using future MeshSurfaceData object [-Wcpp]
 1306 | #warning need to add binding to add_surface using future MeshSurfaceData object
      |  ^~~~~~~
[803/880] Compiling scene/resources/visual_shader.linuxbsd.tools.64.o
scene/resources/visual_shader.cpp:1242:2: warning: #warning everything needs to be cleared here [-Wcpp]
 1242 | #warning everything needs to be cleared here
      |  ^~~~~~~
[839/880] Compiling servers/rendering/renderer_rd/pipeline_cache_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/pipeline_cache_rd.cpp:74:2: warning: #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion [-Wcpp]
   74 | #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
      |  ^~~~~~~
[846/880] Compiling servers/rendering/renderer_rd/renderer_compositor_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_compositor_rd.cpp:107:2: warning: #warning TODO: likely pass a bool to swap buffers to avoid display? [-Wcpp]
  107 | #warning TODO: likely pass a bool to swap buffers to avoid display?
      |  ^~~~~~~
[847/880] Compiling servers/rendering/renderer_rd/renderer_canvas_render_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp:1053:2: warning: #warning TODO obtain from framebuffer format eventually when this is implemented [-Wcpp]
 1053 | #warning TODO obtain from framebuffer format eventually when this is implemented
      |  ^~~~~~~
[863/880] Compiling servers/rendering/renderer_rd/renderer_storage_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_storage_rd.cpp:195:2: warning: #warning TODO need to make a function in Image to swap bits for this [-Wcpp]
  195 | #warning TODO need to make a function in Image to swap bits for this
      |  ^~~~~~~
servers/rendering/renderer_rd/renderer_storage_rd.cpp:5485:2: warning: #warning Should use display refresh rate for all this [-Wcpp]
 5485 | #warning Should use display refresh rate for all this
      |  ^~~~~~~
[880/880] Linking bin/godot.linuxbsd.tools.64

[143/934] Compiling drivers/vulkan/rendering_device_vulkan.linuxbsd.tools.64.o
drivers/vulkan/rendering_device_vulkan.cpp:1708:2: warning: #warning TODO check for support via RenderingDevice to enable on mobile when possible [-Wcpp]
 1708 | #warning TODO check for support via RenderingDevice to enable on mobile when possible
      |  ^~~~~~~
[146/934] Compiling editor/create_dialog.linuxbsd.tools.64.o
editor/create_dialog.cpp:689:2: warning: #warning cannot forward drag data to a non control, must be fixed [-Wcpp]
  689 | #warning cannot forward drag data to a non control, must be fixed
      |  ^~~~~~~
[198/934] Compiling editor/editor_node.linuxbsd.tools.64.o
editor/editor_node.cpp:6625:2: warning: #warning needs to be reimplemented [-Wcpp]
 6625 | #warning needs to be reimplemented
      |  ^~~~~~~
[279/934] Compiling editor/plugins/node_3d_editor_plugin.linuxbsd.tools.64.o
editor/plugins/node_3d_editor_plugin.cpp:4370:2: warning: #warning this needs to be fixed [-Wcpp]
 4370 | #warning this needs to be fixed
      |  ^~~~~~~
[315/934] Compiling editor/project_export.linuxbsd.tools.64.o
editor/project_export.cpp:1036:2: warning: #warning must reimplement drag forward [-Wcpp]
 1036 | #warning must reimplement drag forward
      |  ^~~~~~~
[438/934] Compiling modules/gltf/gltf_document.linuxbsd.tools.64.o
modules/gltf/gltf_document.cpp:2535:2: warning: #warning line loop and triangle fan are not supported and need to be converted to lines and triangles [-Wcpp]
 2535 | #warning line loop and triangle fan are not supported and need to be converted to lines and triangles
      |  ^~~~~~~
[581/934] Compiling platform/linuxbsd/display_server_x11.linuxbsd.tools.64.o
platform/linuxbsd/display_server_x11.cpp:791:2: warning: #warning Need to get from proper window [-Wcpp]
  791 | #warning Need to get from proper window
      |  ^~~~~~~
platform/linuxbsd/display_server_x11.cpp:4044:2: warning: #warning Forcing vulkan rendering driver because OpenGL not implemented yet [-Wcpp]
 4044 | #warning Forcing vulkan rendering driver because OpenGL not implemented yet
      |  ^~~~~~~
[614/934] Compiling scene/2d/sprite_2d.linuxbsd.tools.64.o
scene/2d/sprite_2d.cpp:318:2: warning: #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that) [-Wcpp]
  318 | #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
      |  ^~~~~~~
[619/934] Compiling scene/2d/skeleton_2d.linuxbsd.tools.64.o
scene/2d/skeleton_2d.cpp:192:2: warning: #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin [-Wcpp]
  192 | #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
      |  ^~~~~~~
[684/934] Compiling scene/gui/color_picker.linuxbsd.tools.64.o
scene/gui/color_picker.cpp:1042:2: warning: #warning show modal no longer works, needs to be converted to a popup [-Wcpp]
 1042 | #warning show modal no longer works, needs to be converted to a popup
      |  ^~~~~~~
[733/934] Compiling scene/resources/animation.linuxbsd.tools.64.o
scene/resources/animation.cpp:4043:2: warning: #warning Debugging packet push, disable this code in production to gain a bit more import performance. [-Wcpp]
 4043 | #warning Debugging packet push, disable this code in production to gain a bit more import performance.
      |  ^~~~~~~
scene/resources/animation.cpp:4712:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4712 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4857:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4857 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4929:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4929 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
scene/resources/animation.cpp:4965:2: warning: #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported [-Wcpp]
 4965 | #warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
      |  ^~~~~~~
[762/934] Compiling scene/resources/mesh.linuxbsd.tools.64.o
scene/resources/mesh.cpp:1306:2: warning: #warning need to add binding to add_surface using future MeshSurfaceData object [-Wcpp]
 1306 | #warning need to add binding to add_surface using future MeshSurfaceData object
      |  ^~~~~~~
[819/934] Compiling scene/resources/visual_shader.linuxbsd.tools.64.o
scene/resources/visual_shader.cpp:1242:2: warning: #warning everything needs to be cleared here [-Wcpp]
 1242 | #warning everything needs to be cleared here
      |  ^~~~~~~
[886/934] Compiling servers/rendering/renderer_rd/pipeline_cache_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/pipeline_cache_rd.cpp:74:2: warning: #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion [-Wcpp]
   74 | #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
      |  ^~~~~~~
[894/934] Compiling servers/rendering/renderer_rd/renderer_compositor_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_compositor_rd.cpp:107:2: warning: #warning TODO: likely pass a bool to swap buffers to avoid display? [-Wcpp]
  107 | #warning TODO: likely pass a bool to swap buffers to avoid display?
      |  ^~~~~~~
[897/934] Compiling servers/rendering/renderer_rd/renderer_canvas_render_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp:1053:2: warning: #warning TODO obtain from framebuffer format eventually when this is implemented [-Wcpp]
 1053 | #warning TODO obtain from framebuffer format eventually when this is implemented
      |  ^~~~~~~
[911/934] Compiling servers/rendering/renderer_rd/renderer_storage_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_storage_rd.cpp:195:2: warning: #warning TODO need to make a function in Image to swap bits for this [-Wcpp]
  195 | #warning TODO need to make a function in Image to swap bits for this
      |  ^~~~~~~
servers/rendering/renderer_rd/renderer_storage_rd.cpp:5485:2: warning: #warning Should use display refresh rate for all this [-Wcpp]
 5485 | #warning Should use display refresh rate for all this
      |  ^~~~~~~
[934/934] Linking bin/godot.linuxbsd.tools.64

[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[110/818] Compiling drivers/vulkan/rendering_device_vulkan.linuxbsd.tools.64.o
drivers/vulkan/rendering_device_vulkan.cpp:1708:2: warning: #warning TODO check for support via RenderingDevice to enable on mobile when possible [-Wcpp]
 1708 | #warning TODO check for support via RenderingDevice to enable on mobile when possible
      |  ^~~~~~~
[114/818] Compiling editor/create_dialog.linuxbsd.tools.64.o
editor/create_dialog.cpp:689:2: warning: #warning cannot forward drag data to a non control, must be fixed [-Wcpp]
  689 | #warning cannot forward drag data to a non control, must be fixed
      |  ^~~~~~~
[168/818] Compiling editor/editor_node.linuxbsd.tools.64.o
editor/editor_node.cpp:6625:2: warning: #warning needs to be reimplemented [-Wcpp]
 6625 | #warning needs to be reimplemented
      |  ^~~~~~~
[245/818] Compiling editor/plugins/node_3d_editor_plugin.linuxbsd.tools.64.o
editor/plugins/node_3d_editor_plugin.cpp:4370:2: warning: #warning this needs to be fixed [-Wcpp]
 4370 | #warning this needs to be fixed
      |  ^~~~~~~
[280/818] Compiling editor/project_export.linuxbsd.tools.64.o
editor/project_export.cpp:1036:2: warning: #warning must reimplement drag forward [-Wcpp]
 1036 | #warning must reimplement drag forward
      |  ^~~~~~~
[396/818] Compiling modules/gltf/gltf_document.linuxbsd.tools.64.o
modules/gltf/gltf_document.cpp:2535:2: warning: #warning line loop and triangle fan are not supported and need to be converted to lines and triangles [-Wcpp]
 2535 | #warning line loop and triangle fan are not supported and need to be converted to lines and triangles
      |  ^~~~~~~
[520/818] Compiling platform/linuxbsd/display_server_x11.linuxbsd.tools.64.o
platform/linuxbsd/display_server_x11.cpp:791:2: warning: #warning Need to get from proper window [-Wcpp]
  791 | #warning Need to get from proper window
      |  ^~~~~~~
platform/linuxbsd/display_server_x11.cpp:4044:2: warning: #warning Forcing vulkan rendering driver because OpenGL not implemented yet [-Wcpp]
 4044 | #warning Forcing vulkan rendering driver because OpenGL not implemented yet
      |  ^~~~~~~
[553/818] Compiling scene/2d/sprite_2d.linuxbsd.tools.64.o
scene/2d/sprite_2d.cpp:318:2: warning: #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that) [-Wcpp]
  318 | #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
      |  ^~~~~~~
[558/818] Compiling scene/2d/skeleton_2d.linuxbsd.tools.64.o
scene/2d/skeleton_2d.cpp:192:2: warning: #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin [-Wcpp]
  192 | #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
      |  ^~~~~~~
[623/818] Compiling scene/gui/color_picker.linuxbsd.tools.64.o
scene/gui/color_picker.cpp:1042:2: warning: #warning show modal no longer works, needs to be converted to a popup [-Wcpp]
 1042 | #warning show modal no longer works, needs to be converted to a popup
      |  ^~~~~~~
[691/818] Compiling scene/resources/mesh.linuxbsd.tools.64.o
scene/resources/mesh.cpp:1306:2: warning: #warning need to add binding to add_surface using future MeshSurfaceData object [-Wcpp]
 1306 | #warning need to add binding to add_surface using future MeshSurfaceData object
      |  ^~~~~~~
[738/818] Compiling scene/resources/visual_shader.linuxbsd.tools.64.o
scene/resources/visual_shader.cpp:1242:2: warning: #warning everything needs to be cleared here [-Wcpp]
 1242 | #warning everything needs to be cleared here
      |  ^~~~~~~
[777/818] Compiling servers/rendering/renderer_rd/pipeline_cache_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/pipeline_cache_rd.cpp:74:2: warning: #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion [-Wcpp]
   74 | #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
      |  ^~~~~~~
[784/818] Compiling servers/rendering/renderer_rd/renderer_compositor_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_compositor_rd.cpp:107:2: warning: #warning TODO: likely pass a bool to swap buffers to avoid display? [-Wcpp]
  107 | #warning TODO: likely pass a bool to swap buffers to avoid display?
      |  ^~~~~~~
[785/818] Compiling servers/rendering/renderer_rd/renderer_canvas_render_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp:1053:2: warning: #warning TODO obtain from framebuffer format eventually when this is implemented [-Wcpp]
 1053 | #warning TODO obtain from framebuffer format eventually when this is implemented
      |  ^~~~~~~
[800/818] Compiling servers/rendering/renderer_rd/renderer_storage_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_storage_rd.cpp:195:2: warning: #warning TODO need to make a function in Image to swap bits for this [-Wcpp]
  195 | #warning TODO need to make a function in Image to swap bits for this
      |  ^~~~~~~
servers/rendering/renderer_rd/renderer_storage_rd.cpp:5485:2: warning: #warning Should use display refresh rate for all this [-Wcpp]
 5485 | #warning Should use display refresh rate for all this
      |  ^~~~~~~
[818/818] Linking bin/godot.linuxbsd.tools.64

@akien-mga
Copy link
Member

The above tests were done with https://github.com/akien-mga/godot/tree/add_scons_ninja_tool

I tried the current commit of this PR instead without rebasing, and it does work much better:

[akien@cauldron godot.git (add_scons_ninja_tool)]$ scons p=linuxbsd use_ninja=yes
/usr/bin/scons p=linuxbsd use_ninja=yes 2>&1 | tee -a build.log
scons: Reading SConscript files ...
Note: Building a debug binary (which will run slowly). Use `target=release_debug` to build an optimized release binary.
Checking for C header file mntent.h... yes
scons: done reading SConscript files.
scons: Building targets ...
Generating: build.ninja
scons: done building targets.
[Time elapsed: 00:00:06.356]
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[1/1] Reconnect depfile to build.ninja
[174/2324] Compiling core/object/method_bind.linuxbsd.tools.64.o
core/object/method_bind.cpp:42:2: warning: #warning This needs proper class name and argument type for hashing [-Wcpp]
   42 | #warning This needs proper class name and argument type for hashing
      |  ^~~~~~~
[251/2324] Compiling editor/create_dialog.linuxbsd.tools.64.o
editor/create_dialog.cpp:689:2: warning: #warning cannot forward drag data to a non control, must be fixed [-Wcpp]
  689 | #warning cannot forward drag data to a non control, must be fixed
      |  ^~~~~~~
[305/2324] Compiling editor/editor_node.linuxbsd.tools.64.o
editor/editor_node.cpp:6578:2: warning: #warning needs to be reimplemented [-Wcpp]
 6578 | #warning needs to be reimplemented
      |  ^~~~~~~
[381/2324] Compiling editor/plugins/node_3d_editor_plugin.linuxbsd.tools.64.o
editor/plugins/node_3d_editor_plugin.cpp:4272:2: warning: #warning this needs to be fixed [-Wcpp]
 4272 | #warning this needs to be fixed
      |  ^~~~~~~
[419/2324] Compiling editor/project_export.linuxbsd.tools.64.o
editor/project_export.cpp:1033:2: warning: #warning must reimplement drag forward [-Wcpp]
 1033 | #warning must reimplement drag forward
      |  ^~~~~~~
[561/2324] Compiling modules/gltf/gltf_document.linuxbsd.tools.64.o
modules/gltf/gltf_document.cpp:2551:2: warning: #warning line loop and triangle fan are not supported and need to be converted to lines and triangles [-Wcpp]
 2551 | #warning line loop and triangle fan are not supported and need to be converted to lines and triangles
      |  ^~~~~~~
[635/2324] Compiling platform/linuxbsd/display_server_x11.linuxbsd.tools.64.o
platform/linuxbsd/display_server_x11.cpp:758:2: warning: #warning Need to get from proper window [-Wcpp]
  758 | #warning Need to get from proper window
      |  ^~~~~~~
platform/linuxbsd/display_server_x11.cpp:3977:2: warning: #warning Forcing vulkan rendering driver because OpenGL not implemented yet [-Wcpp]
 3977 | #warning Forcing vulkan rendering driver because OpenGL not implemented yet
      |  ^~~~~~~
[677/2324] Compiling scene/2d/sprite_2d.linuxbsd.tools.64.o
scene/2d/sprite_2d.cpp:318:2: warning: #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that) [-Wcpp]
  318 | #warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
      |  ^~~~~~~
[684/2324] Compiling scene/2d/skeleton_2d.linuxbsd.tools.64.o
scene/2d/skeleton_2d.cpp:192:2: warning: #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin [-Wcpp]
  192 | #warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
      |  ^~~~~~~
[738/2324] Compiling scene/gui/color_picker.linuxbsd.tools.64.o
scene/gui/color_picker.cpp:1036:2: warning: #warning show modal no longer works, needs to be converted to a popup [-Wcpp]
 1036 | #warning show modal no longer works, needs to be converted to a popup
      |  ^~~~~~~
[867/2324] Compiling servers/rendering/renderer_rd/pipeline_cache_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/pipeline_cache_rd.cpp:72:2: warning: #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion [-Wcpp]
   72 | #warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
      |  ^~~~~~~
[873/2324] Compiling servers/rendering/renderer_rd/renderer_compositor_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_compositor_rd.cpp:107:2: warning: #warning TODO: likely pass a bool to swap buffers to avoid display? [-Wcpp]
  107 | #warning TODO: likely pass a bool to swap buffers to avoid display?
      |  ^~~~~~~
[876/2324] Compiling servers/rendering/renderer_rd/renderer_canvas_render_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp:1053:2: warning: #warning TODO obtain from framebuffer format eventually when this is implemented [-Wcpp]
 1053 | #warning TODO obtain from framebuffer format eventually when this is implemented
      |  ^~~~~~~
[908/2324] Compiling servers/rendering/renderer_rd/renderer_storage_rd.linuxbsd.tools.64.o
servers/rendering/renderer_rd/renderer_storage_rd.cpp:195:2: warning: #warning TODO need to make a function in Image to swap bits for this [-Wcpp]
  195 | #warning TODO need to make a function in Image to swap bits for this
      |  ^~~~~~~
servers/rendering/renderer_rd/renderer_storage_rd.cpp:5064:2: warning: #warning Should use display refresh rate for all this [-Wcpp]
 5064 | #warning Should use display refresh rate for all this
      |  ^~~~~~~
[1861/2324] Compiling scene/resources/mesh.linuxbsd.tools.64.o
scene/resources/mesh.cpp:1306:2: warning: #warning need to add binding to add_surface using future MeshSurfaceData object [-Wcpp]
 1306 | #warning need to add binding to add_surface using future MeshSurfaceData object
      |  ^~~~~~~
[1938/2324] Compiling scene/resources/visual_shader.linuxbsd.tools.64.o
scene/resources/visual_shader.cpp:1238:2: warning: #warning everything needs to be cleared here [-Wcpp]
 1238 | #warning everything needs to be cleared here
      |  ^~~~~~~
[2036/2324] Compiling thirdparty/opus/opus_decoder.linuxbsd.tools.64.o
thirdparty/opus/opus_decoder.c:37:10: note: ‘#pragma message: You appear to be compiling without optimization, if so opus will be very slow.’
   37 | # pragma message "You appear to be compiling without optimization, if so opus will be very slow."
      |          ^~~~~~~
[2322/2324] Compiling drivers/vulkan/rendering_device_vulkan.linuxbsd.tools.64.o
drivers/vulkan/rendering_device_vulkan.cpp:1708:2: warning: #warning TODO check for support via RenderingDevice to enable on mobile when possible [-Wcpp]
 1708 | #warning TODO check for support via RenderingDevice to enable on mobile when possible
      |  ^~~~~~~
[2324/2324] Linking bin/godot.linuxbsd.tools.64
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[6/6] Linking bin/godot.linuxbsd.tools.64
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[2/2] Defer to SCons to build progress_finish
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[2/2] Defer to SCons to build progress_finish
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[2/2] Defer to SCons to build progress_finish
[akien@cauldron godot.git (add_scons_ninja_tool)]$ ninja
[2/2] Defer to SCons to build progress_finish

So either something changed in the master branch that broke things, or my tiny nitpicks messed things up. I'll debug further.

@akien-mga
Copy link
Member

So it seems that the slow rebuilds I experienced are simply due to daemon expired between each build:

Note that the scons daemon is launched by ninja and is running scons in the background waiting for ninja to send build commands that only scons know how to deal with. This would be any kind of SCons function action or more complicated actions. The daemon uses the SCons environment variable NINJA_SCONS_DAEMON_KEEP_ALIVE to determine how many seconds the scons daemon should stay awake without receiving a command from ninja. The default is 1800 seconds. A new daemon will be used when the ninja file is regenerated.

But that seems quite limiting. I can see how this daemon would do its job well if using e.g. VSCode which tries to recompile the code all the time when you type, but for a workflow where you write code, then compile when you're done, or simply pull new code from master and recompile on top of your previous build, this seems quite limiting. SCons without ninja does a much better job at incremental compilation over an indeterminate period of time than this daemon-based approach.

Is there a way to improve incremental compilation when the daemon has expired? Systematically rebuilding half the code when there was no change is not usable.

@dmoody256
Copy link
Contributor Author

Is there a way to improve incremental compilation when the daemon has expired? Systematically rebuilding half the code when there was no change is not usable.

technically the daemon can stay up forever. I made the timeout because the daemon pid file lives in build directory. This is not great, because if you clean you build folder, then the pidfile is lost and the daemon will stay until someone manually finds it and takes it down. It definitely needs some work to make it a better behaved daemon.

The main thing is that if the sconscripts change you need to restart the daemon. For scons specific jobs, ninja will not be able to determine if they need to be rebuilt, so ninja will execute those jobs, and send them to the scons daemon, which will then determine if they really need to be rebuilt. The ninja only jobs shouldn't need to be rebuilt, but maybe there is an issue there. I will take a look. Thanks for taking a closer look!

@dmoody256
Copy link
Contributor Author

@akien-mga So I have a few fixups in my local branch for some of the issues you presented, but still I am getting a case where ninja is rebuilding files it should not after regenerating the ninja file takes place, for example, making a non functional change to SConstruct. I realized there are several parts of the godot build which will re-write files just from scons execution, that is to say these files are generated outside the build graph, during sconscript reading phase. This will not work for the ninja tool, because the ninja tool subverts scons normal build processes to make sure nothing is built during the actual SCons build and only the dependency graph and command lines are generated.

Pure SCons build can be smart about this generated during reading phase because it does MD5 checking and can see that even though the timestamp changed, the MD5 is the same so the file is not actually dirty.

Here is just one example I am talking about:

godot/SConstruct

Lines 720 to 724 in 6ad0ca8

if env["tools"]:
env.Append(CPPDEFINES=["TOOLS_ENABLED"])
methods.write_disabled_classes(env["disable_classes"].split(","))
if env["disable_3d"]:
if env["tools"]:

When I was working on a branch to move all build output to target directory, I ended up fixing all the cases I found where things are being generated outside of scons, because in that case too, SCons can not act on things done during SConscript reading phase.

TLDR: I need make some changes to the structure of the build for it work with ninja, namely fixing cases were building is done during sconscript reading phase, should I do that in a separate PR? regardless of ninja, that practice is incorrect form and those build files should become official scons nodes.

@dmoody256
Copy link
Contributor Author

dmoody256 commented Feb 10, 2022

@akien-mga Also I wanted to mention that the ninja tool has merged to upstream scons. That version does not include the scons daemon, and when ninja needs scons to build something, it aggregates the targets, and kicks them all off at once, which has potential to lead to some ordering issues depending on the build structure.

But in any case, while I appreciate the help getting the scons daemon feature working, there are other avenues to get ninja working for the godot scons build. Most of godot source code generation takes place in function actions, but it may be possible to outsource these to dedicated python scripts (you would have to do something like this for Meson anyways) and then just have ninja execute the python scripts as a command.

@YuriSizov YuriSizov modified the milestones: 4.0, 4.x Feb 9, 2023
@Riteo
Copy link
Contributor

Riteo commented Mar 14, 2024

Thank you for your contribution!

As you noted, the state of ninja support changed over the course of this PR, with ninja support being upstreamed and mostly polished. I made a new one that uses this new version directly.

So, I'll mark this as superceded by #89452.

@Riteo Riteo closed this Mar 14, 2024
@Riteo Riteo added the archived label Mar 14, 2024
@AThousandShips AThousandShips removed this from the 4.x milestone Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants