Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix to not use sccache if it's not setup properly #1171

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions manywheel/build_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,60 @@
set -ex
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

# Courtesy of pytorch/.jenkins/pytorch/common_utils.sh
#
# - 1st arg: code to add
# - remaining args: names of traps to modify
#
trap_add() {
trap_add_cmd=$1; shift || fatal "${FUNCNAME[0]} usage error"
for trap_add_name in "$@"; do
trap -- "$(
# helper fn to get existing trap command from output
# of trap -p
extract_trap_cmd() { printf '%s\n' "$3"; }
# print existing trap command with newline
eval "extract_trap_cmd $(trap -p "${trap_add_name}")"
# print the new trap command
printf '%s\n' "${trap_add_cmd}"
)" "${trap_add_name}" \
|| fatal "unable to add to trap ${trap_add_name}"
done
}
# set the trace attribute for the above function. this is
# required to modify DEBUG or RETURN traps because functions don't
# inherit them unless the trace attribute is set
declare -f -t trap_add

# Initialize sccache
if [[ -n "$SCCACHE_BUCKET" ]] && which sccache > /dev/null; then
# Save sccache logs to file
sccache --stop-server > /dev/null 2>&1 || true
rm -f ~/sccache_error.log || true

export SCCACHE_IDLE_TIMEOUT=1200
export SCCACHE_ERROR_LOG=~/sccache_error.log
export RUST_LOG=sccache::server=error

# Report sccache stats for easier debugging
sccache --zero-stats
function sccache_epilogue() {
sccache --show-stats
sccache --stop-server || true
}

trap_add sccache_epilogue EXIT
else
# Not using sscache if it's not setup properly
rm -f /opt/cache/bin/cc
rm -f /opt/cache/bin/c++
rm -f /opt/cache/bin/clang
rm -f /opt/cache/bin/clang++
rm -f /opt/cache/bin/gcc
rm -f /opt/cache/bin/g++

unset CMAKE_CUDA_COMPILER_LAUNCHER
fi

# Require only one python installation
if [[ -z "$DESIRED_PYTHON" ]]; then
Expand Down