@@ -9,7 +9,12 @@ install_ubuntu() {
99 # Instead use lib and headers from OpenSSL1.1 installed in `install_openssl.sh``
1010 apt-get install -y cargo
1111 echo " Checking out sccache repo"
12- git clone https://github.com/pytorch/sccache
12+ if [ -n " $CUDA_VERSION " ]; then
13+ # TODO: Remove this
14+ git clone https://github.com/pytorch/sccache
15+ else
16+ git clone https://github.com/mozilla/sccache -b v0.8.2
17+ fi
1318 cd sccache
1419 echo " Building sccache"
1520 cargo build --release
@@ -19,6 +24,10 @@ install_ubuntu() {
1924 rm -rf sccache
2025 apt-get remove -y cargo rustc
2126 apt-get autoclean && apt-get clean
27+
28+ echo " Downloading old sccache binary from S3 repo for PCH builds"
29+ curl --retry 3 https://s3.amazonaws.com/ossci-linux/sccache -o /opt/cache/bin/sccache-0.2.14a
30+ chmod 755 /opt/cache/bin/sccache-0.2.14a
2231}
2332
2433install_binary () {
@@ -36,18 +45,46 @@ if [ -n "$ROCM_VERSION" ]; then
3645 curl --retry 3 http://repo.radeon.com/misc/.sccache_amd/sccache -o /opt/cache/bin/sccache
3746else
3847 ID=$( grep -oP ' (?<=^ID=).+' /etc/os-release | tr -d ' "' )
39- # TODO: Install the pre-built binary from S3 as building from source
40- # https://github.com/pytorch/sccache has started failing mysteriously
41- # in which sccache server couldn't start with the following error:
42- # sccache: error: Invalid argument (os error 22)
43- install_binary
48+ if [ -n " $CUDA_VERSION " ]; then
49+ # TODO: Install the pre-built binary from S3 as building from source
50+ # https://github.com/pytorch/sccache has started failing mysteriously
51+ # in which sccache server couldn't start with the following error:
52+ # sccache: error: Invalid argument (os error 22)
53+ install_binary
54+ else
55+ install_ubuntu
56+ fi
4457fi
4558chmod a+x /opt/cache/bin/sccache
4659
4760function write_sccache_stub() {
4861 # Unset LD_PRELOAD for ps because of asan + ps issues
4962 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90589
50- printf " #!/bin/sh\nif [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then\n exec sccache $( which $1 ) \"\$ @\" \nelse\n exec $( which $1 ) \"\$ @\" \nfi" > " /opt/cache/bin/$1 "
63+ if [ $1 == " gcc" ]; then
64+ # Do not call sccache recursively when dumping preprocessor argument
65+ # For some reason it's very important for the first cached nvcc invocation
66+ cat > " /opt/cache/bin/$1 " << EOF
67+ #!/bin/sh
68+
69+ if [ "\$ 1" = "-E" ] || [ "\$ 2" = "-E" ]; then
70+ exec $( which $1 ) "\$ @"
71+ elif [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then
72+ exec sccache $( which $1 ) "\$ @"
73+ else
74+ exec $( which $1 ) "\$ @"
75+ fi
76+ EOF
77+ else
78+ cat > " /opt/cache/bin/$1 " << EOF
79+ #!/bin/sh
80+
81+ if [ \$ (env -u LD_PRELOAD ps -p \$ PPID -o comm=) != sccache ]; then
82+ exec sccache $( which $1 ) "\$ @"
83+ else
84+ exec $( which $1 ) "\$ @"
85+ fi
86+ EOF
87+ fi
5188 chmod a+x " /opt/cache/bin/$1 "
5289}
5390
0 commit comments