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

Disable /Zi when using ccache on Windows/MSVC. #11841

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

ScottTodd
Copy link
Member

One step towards enabling ccache on our Windows CI, but there are a few details to still work through: #11009 (comment).

On my machine, I see these results (sample size 1):

clean build (no cache): 528 seconds

λ ccache --show-stats
Cacheable calls:   3942 / 3943 (99.97%)
  Hits:               2 / 3942 ( 0.05%)
    Direct:           0 /    2 ( 0.00%)
    Preprocessed:     2 /    2 (100.0%)
  Misses:          3940 / 3942 (99.95%)
Uncacheable calls:    1 / 3943 ( 0.03%)
Local storage:
  Cache size (GB): 2.21 / 5.00 (44.21%)
  Cleanups:          16

clean build (with cache): 96 seconds

λ ccache --show-stats
Cacheable calls:   3942 / 3943 (99.97%)
  Hits:            3939 / 3942 (99.92%)
    Direct:        3939 / 3939 (100.0%)
    Preprocessed:     0 / 3939 ( 0.00%)
  Misses:             3 / 3942 ( 0.08%)
Uncacheable calls:    1 / 3943 ( 0.03%)
Local storage:
  Cache size (GB): 2.21 / 5.00 (44.23%)

My only changes to enable ccache were:

  • Download ccache.exe and put it on my PATH
  • Configure CMake with -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache (added to "cmake.configureArgs": [ ... ] in VSCode settings)

@ScottTodd ScottTodd added infrastructure Relating to build systems, CI, or testing platform/windows 🚪 Windows-specific build, execution, benchmarking, and deployment labels Jan 14, 2023
Comment on lines +436 to +441
message(STATUS "Replacing /Zi with /Z7 since ccache is in use and does not support /Zi")
# https://learn.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this will affect downstream users too. Not really a fan of when projects modify global flags, but I think this is niche enough...

Copy link
Collaborator

Choose a reason for hiding this comment

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

since it's conditional on ccache usage and anyone using ccache would need the same thing it seems ok - may still conflict with a user's similar hacks but probably worth waiting for that to be an issue :)

Copy link
Collaborator

@benvanik benvanik left a comment

Choose a reason for hiding this comment

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

love this!

@ScottTodd ScottTodd enabled auto-merge (squash) January 14, 2023 00:46
@ScottTodd ScottTodd merged commit fc61048 into iree-org:main Jan 14, 2023
@ScottTodd ScottTodd deleted the windows-ccache branch January 14, 2023 01:12
jpienaar pushed a commit that referenced this pull request May 1, 2023
One step towards enabling [ccache](https://ccache.dev/) on our Windows
CI, but there are a few details to still work through:
#11009 (comment).

On my machine, I see these results (sample size 1):

> clean build (no cache): 528 seconds
> ```
> λ ccache --show-stats
> Cacheable calls:   3942 / 3943 (99.97%)
>   Hits:               2 / 3942 ( 0.05%)
>     Direct:           0 /    2 ( 0.00%)
>     Preprocessed:     2 /    2 (100.0%)
>   Misses:          3940 / 3942 (99.95%)
> Uncacheable calls:    1 / 3943 ( 0.03%)
> Local storage:
>   Cache size (GB): 2.21 / 5.00 (44.21%)
>   Cleanups:          16
> ```
> clean build (with cache): 96 seconds
> ```
> λ ccache --show-stats
> Cacheable calls:   3942 / 3943 (99.97%)
>   Hits:            3939 / 3942 (99.92%)
>     Direct:        3939 / 3939 (100.0%)
>     Preprocessed:     0 / 3939 ( 0.00%)
>   Misses:             3 / 3942 ( 0.08%)
> Uncacheable calls:    1 / 3943 ( 0.03%)
> Local storage:
>   Cache size (GB): 2.21 / 5.00 (44.23%)
> ```

My only changes to enable ccache were:
* Download ccache.exe and put it on my `PATH`
* Configure CMake with `-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache` (added to `"cmake.configureArgs":
[ ... ]` in VSCode settings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Relating to build systems, CI, or testing platform/windows 🚪 Windows-specific build, execution, benchmarking, and deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants