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

Use sccache or ccache when available #651

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ rapids_find_package(CUDAToolkit REQUIRED
INSTALL_EXPORT_SET raft-exports)
include(cmake/modules/ConfigureCUDA.cmake)

##############################################################################
# - Setup cache --------------------------------------------------------------

find_program(CCACHE sccache NAMES sccache ccache)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a build.sh option and not something that implicit runs on a machine. We shouldn't presume that a user of RAFT that has both sccache and ccache always wants sccache.

As discussed here: rapidsai/cuml#4534 (comment) The option to control this should be allow the user to specify which tool they want when using build.sh. For users that aren't using build.sh they can use the CMake supported enviornment variables to control this if they don't want to specify them on the command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out for me! I'd be happy to add similar flags in this PR. Is there any fundamental reason to not enable one of the tools by default (if no flags/env vars specified)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we shouldn't infer intent from the lack of setting the compiler launcher. For a couple of reasons:

  1. Both ccache and sccache also support the use case when they are the actual compiler provided to CMake. This pattern is used by developers and package managers. When this is happening and you have ccache/sccache as the compiler launcher you get errors as both don't support a syntax of ccache <ccache-symlink>

  2. At times developers need to benchmark the compile time cost / improvement of a change. By automatically injecting a ccache / sccache into the the compile line it will break presumptions of actual performance.

if (CCACHE)
message(VERBOSE "Using ${CCACHE} for caching.")
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CUDA_COMPILER_LAUNCHER ${CCACHE})
endif()

##############################################################################
# - Requirements -------------------------------------------------------------

Expand Down