From 46a939a70075763b82557ba6e1d09cc235ea6660 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 14 Aug 2025 15:38:56 +0200 Subject: [PATCH] qmake: Make ccache feature available on windows hosts Previously the ccache feature was only available on Unix-like hosts. This change makes it available on Windows hosts as well. Guard the ccache sloppiness assignments not to run on Windows hosts, due to syntax errors in the Windows shell. Also make sure to only wrap the compilers when targeting msvc, otherwise sccache specifically will complain when executing link.exe, which is a linker. ccache doesn't have this issue. Pick-to: 6.8 6.9 6.10 Task-number: QTBUG-139139 Change-Id: Icf314cf53197d6372c2794ecfb52786c1f9ee6d4 Reviewed-by: Alexey Edelev Reviewed-by: Joerg Bornemann --- mkspecs/features/{unix => }/ccache.prf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) rename mkspecs/features/{unix => }/ccache.prf (63%) diff --git a/mkspecs/features/unix/ccache.prf b/mkspecs/features/ccache.prf similarity index 63% rename from mkspecs/features/unix/ccache.prf rename to mkspecs/features/ccache.prf index ff6173171ab..858974c5e55 100644 --- a/mkspecs/features/unix/ccache.prf +++ b/mkspecs/features/ccache.prf @@ -8,7 +8,7 @@ launcher_prefix = ccache launcher_prefix = $$QMAKE_CACHE_LAUNCHER_PREFIX } -precompile_header:contains(launcher_prefix, ccache) { +precompile_header:contains(launcher_prefix, ccache):!equals(QMAKE_HOST.os, Windows) { CCACHE_SLOPPINESS += pch_defines time_macros launcher_prefix = \ @@ -19,5 +19,13 @@ precompile_header:contains(launcher_prefix, ccache) { $$launcher_prefix } -for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C)): \ +# sccache doesn't recognize that link.exe is a linker, not a compiler, so when targeting msvc +# only wrap the compiler tools. +msvc { + tools = QMAKE_CC QMAKE_CXX +} else { + tools = QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C +} + +for(tool, tools): \ $$tool = $$launcher_prefix $$eval($$tool)