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

cmake: Rework WITH_CCACHE #215

Merged
merged 2 commits into from
Jun 17, 2024
Merged

cmake: Rework WITH_CCACHE #215

merged 2 commits into from
Jun 17, 2024

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented May 27, 2024

This PR makes WITH_CCACHE an opportunistic boolean option with the default value ON.

Also the build system learned to tell ccache in the masquerade mode, which addresses this #93 (comment).

The TristateOption module has been deleted as planned.

else()
set(ccache_hints)
if(EXISTS "$ENV{ChocolateyInstall}")
# Bypass a shim executable provided by Chocolatey.

Choose a reason for hiding this comment

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

Is this not something that users of this package manger should be fixing on their own machine? In any case, the comment doesn't explain why it's needed (same goes for all other comments here).

Copy link
Owner Author

@hebasto hebasto Jun 8, 2024

Choose a reason for hiding this comment

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

Is this not something that users of this package manger should be fixing on their own machine?

That's indeed unfortunate that Chocalately's ccache.exe shim executable can't be moved or copied without being broken. But it is our intention to copy it in order to integrate with MSVC. Therefore, I believe that this is our responsibility to provide a workaround for such a case. Besides, it is only a single path hint.

Of course, this workaround can be removed in the future if it leads to extra maintenance burden.

In any case, the comment doesn't explain why it's needed (same goes for all other comments here).

I’ve reworked the comments in the hope of addressing your comment.

Copy link

Choose a reason for hiding this comment

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

But it is our intention to copy it in order to integrate with MSVC.

I still don't understand why we even need to do this though, to make ccache "work".

Copy link
Owner Author

Choose a reason for hiding this comment

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

@hebasto
Copy link
Owner Author

hebasto commented Jun 5, 2024

Rebased.

@hebasto hebasto force-pushed the 240527-cmake-FT branch from 89b0f0c to d6c76da Compare June 8, 2024 16:24
@hebasto hebasto force-pushed the 240527-cmake-FT branch 3 times, most recently from a9b113e to cc9fdc9 Compare June 17, 2024 10:50
@hebasto
Copy link
Owner Author

hebasto commented Jun 17, 2024

I've removed stuff, which is specific to the Chocolatey package manager. As native Windows jobs in our CI use ccache from Chocolatey, the required adjustments have been done.

# file COPYING or https://opensource.org/license/mit/.

if(MSVC AND WITH_CCACHE)
# For integration of ccache and MSVC, please refer to

Choose a reason for hiding this comment

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

I thought we were going to remove all of this for now? If not, it's still not clear to me why forcing ccache usage into MSVC / Visual Studio is the right thing to be doing, or what the trade-offs are (i.e what is the effect of using the "old" debug information format, I assume this degrades / breaks other things, and a quick google suggests this used(?) to brake incremental linking, and would currently be incompatible with hot reloading etc). Nothing is mentioned here, or in the PR description, and I'd be suprised if this answer is "no side-effects".

Copy link
Owner Author

Choose a reason for hiding this comment

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

find_program(CCACHE_EXECUTABLE ccache)
if(CCACHE_EXECUTABLE)
file(COPY_FILE ${CCACHE_EXECUTABLE} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT)
list(APPEND CMAKE_VS_GLOBALS

Choose a reason for hiding this comment

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

I didn't previously that this is configuring settings Visual Studio. Our build system really shouldn't need to pass settings to peoples code editors. If we are just copy-pasting what is in the cmake wiki, why don't we include "TrackFileAccess=false" & "UseMultiToolTask=true" here? According to https://cmake.org/cmake/help/latest/variable/CMAKE_VS_GLOBALS.html, the setting being used here, is also meant to be set by a toolchain file?

"CLToolPath=${CMAKE_BINARY_DIR}"
"DebugInformationFormat=OldStyle"
)
set(CMAKE_VS_NO_COMPILE_BATCHING ON)

Choose a reason for hiding this comment

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

So this turns off parallelism in builds entirely, to be able to use ccache?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Parallelism is provided by means of "UseMultiToolTask=true".

@hebasto
Copy link
Owner Author

hebasto commented Jun 17, 2024

#215 (comment):

I thought we were going to remove all of this for now?

Sure. MSVC support has been removed.

hebasto added 2 commits June 17, 2024 15:46
`WITH_CCACHE` is an opportunistic option now and its default is `ON`.
@m3dwards
Copy link

ACK 4cd15f1

Tested on Debian and saw ccache running and second builds were much faster. I also uninstalled ccache and configure correctly configured it to be off. I then tried to force ccache on and configure would not allow it to be on without ccache installed.

@hebasto hebasto merged commit c98d7ae into cmake-staging Jun 17, 2024
36 checks passed
hebasto added a commit that referenced this pull request Jun 29, 2024
…_required()`

af5e6b4 [FIXUP] cmake: Enable CMP0141 policy after `cmake_minimum_required()` (Hennadii Stepanov)

Pull request description:

  Otherwise, the policy setting won't get any effect.

  See https://cmake.org/cmake/help/latest/policy/CMP0141.html

  ---

  After #215, the `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` CMake's abstraction is not used in our code directly, but it is still convenient for the user to be able to use it when configuring the build system from the command line or an IDE.

  ---

  This change can be easily verified on any system (not Windows only) by injecting the following commands:
  ```cmake
  cmake_policy(GET CMP0141 result)
  message("${result}")
  ```

ACKs for top commit:
  m3dwards:
    ACK af5e6b4

Tree-SHA512: 98dccc7f97b3b496a121a6e0961b60c344a2bc7f2e19193ea1936a9776c5ebf7eec6c47e6159332997b48ea2ce3220a801054c3c9d1d8c7be927add4458bfb92
hebasto added a commit that referenced this pull request Sep 6, 2024
The `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT` variable has not been used
since the merge of #215 in the
CMake staging branch.
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.

3 participants