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

Added support ccache for speedup compilation on Linux #14173

Closed
wants to merge 1 commit into from

Conversation

GermanAizek
Copy link
Contributor

@GermanAizek GermanAizek commented Dec 27, 2023

@wsor4035
Copy link
Contributor

wsor4035 commented Dec 27, 2023

duplicate/alternate of #13111 ? - if nothing else, #11667 should be linked @Zughy

@wsor4035 wsor4035 added @ Build CMake, build scripts, official builds, compiler and linker errors Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements Performance labels Dec 27, 2023
@GermanAizek
Copy link
Contributor Author

I did not measure CI build speed, I was interested in local build on computer.

@Zughy Zughy added Feature ✨ PRs that add or enhance a feature Roadmap The change matches an item on the current roadmap Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand and removed Roadmap The change matches an item on the current roadmap labels Dec 28, 2023
@lhofhansl
Copy link
Contributor

A complete rebuild takes 2m12s on my 2019 laptop. Do we really need to add complexity to this?
Not opposed, but at least "neutral".

Copy link
Member

@Desour Desour left a comment

Choose a reason for hiding this comment

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

I've already been using ccache for years (I have /usr/lib/ccache/bin/ in my $PATH), and I consider it essential. Waiting minutes at rebuilding each time you checkout a different branch is awful.
=> I support this.


Please add a build option to enable this. One might still want to compile without ccache every now and then, e.g. for benchmarking build speed.

@Desour Desour added Action / change needed Code still needs changes (PR) / more information requested (Issues) Concept approved Approved by a core dev: PRs welcomed! and removed Roadmap: Needs approval The change is not part of the current roadmap and needs to be approved by coredevs beforehand labels Dec 28, 2023
@Desour
Copy link
Member

Desour commented Dec 28, 2023

duplicate/alternate of #13111 ?

Probably not. The cached build artifacts needs to be stored somewhere, you won't get this without modifying the CI stuff.

@Zughy Zughy added Roadmap: supported by core dev PR not adhering to the roadmap, yet some core dev decided to take care of it and removed Concept approved Approved by a core dev: PRs welcomed! labels Jan 21, 2024
@appgurueu
Copy link
Contributor

appgurueu commented Jan 24, 2024

What's the benefit of making changes to our CMakeLists.txt for this? According to https://github.com/ccache/ccache/wiki/CMake, I can just do -D CMAKE_CXX_COMPILER_LAUNCHER=ccache, and this seems to work just fine; I can switch branches and recompile efficiently.

Maybe we should just recommend ccache in the docs?

@GermanAizek
Copy link
Contributor Author

GermanAizek commented Jan 25, 2024

What's the benefit of making changes to our CMakeLists.txt for this? According to https://github.com/ccache/ccache/wiki/CMake, I can just do -D CMAKE_CXX_COMPILER_LAUNCHER=ccache, and this seems to work just fine; I can switch branches and recompile efficiently.

Maybe we should just recommend ccache in the docs?

Do you suggest entering -D parameter every time? I think most people will forget.

@appgurueu
Copy link
Contributor

appgurueu commented Jan 25, 2024

Do you suggest entering -D parameter every time? I think most people will forget.

This is just needed at "configure time", e.g. when invoking cmake. Subsequent make invocations do not require this to be passed. Using ccache should be an explicit choice; it comes at a cost (disk space and, apparently, a minuscule risk of broken builds) and is only really relevant to developers who frequently recompile anyways.

And if people do "forget" to use ccache, it's not much of an issue; their build will just be slightly slower.

(BTW, I removed the linked issue, since that concerned CI, and this PR does not make necessary CI changes.)

@Desour
Copy link
Member

Desour commented Jan 26, 2024

A simple -DENABLE_CCACHE=1 is easier than something like -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache (if you also want to enable it for C files). (And this doesn't even include the sloppiness yet.)

Either way, we should have some doc explaining how one can compile minetest with ccache.

@appgurueu
Copy link
Contributor

appgurueu commented Jan 27, 2024

A simple -DENABLE_CCACHE=1 is easier than something like -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache (if you also want to enable it for C files). (And this doesn't even include the sloppiness yet.)

(Nitpick: The C files aren't really relevant for performance. We have only one C file (sha256.c). But it's nice for consistency, I suppose.)

What I like about -DCMAKE_CXX_COMPILER_LAUNCHER=ccache is that it should work for pretty much any CMake C++ project. No need to deal with any project-specific flags there.

Anyways, if it's such a trivial shorthand I wouldn't mind; there is virtually no risk in merging that, though I'd be wary of a default of 1.

Either way, we should have some doc explaining how one can compile minetest with ccache.

Agreed.

@Zughy Zughy removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Jan 30, 2024
@Desour
Copy link
Member

Desour commented Feb 4, 2024

The option is still missing.

@Desour Desour added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label Feb 4, 2024
@Zughy Zughy added the Adoption needed The pull request needs someone to adopt it. Adoption welcomed! label Mar 2, 2024
@Zughy Zughy closed this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Action / change needed Code still needs changes (PR) / more information requested (Issues) Adoption needed The pull request needs someone to adopt it. Adoption welcomed! @ Build CMake, build scripts, official builds, compiler and linker errors Feature ✨ PRs that add or enhance a feature Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements Performance Roadmap: supported by core dev PR not adhering to the roadmap, yet some core dev decided to take care of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants