@@ -12,26 +12,6 @@ set -ex
1212# shellcheck source=/dev/null
1313source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
1414
15- install_ubuntu () {
16- echo " Preparing to build sccache from source"
17- apt-get update
18- # libssl-dev will not work as it is upgraded to libssl3 in Ubuntu-22.04.
19- # Instead use lib and headers from OpenSSL1.1 installed in `install_openssl.sh``
20- apt-get install -y cargo
21- echo " Checking out sccache repo"
22- git clone https://github.com/mozilla/sccache -b v0.8.2
23-
24- cd sccache
25- echo " Building sccache"
26- cargo build --release
27- cp target/release/sccache /opt/cache/bin
28- echo " Cleaning up"
29- cd ..
30- rm -rf sccache
31- apt-get remove -y cargo rustc
32- apt-get autoclean && apt-get clean
33- }
34-
3515install_binary () {
3616 echo " Downloading sccache binary from S3 repo"
3717 curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /opt/cache/bin/sccache
@@ -42,33 +22,15 @@ mkdir -p /opt/cache/bin
4222sed -e ' s|PATH="\(.*\)"|PATH="/opt/cache/bin:\1"|g' -i /etc/environment
4323export PATH=" /opt/cache/bin:$PATH "
4424
45- install_ubuntu
25+ # NB: Install the pre-built binary from S3 as building from source
26+ # https://github.com/pytorch/sccache has started failing mysteriously
27+ # in which sccache server couldn't start with the following error:
28+ # sccache: error: Invalid argument (os error 22)
29+ install_binary
4630
4731function write_sccache_stub() {
4832 BINARY=$1
49- if [ $1 == " gcc" ]; then
50- # Do not call sccache recursively when dumping preprocessor argument
51- # For some reason it's very important for the first cached nvcc invocation
52- cat > " /opt/cache/bin/$1 " << EOF
53- #!/bin/sh
54- if [ "\$ 1" = "-E" ] || [ "\$ 2" = "-E" ]; then
55- exec $( which $1 ) "\$ @"
56- elif [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then
57- exec sccache $( which $1 ) "\$ @"
58- else
59- exec $( which $1 ) "\$ @"
60- fi
61- EOF
62- else
63- cat > " /opt/cache/bin/$1 " << EOF
64- #!/bin/sh
65- if [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then
66- exec sccache $( which $1 ) "\$ @"
67- else
68- exec $( which $1 ) "\$ @"
69- fi
70- EOF
71- fi
33+ printf " #!/bin/sh\nif [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then\n exec sccache %s \"\$ @\" \nelse\n exec %s \"\$ @\" \nfi" " $( which " ${BINARY} " ) " " $( which " ${BINARY} " ) " > " /opt/cache/bin/${BINARY} "
7234 chmod a+x " /opt/cache/bin/${BINARY} "
7335}
7436
@@ -82,7 +44,7 @@ init_sccache() {
8244
8345 # NB: This function is adopted from PyTorch core at
8446 # https://github.com/pytorch/pytorch/blob/main/.ci/pytorch/common-build.sh
85- as_ci_user sccache --stop-server > /dev/null 2>&1 || true
47+ as_ci_user sccache --stop-server > /dev/null 2>&1 || true
8648 rm -f " ${SCCACHE_ERROR_LOG} " || true
8749
8850 # Clear sccache stats before using it
0 commit comments