Build Godot from source, with modules as shared dependencies

Hello everyone.

It’s easy to build Godot from source, thanks to great documentation (gg). :slight_smile:
However, I hate how both the Editor and the templates are so “monolithic”; like it’s a single executable statically linked…

Have anyone ever tried to build the engine with modules, drivers, etc as shared libraries (dll / so), in order to alleviate the size of multiple templates?

And would a developer explain the decision to have everything statically linked to begin with?

Thank you in advance.

How would this work? The engine depends on having these features either on or not, how would you detect if the particular feature was linked or not?

Well, of course the features would be either on or off at build-time, but they’d be built as shared libraries; thus reducing the code duplication between the editor and/or the templates.

It makes it easier to port across platforms because each OS has a different way of loading “modules”. For example GNU/Linux uses dlopen and dlfcn.h to load .so libraries. While Windows uses windows.h and LoadLibrary to load a .dll. The process of calling the functions after loading them is also diffrent for each OS. A monolithic style makes it easier to port and maintain. Storing the entire app in one file also makes it “standalone”. This means you can copy the entire engine to a drive or folder and run it anywhere without any trouble.

Editor and template builds have different code though, and making dynamic linking is far less efficient than static linking

2 Likes

True, but I’m not really talking about this: I don’t especially need to implement a dynamic shared modules loading at runtime, but simply to link at build-time shared libraries.

This, I understand more, thanks.
However, I don’t manage only one template, so I still wish to build some parts as shared…

I guess I’ll have to tinker the SConstruct build system to see how I can achieve this.

Good luck! I don’t think it’ll be easy or very useful though, if you have different templates with different things enabled then you’d need to carefully detect what is used, and make sure it doesn’t build it with a config that’s different

You’d also have duplicate things in your output, making the resulting template larger, as you can’t strip shared code with lto

This of course assumes you’re just making a template with and without 3D enabled and such, not different target hardware or os etc.

1 Like