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

Fix Thin LTO not working #22171

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

Conversation

TCROC
Copy link
Contributor

@TCROC TCROC commented Dec 6, 2024

This PR fixes this issue: #21947. I have tested compiling the Godot Game Engine with this PR: https://github.com/godotengine/godot

It compiles much faster and does not consume all of my memory! :)

This is vital for us to be able to add first class support for cross platform compilation in our godot-src project: https://github.com/lange-studios/godot-src

NOTE:

I am unsure of how to trigger the code path in main.zig in lines 1383 - 1396. If someone could give me instructions on how to trigger that code path or test themselves to confirm that code change works, that would be greatly appreciated!

Thanks again for the awesome Zig! U all rock! :)

src/Compilation/Config.zig Outdated Show resolved Hide resolved
src/Compilation/Config.zig Outdated Show resolved Hide resolved
@alexrp
Copy link
Member

alexrp commented Dec 7, 2024

I am unsure of how to trigger the code path in main.zig in lines 1383 - 1396. If someone could give me instructions on how to trigger that code path or test themselves to confirm that code change works, that would be greatly appreciated!

That would be for zig build-exe, build-lib, test, etc... the other code path is for zig cc and zig c++.

src/Compilation/Config.zig Outdated Show resolved Hide resolved
@TCROC
Copy link
Contributor Author

TCROC commented Dec 13, 2024

@alexrp looks like one of the pipelines failed. Doesn't jump out to me as something introduced by this PR. Likely just needs a rerun. Let me know if you think otherwise

src/Compilation.zig Outdated Show resolved Hide resolved
.Debug => false,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => true,
.Debug => .none,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => options.lto,
Copy link
Member

Choose a reason for hiding this comment

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

In this path, we're supposed to resolve a default value if the user has not provided one. We already checked options.lto != .none above, so this can only possibly resolve to .none.

This should probably be:

Suggested change
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => options.lto,
.ReleaseSafe, .ReleaseFast, .ReleaseSmall => .full,

We can consider later if the default should be switched to .thin. I don't know if there are any major disadvantages to it that would make .full a preferable default.

Copy link
Member

Choose a reason for hiding this comment

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

@TCROC ping; I think this hunk is the only blocker for merging this.

@alexrp
Copy link
Member

alexrp commented Dec 13, 2024

It would also be nice to change std.Build to support enum { none, full, thin }. That's not a requirement to merge this, though.

@TCROC
Copy link
Contributor Author

TCROC commented Dec 14, 2024

It would also be nice to change std.Build to support enum { none, full, thin }. That's not a requirement to merge this, though.

Sounds like a plan! I look forward to testing your PR after this one goes through! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants