forked from grpc/grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ccache for selected C++ and python builds (with redis server as c…
…ache) (grpc#28661) * add cmake support for ccache * cleanup: use --env-file for docker run invocations * make python build compatible with using ccache * enable building using ccache in selected kokoro jobs * print ccache stats and the end of run_tests.py
- Loading branch information
1 parent
739e739
commit f23f1bb
Showing
16 changed files
with
131 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright 2022 The gRPC Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Configure ccache if requested by environment variable GRPC_BUILD_ENABLE_CCACHE | ||
|
||
if ($ENV{GRPC_BUILD_ENABLE_CCACHE}) | ||
find_program(gRPC_CCACHE_BINARY ccache) | ||
if(gRPC_CCACHE_BINARY) | ||
message(STATUS "Will use ccache as compiler launcher: ${gRPC_CCACHE_BINARY}") | ||
set(CMAKE_C_COMPILER_LAUNCHER ${gRPC_CCACHE_BINARY}) | ||
set(CMAKE_CXX_COMPILER_LAUNCHER ${gRPC_CCACHE_BINARY}) | ||
else() | ||
message(STATUS "Build will not use ccache (ccache binary not found).") | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# Copyright 2022 The gRPC Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Source this rc script to configure ccache (compiler cache to speed up builds) | ||
|
||
# Allow use of ccache in builds that support that. | ||
export GRPC_BUILD_ENABLE_CCACHE=true | ||
|
||
# Redis instance housed in grpc-testing cloud project serves as the main compiler cache | ||
export CCACHE_SECONDARY_STORAGE=redis://10.76.145.84:6379 |
31 changes: 31 additions & 0 deletions
31
tools/internal_ci/helper_scripts/prepare_ccache_symlinks_rc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# Copyright 2022 The gRPC Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Source this rc script to create symlinks to ccache | ||
|
||
# TODO: handle values like "0", "false" etc. | ||
if [ "${GRPC_BUILD_ENABLE_CCACHE}" != "" ] | ||
then | ||
if [ -x "$(command -v ccache)" ] | ||
then | ||
TEMP_CCACHE_BINDIR="$(mktemp -d)" | ||
# TODO: symlinks for crosscompilers... | ||
for compiler in "gcc" "g++" "clang" "clang++" "cc" "c++" | ||
do | ||
ln -s "$(which ccache)" "${TEMP_CCACHE_BINDIR}/${compiler}" | ||
done | ||
export PATH="${TEMP_CCACHE_BINDIR}:$PATH" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Pass this file to "docker run" using --env-file argument. | ||
# Variables listed in this file will be set or propagated | ||
# to the docker container. | ||
|
||
# TODO(jtattermusch): revisit whether this very old hack is still needed. | ||
THIS_IS_REALLY_NEEDED="see https://github.com/docker/docker/issues/14203 for why docker is awful" | ||
|
||
# Kokoro sets environment variables for each build and we want them to be | ||
# available inside the test docker containers. | ||
KOKORO_BUILD_ID | ||
KOKORO_BUILD_NUMBER | ||
KOKORO_BUILD_URL | ||
KOKORO_JOB_NAME | ||
|
||
# Propagate ccache configuration to the docker containers. | ||
GRPC_BUILD_ENABLE_CCACHE | ||
CCACHE_SECONDARY_STORAGE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters