Skip to content

Commit

Permalink
sccache sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Oct 8, 2024
1 parent 746835f commit 172674d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
32 changes: 18 additions & 14 deletions dev/ci/setup-sccache
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion dev/ci/teardown-sccache
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set -e
exec 2>&1

set -x
sccache --stop-server
sudo sccache --stop-server
cat sccache.log

0 comments on commit 172674d

Please sign in to comment.