-
Notifications
You must be signed in to change notification settings - Fork 793
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
CMake: use ccache and sccache for compiler caching #3947
base: master
Are you sure you want to change the base?
Conversation
8cd3810
to
6590b82
Compare
Nice :) thank you. I haven't tested it yet, but do you think it would be possible to extract the logic into a |
Yes, good idea. |
6590b82
to
602dc3b
Compare
I refactored it to not even check for ccache if CMake is using MSVC as the compiler. Extracting this to a CMake module is a good idea. This could be easily dropped into any CMake project now. |
The next step after this could be using this on CI. I haven't worked with Drone before but I suppose it shouldn't be too hard. I don't see how macOS builds are done though... is CI only running for Linux and Windows? |
Yes, correct. CI is only running on Windows and Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution
I believe I would still prefer to have this as an option that would be enabled manually
my question is because I believe some people might have ccache
installed but would not necessarily want to use it
or is there absolutely no downside to use it ? (disc space usage, ...)
Why? I have never seen anyone raise concern about this. If they are bothered by this, they could uninstall ccache, or manually specify
The only downside is storage space used. The maximum cache size can be set with |
How do you make sure that in no case you can get obsolete compilation products being used ?
should not be a problem for people familiar with it |
This is ccache's job and it does a really good job of it. I have never once had a problem that was fixed by disabling ccache. |
Is there anything left to do here? |
we are in the process of pushing a release and master is frozen |
@Be-ing sorry for almost forgetting about this |
602dc3b
to
b7c8aaf
Compare
FWIW, while I've never had a problem caused by ccache doing bad caches that caused the wrong results, there are definitely times I didn't want to use ccache even when it is installed. Both because of the space, and because ccache is, by design, a bit slower than running the compiler on its own -- due to the file copying it kind of has to be. So, one might want to disable ccache if it is known that the build itself is a one-off build of something and the work will never be reused. meson enables it by default, which generally works quite well, but only if you let it autodetect the compiler. You can specify Apparently cmake defines a special option for a compiler wrapper? Interesting. Anyway, offering a cmake option to disable ccache is all that I think is needed, and that is done here... now the trick is to let people know that such an option exists without first running cmake, having it detect ccache, and then running |
This CMake module creates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry completely overlooked one thing during review (and sorry again for the delays, it is extremely busy here)
could you change the license of the new file to match existing ones (BSD 3 clauses as far as I can tell) ?
this is what is being done most of the time with cmake module files
I don't mind, but this includes code originally written by @emabrey so she would need to approve relicensing it as well. |
I just noticed that I had not updated the SPDX license identifier when copying this module to another repo. I just fixed that. |
13219b1
to
6ae8e98
Compare
/rebase |
6ae8e98
to
53e1fb2
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3947 +/- ##
==========================================
+ Coverage 60.09% 60.12% +0.03%
==========================================
Files 145 145
Lines 18810 18810
==========================================
+ Hits 11303 11309 +6
+ Misses 7507 7501 -6 |
53e1fb2
to
8f83cdd
Compare
AppImage file: nextcloud-PR-3947-8f83cdde40420a19a72c9cc986b2c70e8a9fcff1-x86_64.AppImage |
First build on Fedora 35 with an Intel Core i7 8550U: 4.5 minutes Repeat build with ccache after deleting CMake build directory and creating a new one: 1.5 minutes This code is adapted from Tenacity, written by myself and @emabrey, licensed BSD-3-Clause. ccache is easily available from Linux distribution packages and Homebrew on macOS. sccache is the only currently maintained compiler cache for MSVC and can be installed easily from Chocolatey on Windows. Alternatively it can be installed with cargo if a Rust toolchain is installed. Signed-off-by: Be <[email protected]>
8f83cdd
to
ca07f32
Compare
First build on Fedora 35 with an Intel Core i7 8550U: 4.5 minutes
Repeat build with ccache after deleting CMake build directory
and creating a new one: 1.5 minutes
This code is adapted from Tenacity, written by myself and
@emabrey, licensed GPLv2 or later.
ccache is easily available from Linux distribution packages and
Homebrew on macOS. sccache is the only currently maintained
compiler cache for MSVC and can be installed easily from
Chocolatey on Windows.
Signed-off-by: Be [email protected]