Skip to content

Conversation

@TCROC
Copy link

@TCROC TCROC commented Oct 13, 2024

This was done for the same reasons as this PR for godot: godotengine/godot#91743 godotengine/godot#101042

Currently Godot overrides build tools such as CC and CXX depending on which platform is being targeted. This adds a boolean to the build process that prevents this from happening. It helps solve a lot of the pain points that I have been running into in the godot-src project: https://github.com/lange-studios/godot-src

This allows me to more easily use zig and other tools for cross compilation. Example:

  "CC=zig cc -target x86_64-linux-gnu"
  "CXX=zig c++ -target x86_64-linux-gnu"
  "LINK=zig c++ -target x86_64-linux-gnu"
  "AS=zig c++ -target x86_64-linux-gnu"
  "AR=zig ar"
  "RANLIB=zig ranlib"
  "WINDRES=zig rc"

And just like that, I can compile godot from any platform zig supports compiling from to any platform zig supports compiling to! In this case from Windows, Mac, or Linux to Linux! :)

I'm still testing out things as we build our own game with this tool to different platforms. So far it is working good! I'll leave it in draft state while I test things a little more and see what other changes I may need to make to the build process. I'm doing my best to keep the changes as small as possible. Please feel free to leave any feedback in the meantime.

Another thing to note:

zig handles the linking of libatomic (or so it seems in my tests) so I added a boolean to prevent that from being linked as well. I have set the default values to mirror exactly how godot currently behaves so as to avoid any breaking changes for existing build processes.

Let me know if there is anything you would like changed :). Thanks for the awesome tool! :)

@bruvzg
Copy link
Member

bruvzg commented Nov 3, 2025

Is this still relevant?

These tool scripts are copy from godot-cpp. So it's probably better to do the all the changes there first (if it was not already done), and sync script afterward.

@TCROC
Copy link
Author

TCROC commented Nov 3, 2025

Is this still relevant?

These tool scripts are copy from godot-cpp. So it's probably better to do the all the changes there first (if it was not already done), and sync script afterward.

I don't understand. We are still using this PR in our fork. Did a different PR get merged that already took care of this and I didn't realize? Or maybe it can already be accomplished without this PR and I didn't realize?

@bruvzg
Copy link
Member

bruvzg commented Nov 3, 2025

Did a different PR get merged that already took care of this and I didn't realize?

No, definitely not in this repo. And seems like neither main Godot repo nor godot-cpp have it or anything similar.

What I'm telling is making the same PR in the godot-cpp repo is likely a better idea than doing it here, since it's the primary source of these scripts (for both this and ANGLE repo).

@TCROC
Copy link
Author

TCROC commented Nov 3, 2025

Ah I see what you are saying. Yes, this PR is still relevant as we build godot-nir-static from source in the same way. Without this PR, our cross compilation tools don't work properly. But it may make more sense to wait for the approval of the godot-cpp PR first so that any critiques made to it, I can carry over to here.

@TCROC
Copy link
Author

TCROC commented Nov 3, 2025

And to clarify, the same PR is also in the godot repo:

godotengine/godot#91743

@TCROC
Copy link
Author

TCROC commented Nov 3, 2025

Wrong link, my bad. The PR is here: godotengine/godot#101042

Edit: I've also updated this PR subscription with the correct link to the pr in the godot repo as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants