@@ -12,26 +12,6 @@ set -ex
12
12
# shellcheck source=/dev/null
13
13
source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
14
14
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
-
35
15
install_binary () {
36
16
echo " Downloading sccache binary from S3 repo"
37
17
curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /opt/cache/bin/sccache
@@ -42,33 +22,15 @@ mkdir -p /opt/cache/bin
42
22
sed -e ' s|PATH="\(.*\)"|PATH="/opt/cache/bin:\1"|g' -i /etc/environment
43
23
export PATH=" /opt/cache/bin:$PATH "
44
24
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
46
30
47
31
function write_sccache_stub() {
48
32
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} "
72
34
chmod a+x " /opt/cache/bin/${BINARY} "
73
35
}
74
36
@@ -82,7 +44,7 @@ init_sccache() {
82
44
83
45
# NB: This function is adopted from PyTorch core at
84
46
# 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
86
48
rm -f " ${SCCACHE_ERROR_LOG} " || true
87
49
88
50
# Clear sccache stats before using it
0 commit comments