-
-
Notifications
You must be signed in to change notification settings - Fork 23.6k
Description
Tested versions
- Current master branch
System information
- Windows 11 with mingw
Issue description
Godot's SConstruct file currently builds a separate static library for each subdirectory: core/, scene/, main/, platform/, a number of separate libraries under modules/, etc.
This is problematic, since libraries must be listed on the command line in dependency order: each library must be listed before other libraries they depend on. However, there are many circular dependencies between these libraries:
- Pretty much everything uses code from core/
- core/ depends on code from scene/, servers/, main/, and modules/
- servers/ depends on code from scene/ and modules/
- scene/ depends on code from modules/
- main/ depends on pretty much everything, including all modules (for
initialize_modules()) and platform (forregister_platform_apis())
The circular dependencies means that there is no correct way to list these libraries in a correct order on the command line. The code happens to work today, but is very fragile to exposing undefined symbol errors if anything is tweaked. (e.g.: this build failure from #108415.)
There are a few options for how this could be fixed:
- The most correct would be to combine everything into a single library. Since everything depends on everything else, it technically should be a single library. Unfortunately, attempting to do so currently results in build failures with
Argument list too longerrors trying to pass all of the source file names in a single command line. This could be worked around by making multiple separate calls toarto incrementally append more files to the archive, but that might be awkward with SCons. Another approach might be to let SCons build the current libraries as-is, and then relink them afterwards into one combined library. - For Linux we could hack around the problem by adding
-Wl,--start-groupand-Wl,--end-grouparound this group of libraries, to inform it that this group of libraries contains circular dependencies. However, it looks like the Apple linker may not support this functionality.
Steps to reproduce
PR #108415 makes a minor tweak to the link line (moving libtest before libmain) which triggers link failures due to these dependency problems. I'm sort of surprised that the build works as-is with these circular dependencies.
Minimal reproduction project (MRP)
Build #108415 with mingw on Windows.
Metadata
Metadata
Assignees
Type
Projects
Status