Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 713ad0d

Browse files
committed
Install and compile with ccache for faster builds
1 parent 4ad6e88 commit 713ad0d

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

docker/common/install_base.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ apt-get install -y --no-install-recommends \
1313
wget \
1414
unzip \
1515
vim \
16+
autoconf \
1617
automake \
1718
libtool \
1819
valgrind \
@@ -33,12 +34,48 @@ apt-get install -y --no-install-recommends libcilkrts5 gcc-$GCC_VERSION g++-$GCC
3334
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 50
3435
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION 50
3536

36-
export CC=/usr/bin/gcc
37-
export CXX=/usr/bin/g++
37+
# Install ccache from source. Needs 3.4 or later for ccbin support
38+
# Needs specific branch to work with nvcc (ccache/ccache#145)
39+
# Also pulls in a commit that disables documentation generation,
40+
# as this requires asciidoc to be installed (which pulls in a LOT of deps).
41+
echo "Installing ccache"
42+
pushd /tmp
43+
git clone https://github.com/pietern/ccache -b ccbin
44+
pushd ccache
45+
./autogen.sh
46+
./configure --prefix=/usr/local
47+
make "-j$(nproc)" install
48+
popd
49+
popd
50+
51+
# Install ccache symlink wrappers
52+
# A good read on ccache: https://software.intel.com/en-us/articles/accelerating-compilation-part-1-ccache
53+
echo "Setting up ccache wrappers"
54+
pushd /usr/local/bin
55+
ln -sf "$(which ccache)" cc
56+
ln -sf "$(which ccache)" c++
57+
ln -sf "$(which ccache)" gcc
58+
ln -sf "$(which ccache)" g++
59+
ln -sf "$(which ccache)" x86_64-linux-gnu-gcc
60+
# Install ccache wrapper for nvcc. We are using NVIDIA image so nvcc is there.
61+
ln -sf "$(which ccache)" nvcc
62+
# set the cache limit
63+
ccache -M 25Gi
64+
65+
export CCACHE_WRAPPER_DIR="$PWD/ccache"
66+
export PATH="$CCACHE_WRAPPER_DIR:$PATH"
67+
# CMake should use ccache symlink for nvcc
68+
export CUDA_NVCC_EXECUTABLE="$PWD/nvcc"
69+
popd
70+
71+
echo "Setting CC and CXX env variables"
72+
export CC=$(which gcc)
73+
export CXX=$(which g++)
74+
echo "CC: ${CC}"
75+
echo "CXX: ${CXX}"
3876

3977
# install cmake - this unifies trusty/xenial cmake version > 3.4.3
4078
[ -n "$CMAKE_VERSION" ]
41-
4279
# Turn 3.6.3 into v3.6
4380
path=$(echo "${CMAKE_VERSION}" | sed -e 's/\([0-9].[0-9]\+\).*/v\1/')
4481
file="cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz"
@@ -49,7 +86,6 @@ tar -C /usr/local --strip-components 1 --no-same-owner -zxf cmake-*.tar.gz
4986
rm -f cmake-*.tar.gz
5087
popd
5188

52-
5389
# LLVM+Clang-Tapir5.0
5490
export LLVM_SOURCES=/tmp/llvm_sources-tapir5.0
5591
mkdir -p $LLVM_SOURCES

docker/docker_build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ echo "============Summary Ended================"
5454
docker build \
5555
--build-arg "BUILD_ENVIRONMENT=${image}" \
5656
--build-arg "CMAKE_VERSION=${CMAKE_VERSION}" \
57-
--build-arg "EC2=${EC2:-}" \
5857
--build-arg "JENKINS=${JENKINS:-}" \
5958
--build-arg "JENKINS_UID=${JENKINS_UID:-}" \
6059
--build-arg "JENKINS_GID=${JENKINS_GID:-}" \

docker/ubuntu-cuda-conda/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ ARG GCC_VERSION
2222
ARG CMAKE_VERSION
2323
ADD ./common/install_base.sh install_base.sh
2424
RUN bash ./install_base.sh && rm install_base.sh
25+
ENV PATH /usr/local/bin/ccache:$PATH
26+
ENV CUDA_NVCC_EXECUTABLE /usr/local/bin/nvcc
27+
ENV PATH /usr/local/cuda/bin:$PATH
2528

2629
# Anaconda3
2730
ADD ./common/install_conda.sh install_conda.sh
@@ -45,8 +48,8 @@ ARG BUILD_ENVIRONMENT
4548
ENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
4649

4750
# Set all the environment variables now
48-
ENV CC /usr/bin/gcc
49-
ENV CXX /usr/bin/g++
51+
ENV CC /usr/local/bin/gcc
52+
ENV CXX /usr/local/bin/g++
5053
ENV PATH /opt/conda/bin:$PATH
5154
ENV CMAKE_VERSION cmake
5255

docker/ubuntu-cuda/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ ARG GCC_VERSION
1717
ARG CMAKE_VERSION
1818
ADD ./common/install_base.sh install_base.sh
1919
RUN bash ./install_base.sh && rm install_base.sh
20+
ENV PATH /usr/local/bin/ccache:$PATH
21+
ENV CUDA_NVCC_EXECUTABLE /usr/local/bin/nvcc
22+
ENV PATH /usr/local/cuda/bin:$PATH
2023

2124
# Python3
2225
ADD ./common/install_pip_python.sh install_pip_python.sh
@@ -39,8 +42,8 @@ ARG BUILD_ENVIRONMENT
3942
ENV BUILD_ENVIRONMENT ${BUILD_ENVIRONMENT}
4043

4144
# Set all the environment variables now
42-
ENV CC /usr/bin/gcc
43-
ENV CXX /usr/bin/g++
45+
ENV CC /usr/local/bin/gcc
46+
ENV CXX /usr/local/bin/g++
4447
ENV PATH /usr/bin/python3:$PATH
4548
ENV CMAKE_VERSION cmake
4649

0 commit comments

Comments
 (0)