Created attachment 214185 [details] patch Make ccache more efficient. https://ccache.dev/manual/3.7.9.html#_compiling_in_different_directories Port system builds every port in folders with different names, this broke ccache hit ratio. With this patch last chromium update take ~20 minutes, not 1 hour 30 minutes as usual.
Assign PR to the maintainer.
Yes this patch makes sense. I haven't tested it though.
Do we need an exp-run because of the CFLAGS change?
(In reply to Mathieu Arnold from comment #3) It wouldn't hurt. I do worry that it will regress some ports that somehow see the MAKE_ENV but don't care about CFLAGS passed in. Not worth blocking it on those though as they are already losing all caching on version bumps due to changed workdir name.
(In reply to Bryan Drewery from comment #4) The proposed CFLAG change option isn't available in the man pages of clang nor gcc9, so the begging question is: how will this change affect those that have a development/debugging environment. (Hopefully none). Conversely for those that turn off debugging in their CFLAGS (-g0), does this option become a noop? (I'm afraid that I'm overly cautious when something may be added to binaries)
(In reply to dewayne from comment #5) -fdebug-prefix-map=${WRKSRC}=. - documented option. https://gcc.gnu.org/install/configure.html https://manpages.debian.org/experimental/binutils-common/as.1.en.html Then some one make debug build in backtrace or whatever then will see main.c not /tmp/ports/***/***/someapp-1.33.55/main.c. This allow ccache to cache files even then path to file changed. In our port system path changed on app version update.
(In reply to rozhuk.im from comment #6) Thank-you. After reviewing your references and poking around in # find /usr/src/ | xargs grep debug-prefix-map files I can see little to be concerned. Cheers.
Problem a more complex, current patch may improve cache hit ratio but does not work after port version change.
(In reply to Ivan Rozhuk from comment #8) Can you elaborate? Which port version? What breaks?
(In reply to Bryan Drewery from comment #9) https://github.com/ccache/ccache/issues/751 Then you build port version 1.2.3 it builds some where, and if this is out of source build than 1.2.3 go to the ccache metainfo as part of path to sources. In next time then you will build version 1.2.4 ccache will cache miss because in meta stored 1.2.3 path to sources. This issue affects cmake ports with outofsource build and may be some other ports. Current version of patch may improve cache hit ratio for insource build ports.
IMHO this part of work is done. To improve ccache hit ratio there is 2 ways: 1. Always build at same path, this mean do not use port version/hash for dir naming. 2. Step-by-step change outofsource build ports. For cmake this means that in build dir we need create symlink to sources dir and use this symlink as path to sources.
Created attachment 247340 [details] patch Add CXXFLAGS.
(In reply to Ivan Rozhuk from comment #12) According to ccache documentation [1], one must _either_ set hash_dir to false or pass -fdebug-prefix-map= to CFLAGS. Perhaps there's specific reason to use both options? [1]: https://ccache.dev/manual/4.9.html#_compiling_in_different_directories
(In reply to Anton Saietskii from comment #13) I do not see any disadvantages to set both same time in "hash_dir" description.
Created attachment 250920 [details] patch Fix issue: some CMake based ports fail to build due to miss includes from /usr/local/include.