Skip to content

Fix circular dependencies between libraries #108426

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

simpkins
Copy link
Contributor

@simpkins simpkins commented Jul 9, 2025

Fix circular dependencies between libraries

This merges the libraries from scene/, core/ drivers/, servers/, main/,
editor/, platform/, modules/, and tests/ into a single library.

Each of these directories includes code from the others, so trying to
build them as separate libraries causes problems, because they all
circularly depend on each other. I'm sort of surprised that the build
has worked up until now, given that code in core/ depends on symbols
from modules/, scene/ and servers/.

This fixes #108429, and is needed to help unblock #108415.

@adamscott
Copy link
Member

adamscott commented Jul 9, 2025

What's the issue currently? And what does your PR do? Can you add a little bit more detail to your description?

@simpkins
Copy link
Contributor Author

simpkins commented Jul 9, 2025

What's the issue currently? And what does your PR do? Can you add a little bit more detail to your description?

This is a draft PR that is not intended to be reviewed. I am using it just to kick off CI workflows to test builds on all the platforms.

That said, the commit messages do have more complete descriptions, and #108429 and #108415 are other relevant issues and PRs involved.

@simpkins simpkins force-pushed the lib_deps branch 2 times, most recently from 2cfffa3 to 2d9439f Compare July 9, 2025 19:31
@simpkins
Copy link
Contributor Author

simpkins commented Jul 9, 2025

Actually, now that I think I've got things working on all platforms, I will go ahead and re-use this PR to submit just the changes needed to fix the circular dependencies.

@simpkins simpkins changed the title Fix circular library dependencies Fix circular dependencies between libraries Jul 9, 2025
@simpkins simpkins marked this pull request as ready for review July 9, 2025 20:12
@simpkins simpkins requested a review from a team as a code owner July 9, 2025 20:12
env.Prepend(LIBS=[lib])

# Needed to force rebuilding the core files when the thirdparty code is updated.
env.Depends(lib, thirdparty_obj)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that thirdparty_obj is added to env.core_sources above on line 163, so removing this explicit env.Depends() should not have any effect.

This merges the libraries from scene/, core/ drivers/, servers/, main/,
editor/, platform/, modules/, and tests/ into a single library.

Each of these directories includes code from the others, so trying to
build them as separate libraries causes problems, because they all
circularly depend on each other.  I'm sort of surprised that the build
has worked up until now, given that code in core/ depends on symbols
from modules/, scene/ and servers/.

This fixes godotengine#108429, and is needed to help unblock godotengine#108415.
@Repiteo
Copy link
Contributor

Repiteo commented Jul 9, 2025

I'm sort of surprised that the build has worked up until now, given that code in core/ depends on symbols from modules/, scene/ and servers/.

Out of curiosity: how did you go about finding these? Was it from the compile errors alone, or is there an SCons command/tool you used? I've tried using the latter with --tree, but it was always waaay too much to parse in any meaningful way

@simpkins
Copy link
Contributor Author

Out of curiosity: how did you go about finding these? Was it from the compile errors alone, or is there an SCons command/tool you used? I've tried using the latter with --tree, but it was always waaay too much to parse in any meaningful way

Initially some of it was just from the build errors while working on #108415, but then I just did a pretty dumb grep to look for includes that shouldn't be there. e.g. rg '#include "(main|modules|scene|servers)/' core
(You can use grep -Er instead of rg if you don't have ripgrep installed.)

Grepping for all the includes and sorting the results by include path is also helpful to look for things that shouldn't be there:

rg '#include' core | awk -F : '{ print $2 " : " $1 }' | sort

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.

Circular dependencies between core libraries
4 participants