Last active
October 23, 2023 13:14
-
-
Save weliveindetail/95c46f66fd789994fa506ba2027b40ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From fa1d9a34232137d7a6db6a01735a9d4bf690d4a4 Mon Sep 17 00:00:00 2001 | |
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <[email protected]> | |
Date: Thu, 16 Mar 2023 14:42:45 +0100 | |
Subject: [PATCH] [CMake] Prevent uncachable calls with ccache on Windows | |
--- | |
llvm/CMakeLists.txt | 25 +++++++++++++++++++++++++ | |
1 file changed, 25 insertions(+) | |
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt | |
index db207e3328be..51b5e4311f83 100644 | |
--- a/llvm/CMakeLists.txt | |
+++ b/llvm/CMakeLists.txt | |
@@ -207,6 +207,31 @@ if(LLVM_CCACHE_BUILD) | |
endif() | |
endif() | |
+if (WIN32) | |
+ if (CMAKE_C_COMPILER_LAUNCHER) | |
+ # Ccache has no support for /Zi, all calls will be rejected as uncacheable. | |
+ # Fall back to /Z7 instead in order to exploit the cache. | |
+ foreach(var_to_update | |
+ CMAKE_C_FLAGS | |
+ CMAKE_C_FLAGS_DEBUG | |
+ CMAKE_C_FLAGS_RELWITHDEBINFO) | |
+ string(REGEX REPLACE "(^| )/Z[i7I]($| )" " /Z7 " | |
+ "${var_to_update}" "${${var_to_update}}") | |
+ endforeach() | |
+ endif() | |
+ if (CMAKE_CXX_COMPILER_LAUNCHER) | |
+ # Ccache has no support for /Zi, all calls will be rejected as uncacheable. | |
+ # Fall back to /Z7 instead in order to exploit the cache. | |
+ foreach(var_to_update | |
+ CMAKE_CXX_FLAGS | |
+ CMAKE_CXX_FLAGS_DEBUG | |
+ CMAKE_CXX_FLAGS_RELWITHDEBINFO) | |
+ string(REGEX REPLACE "(^| )/Z[i7I]($| )" " /Z7 " | |
+ "${var_to_update}" "${${var_to_update}}") | |
+ endforeach() | |
+ endif() | |
+endif() | |
+ | |
set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING | |
"Optional arguments for the native tool used in CMake --build invocations for external projects.") | |
mark_as_advanced(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS) | |
-- | |
2.38.1.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment