Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Add direct softlinks for compiler in local bin
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoabreu committed Nov 28, 2018
1 parent 9288527 commit 5a59f07
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 68 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ python/.eggs
tests/Makefile
tests/mxnet_unit_tests

# generated wrappers for ccache
cc
cxx

# Code coverage related
.coverage
*.gcov
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ build/src/%.o: src/%.cc | mkldnn

build/src/%_gpu.o: src/%.cu | mkldnn
@mkdir -p $(@D)
$(NVCC) $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS)" -M -MT build/src/$*_gpu.o $< >build/src/$*_gpu.d
$(NVCC) $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS)" --generate-dependencies -MT build/src/$*_gpu.o $< >build/src/$*_gpu.d
$(NVCC) -c -o $@ $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS)" $<

# A nvcc bug cause it to generate "generic/xxx.h" dependencies from torch headers.
Expand All @@ -479,7 +479,7 @@ build/plugin/%.o: plugin/%.cc

%_gpu.o: %.cu
@mkdir -p $(@D)
$(NVCC) $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS) -Isrc/operator" -M -MT $*_gpu.o $< >$*_gpu.d
$(NVCC) $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS) -Isrc/operator" --generate-dependencies -MT $*_gpu.o $< >$*_gpu.d
$(NVCC) -c -o $@ $(NVCCFLAGS) $(CUDA_ARCH) -Xcompiler "$(CFLAGS) -Isrc/operator" $<

%.o: %.cc $(CORE_INC)
Expand Down Expand Up @@ -660,7 +660,7 @@ jnilint:

rclean:
$(RM) -r R-package/src/image_recordio.h R-package/NAMESPACE R-package/man R-package/R/mxnet_generated.R \
R-package/inst R-package/src/*.o R-package/src/*.so mxnet_*.tar.gz
R-package/inst R-package/src/*.o R-package/src/*.so mxnet_*.tar.gz deps

ifneq ($(EXTRA_OPERATORS),)
clean: rclean cyclean $(EXTRA_PACKAGES_CLEAN)
Expand Down
5 changes: 5 additions & 0 deletions ci/docker/install/centos7_adduser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ then
mkdir /work/mxnet
mkdir /work/build
chown -R jenkins_slave /work/

# Later on, we have to override the links because underlying build systems ignore our compiler settings. Thus,
# we have to give the process the proper permission to these files. This is hacky, but unfortunately
# there's no better way to do this without patching all our submodules.
chown -R jenkins_slave /usr/local/bin
fi
5 changes: 5 additions & 0 deletions ci/docker/install/ubuntu_adduser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ then
mkdir /work/mxnet
mkdir /work/build
chown -R jenkins_slave /work/

# Later on, we have to override the links because underlying build systems ignore our compiler settings. Thus,
# we have to give the process the proper permission to these files. This is hacky, but unfortunately
# there's no better way to do this without patching all our submodules.
chown -R jenkins_slave /usr/local/bin
fi
129 changes: 68 additions & 61 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,37 @@ clean_repo() {
git submodule update --init --recursive
}

build_ccache_wrappers() {
set -ex

rm -f cc
rm -f cxx

touch cc
touch cxx

if [ -z ${CC+x} ]; then
echo "No \$CC set, defaulting to gcc";
export CC=gcc
fi

if [ -z ${CXX+x} ]; then
echo "No \$CXX set, defaulting to g++";
export CXX=g++
fi

# this function is nessesary for cuda enabled make based builds, since nvcc needs just an executable for -ccbin

echo -e "#!/bin/sh\n/usr/local/bin/ccache ${CC} \"\$@\"\n" >> cc
echo -e "#!/bin/sh\n/usr/local/bin/ccache ${CXX} \"\$@\"\n" >> cxx

chmod +x cc
chmod +x cxx

export CC=`pwd`/cc
export CXX=`pwd`/cxx
install_ccache_wrappers() {
set -ex

# Recommended by CCache: https://ccache.samba.org/manual.html#_run_modes
# Add to the beginning of path to ensure this redirection is picked up instead
# of the original ones. Especially CUDA/NVCC appends itself to the beginning of the
# path and thus this redirect is ignored. This change fixes this problem
# This hacky approach with symbolic links is required because underlying build
# systems of our submodules ignore our CMake settings. If they use Makefile,
# we can't influence them at all in general and NVCC also prefers to hardcode their
# compiler instead of respecting the settings. Thus, we take this brutal approach
# and just redirect everything of this installer has been called.
# In future, we could do these links during image build time of the container.
# But in the beginning, we'll make this opt-in. In future, loads of processes like
# the scala make step or numpy compilation and other pip package generations
# could be heavily sped up by using ccache as well.
export PATH=/usr/local/bin:$PATH
ln -s ccache /usr/local/bin/gcc
ln -s ccache /usr/local/bin/g++
ln -s ccache /usr/local/bin/g++-8
ln -s ccache /usr/local/bin/gcc-8
ln -s ccache /usr/local/bin/nvcc
ln -s ccache /usr/local/bin/clang++-3.9
ln -s ccache /usr/local/bin/clang-3.9
ln -s ccache /usr/local/bin/clang++-5.0
ln -s ccache /usr/local/bin/clang-5.0
ln -s ccache /usr/local/bin/clang++-6.0
ln -s ccache /usr/local/bin/clang-6.0

# TODO: Remove
export CCACHE_LOGFILE=/work/mxnet/ccache-log
}

build_wheel() {
Expand Down Expand Up @@ -128,7 +130,6 @@ build_armv6() {
# to be linked additionally.

# We do not need OpenMP, since most armv6 systems have only 1 core

cmake \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
Expand Down Expand Up @@ -227,6 +228,8 @@ build_android_armv8() {
cd /work/build
cmake\
-DANDROID=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DUSE_CUDA=OFF\
-DUSE_SSE=OFF\
-DUSE_LAPACK=OFF\
Expand All @@ -242,9 +245,8 @@ build_android_armv8() {
build_centos7_cpu() {
set -ex
cd /work/mxnet
export CC="ccache gcc"
export CXX="ccache g++"

install_ccache_wrappers
make \
DEV=1 \
USE_LAPACK=1 \
Expand All @@ -257,6 +259,7 @@ build_centos7_cpu() {

build_amzn_linux_cpu() {
cd /work/build
install_ccache_wrappers
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
Expand All @@ -277,9 +280,8 @@ build_amzn_linux_cpu() {
build_centos7_mkldnn() {
set -ex
cd /work/mxnet
export CC="ccache gcc"
export CXX="ccache g++"


install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -293,8 +295,7 @@ build_centos7_mkldnn() {
build_centos7_gpu() {
set -ex
cd /work/mxnet
# unfortunately this build has problems in 3rdparty dependencies with ccache and make
# build_ccache_wrappers
install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -315,8 +316,7 @@ build_ubuntu_cpu() {

build_ubuntu_cpu_openblas() {
set -ex
export CC="ccache gcc"
export CXX="ccache g++"
install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -330,6 +330,7 @@ build_ubuntu_cpu_cmake_debug() {
set -ex
pushd .
cd /work/build
install_ccache_wrappers
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
Expand All @@ -351,6 +352,8 @@ build_ubuntu_cpu_cmake_asan() {

pushd .
cd /work/build
install_ccache_wrappers
# TODO: Check if we can remove the g++-8 override
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
Expand All @@ -377,10 +380,10 @@ build_ubuntu_cpu_cmake_asan() {

build_ubuntu_cpu_clang39() {
set -ex
export CXX=clang++-3.9
export CXX=clang++-3.9
export CC=clang-3.9
build_ccache_wrappers
make \
install_ccache_wrappers
make \
ENABLE_TESTCOVERAGE=1 \
USE_CPP_PACKAGE=1 \
USE_BLAS=openblas \
Expand All @@ -395,7 +398,7 @@ build_ubuntu_cpu_clang60() {
export CXX=clang++-6.0
export CC=clang-6.0

build_ccache_wrappers
install_ccache_wrappers

make \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -415,6 +418,7 @@ build_ubuntu_cpu_clang_tidy() {

pushd .
cd /work/build
install_ccache_wrappers
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
Expand All @@ -438,8 +442,7 @@ build_ubuntu_cpu_clang39_mkldnn() {
export CXX=clang++-3.9
export CC=clang-3.9

build_ccache_wrappers

install_ccache_wrappers
make \
ENABLE_TESTCOVERAGE=1 \
USE_CPP_PACKAGE=1 \
Expand All @@ -455,8 +458,7 @@ build_ubuntu_cpu_clang60_mkldnn() {
export CXX=clang++-6.0
export CC=clang-6.0

build_ccache_wrappers

install_ccache_wrappers
make \
ENABLE_TESTCOVERAGE=1 \
USE_CPP_PACKAGE=1 \
Expand All @@ -469,8 +471,7 @@ build_ubuntu_cpu_clang60_mkldnn() {
build_ubuntu_cpu_mkldnn() {
set -ex

build_ccache_wrappers

install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -488,7 +489,7 @@ build_ubuntu_gpu_tensorrt() {

set -ex

build_ccache_wrappers
install_ccache_wrappers

# Build ONNX
pushd .
Expand All @@ -498,6 +499,8 @@ build_ubuntu_gpu_tensorrt() {
mkdir -p build
cd build
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_FLAGS=-I/usr/include/python${PYVER}\
-DBUILD_SHARED_LIBS=ON ..\
-G Ninja
Expand All @@ -512,7 +515,10 @@ build_ubuntu_gpu_tensorrt() {
cd 3rdparty/onnx-tensorrt/
mkdir -p build
cd build
cmake ..
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
..
make -j$(nproc)
export LIBRARY_PATH=`pwd`:$LIBRARY_PATH
popd
Expand Down Expand Up @@ -543,8 +549,7 @@ build_ubuntu_gpu_tensorrt() {
build_ubuntu_gpu_mkldnn() {
set -ex

build_ccache_wrappers

install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -561,8 +566,7 @@ build_ubuntu_gpu_mkldnn() {
build_ubuntu_gpu_mkldnn_nocudnn() {
set -ex

build_ccache_wrappers

install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -577,8 +581,7 @@ build_ubuntu_gpu_mkldnn_nocudnn() {

build_ubuntu_gpu_cuda91_cudnn7() {
set -ex
# unfortunately this build has problems in 3rdparty dependencies with ccache and make
# build_ccache_wrappers
install_ccache_wrappers
make \
DEV=1 \
ENABLE_TESTCOVERAGE=1 \
Expand All @@ -595,6 +598,7 @@ build_ubuntu_gpu_cuda91_cudnn7() {
build_ubuntu_amalgamation() {
set -ex
# Amalgamation can not be run with -j nproc
install_ccache_wrappers
make -C amalgamation/ clean
make -C amalgamation/ \
USE_BLAS=openblas \
Expand All @@ -604,6 +608,7 @@ build_ubuntu_amalgamation() {
build_ubuntu_amalgamation_min() {
set -ex
# Amalgamation can not be run with -j nproc
install_ccache_wrappers
make -C amalgamation/ clean
make -C amalgamation/ \
USE_BLAS=openblas \
Expand All @@ -614,9 +619,10 @@ build_ubuntu_amalgamation_min() {
build_ubuntu_gpu_cmake_mkldnn() {
set -ex
cd /work/build
install_ccache_wrappers
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_CUDA=1 \
-DUSE_CUDNN=1 \
Expand All @@ -637,9 +643,10 @@ build_ubuntu_gpu_cmake_mkldnn() {
build_ubuntu_gpu_cmake() {
set -ex
cd /work/build
install_ccache_wrappers
cmake \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DENABLE_TESTCOVERAGE=ON \
-DUSE_CUDA=1 \
-DUSE_CUDNN=1 \
Expand Down

0 comments on commit 5a59f07

Please sign in to comment.