Skip to content

ccache: support MSVC by using /Z7 via MSVC_DEBUG_INFORMATION_FORMAT #1853

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

Merged
merged 3 commits into from
Feb 7, 2025

Conversation

eramongodb
Copy link
Contributor

Attempt to improve support for building with ccache on Windows distros.

CMake uses /Zi in CMAKE_<LANG>_FLAGS_DEBUG by default. Unfortunately, ccache does not support /Zi. This means building C projects with CMake and Visual Studio is incompatible with ccache by default when using debug configurations.

CMake 3.25 introduces CMP0141 which moves the /Zi flag out of CMAKE_<LANG>_FLAGS_DEBUG into a new, dedicated MSVC_DEBUG_INFORMATION_FORMAT target property instead. This property is initialized by the new CMAKE_MSVC_DEBUG_INFORMATION_FORMAT variable, which still defaults to /Zi (aka ProgramDatabase) when the compiler supports it (which, for MSVC, it usually does). However, other debug information formats such as /Z7 (aka Embedded) which are compatible with ccache are now available to be specified directly in a controlled manner (rather than messing with *_FLAGS variables).

Therefore, this PR adds find_ccache_and_export_vars (from #1524) to compile-windows.sh, sets CMP0141 to NEW, and MSVC_DEBUG_INFORMATION_FORMAT top Embedded (/Z7) (when debug info is requested by the build configuration) to fully opt-into ccache-compatible builds.

@eramongodb eramongodb requested a review from kevinAlbs February 6, 2025 15:11
@eramongodb eramongodb self-assigned this Feb 6, 2025
Copy link
Contributor Author

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

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

Apologies, I had pushed an outdated branch.

@eramongodb eramongodb requested a review from kevinAlbs February 7, 2025 18:17
@eramongodb eramongodb merged commit 6856300 into mongodb:master Feb 7, 2025
43 checks passed
@eramongodb eramongodb deleted the cdriver-ccache branch February 7, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants