Skip to content

Commit

Permalink
[BUILD] Build with ccache by default if available (#5076)
Browse files Browse the repository at this point in the history
It's a bit annoying to have to remember to pass
`TRITON_BUILD_WITH_CCACHE` every time you invoke `pip install`.

This changes the default to check if ccache is installed and use it if
it's found, with the option to manually disable ccache if it's not
wanted for some reason.
  • Loading branch information
peterbell10 authored Nov 5, 2024
1 parent c802bb4 commit 053ced9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 17)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

project(triton)
project(triton CXX)
include(CTest)

if(NOT WIN32)
Expand All @@ -26,8 +26,25 @@ option(TRITON_BUILD_TUTORIALS "Build C++ Triton tutorials" ON)
option(TRITON_BUILD_PYTHON_MODULE "Build Python Triton bindings" OFF)
option(TRITON_BUILD_PROTON "Build the Triton Proton profiler" ON)
option(TRITON_BUILD_UT "Build C++ Triton Unit Tests" ON)
option(TRITON_BUILD_WITH_CCACHE "Build with ccache (if available)" ON)
set(TRITON_CODEGEN_BACKENDS "" CACHE STRING "Enable different codegen backends")

if(TRITON_BUILD_WITH_CCACHE)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}"
CACHE STRING "C compiler launcher")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}"
CACHE STRING "CXX compiler launcher")
else()
message(
STATUS
"Could not find ccache. Consider installing ccache to speed up compilation."
)
endif()
endif()


# Ensure Python3 vars are set correctly
# used conditionally in this file and by lit tests

Expand Down
13 changes: 7 additions & 6 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,16 @@ def build_extension(self, ext):
"-DCMAKE_CXX_FLAGS=-fsanitize=address",
]

if check_env_flag("TRITON_BUILD_WITH_CCACHE"):
cmake_args += [
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
]
# environment variables we will pass through to cmake
passthrough_args = [
"TRITON_BUILD_PROTON",
"TRITON_BUILD_TUTORIALS",
"TRITON_BUILD_WITH_CCACHE",
]
cmake_args += [f"-D{option}={os.getenv(option)}" for option in passthrough_args if option in os.environ]

if check_env_flag("TRITON_BUILD_PROTON", "ON"): # Default ON
cmake_args += self.get_proton_cmake_args()
else:
cmake_args += ["-DTRITON_BUILD_PROTON=OFF"]

if is_offline_build():
# unit test builds fetch googletests from GitHub
Expand Down

0 comments on commit 053ced9

Please sign in to comment.