From 172674dae485a818077fbb2ebdd76a9164c8544a Mon Sep 17 00:00:00 2001 From: Hongli Lai Date: Sun, 6 Oct 2024 10:13:20 +0200 Subject: [PATCH] sccache sudo --- dev/ci/setup-sccache | 32 ++++++++++++++++++-------------- dev/ci/teardown-sccache | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/dev/ci/setup-sccache b/dev/ci/setup-sccache index 5d76a2f925..b7cdfde5ba 100755 --- a/dev/ci/setup-sccache +++ b/dev/ci/setup-sccache @@ -10,31 +10,35 @@ if [[ -z "$SCCACHE_AZURE_CONNECTION_STRING" ]]; then exit 1 fi -echo "PATH=/usr/local/libexec/sccache:/usr/local/bin:$PATH" >> "$GITHUB_ENV" -echo "SCCACHE_ERROR_LOG=$(pwd)/sccache.log" >> "$GITHUB_ENV" - -# Ensure Github Actions print stdout and stderr data in correct order. +## Ensure Github Actions print stdout and stderr data in correct order. exec 2>&1 set -x +## Download and install sccache. wget --output-document sccache.tar.gz "https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-$ARCH_AND_OS.tar.gz" tar xzf sccache.tar.gz rm sccache.tar.gz sudo mv sccache*/sccache /usr/local/bin/sccache rm -rf sccache* +## Set up sccache as a compiler wrapper. +echo "PATH=/usr/local/libexec/sccache:/usr/local/bin:$PATH" >> "$GITHUB_ENV" sudo mkdir -p /usr/local/libexec/sccache for PROG in cc c++; do -FULLPATH=$(command -v "$PROG") -echo '#!/bin/sh' > "$PROG" -echo "exec /usr/local/bin/sccache $FULLPATH \"\$@\"" >> "$PROG" -cat "$PROG" -chmod +x "$PROG" -sudo mv "$PROG" /usr/local/libexec/sccache/ + FULLPATH=$(command -v "$PROG") + echo '#!/bin/sh' > "$PROG" + echo "exec /usr/local/bin/sccache $FULLPATH \"\$@\"" >> "$PROG" + chmod +x "$PROG" + sudo mv "$PROG" /usr/local/libexec/sccache/ done -touch sccache.log -export SCCACHE_START_SERVER=1 -# Uncomment this to have the sccache server write debug logs to sccache.log +## Start sccache server. + +## Uncomment this to have the sccache server write debug logs to sccache.log # export SCCACHE_LOG=debug -sccache + +touch sccache.log +echo "SCCACHE_ERROR_LOG=$(pwd)/sccache.log" >> "$GITHUB_ENV" + +# We sometimes run the compiler as root, so we need to give sccache root privileges as well. +sudo env SCCACHE_START_SERVER=1 sccache diff --git a/dev/ci/teardown-sccache b/dev/ci/teardown-sccache index 94bf24f96a..fc6737f0de 100755 --- a/dev/ci/teardown-sccache +++ b/dev/ci/teardown-sccache @@ -5,5 +5,5 @@ set -e exec 2>&1 set -x -sccache --stop-server +sudo sccache --stop-server cat sccache.log