From 41a8c5e2e694006708f276bdad2f13079f3f2b13 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Mon, 26 May 2025 16:31:28 -0700 Subject: [PATCH] Remove remnants of sccache Before commit 71882f2eef78c6eea85c1a7e8fdca5f25ff72022 (May 2022), we built LLVM from source. This employed sccache to make builds faster. After that commit, sccache hasn't effectively been used. But there were remnants of sccache in the code base. This commit removes all references to sccache in the repo. --- cpython-unix/build-binutils.sh | 11 ----------- cpython-unix/build.py | 30 ---------------------------- cpython-unix/sccache-wrapper.sh | 31 ----------------------------- docs/building.rst | 35 --------------------------------- pythonbuild/utils.py | 11 ----------- src/github.rs | 2 +- 6 files changed, 1 insertion(+), 119 deletions(-) delete mode 100755 cpython-unix/sccache-wrapper.sh diff --git a/cpython-unix/build-binutils.sh b/cpython-unix/build-binutils.sh index b287e2e1c..c52e8238b 100755 --- a/cpython-unix/build-binutils.sh +++ b/cpython-unix/build-binutils.sh @@ -5,23 +5,12 @@ set -ex -ROOT=$(pwd) -SCCACHE="${ROOT}/sccache" - cd /build tar -xf binutils-${BINUTILS_VERSION}.tar.xz mkdir binutils-objdir pushd binutils-objdir -EXTRA_VARS= - -if [ -x "${SCCACHE}" ]; then - "${SCCACHE}" --start-server - export CC="${SCCACHE} /usr/bin/gcc" - export STAGE_CC_WRAPPER="${SCCACHE}" -fi - # gprofng requires a bison newer than what we have. So just disable it. ../binutils-${BINUTILS_VERSION}/configure \ --build=x86_64-unknown-linux-gnu \ diff --git a/cpython-unix/build.py b/cpython-unix/build.py index 6829e9101..6f98e990f 100755 --- a/cpython-unix/build.py +++ b/cpython-unix/build.py @@ -64,34 +64,6 @@ MACOS_ALLOW_FRAMEWORKS = {"CoreFoundation"} -def install_sccache(build_env): - """Attempt to install sccache into the build environment. - - This will attempt to locate a sccache executable and copy it - into the root directory of the build environment. - """ - candidates = [ - # Prefer a binary in the project itself. - ROOT / "sccache", - ] - - # Look for sccache in $PATH, but only if the build environment - # isn't isolated, as copying binaries into an isolated environment - # may not run. And running sccache in an isolated environment won't - # do anything meaningful unless an external cache is being used. - if not build_env.is_isolated: - for path in os.environ.get("PATH", "").split(":"): - if not path: - continue - - candidates.append(pathlib.Path(path) / "sccache") - - for candidate in candidates: - if candidate.exists(): - build_env.copy_file(candidate) - return - - def add_target_env(env, build_platform, target_triple, build_env): add_env_common(env) @@ -302,8 +274,6 @@ def build_binutils(client, image, host_platform): archive = download_entry("binutils", DOWNLOADS_PATH) with build_environment(client, image) as build_env: - install_sccache(build_env) - build_env.copy_file(archive) build_env.copy_file(SUPPORT / "build-binutils.sh") diff --git a/cpython-unix/sccache-wrapper.sh b/cpython-unix/sccache-wrapper.sh deleted file mode 100755 index 6eb63fb24..000000000 --- a/cpython-unix/sccache-wrapper.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -# This script is needed to handle a race in GCC's build system and a bug in -# sccache. -# -# GCC's build system could materialize `xgcc` and invoke commands like -# `xgcc -dumpspecs` before make materializes `cc1`. This is relevant because -# sccache invokes ` -E` on the first invocation of a compiler to -# determine which flavor of compiler to treat it as. And `gcc -E` requires -# support binaries like `cc1` in order to work. Our wrapper script sniffs -# for existence of `cc1` to mitigate this race condiion. -# -# Furthermore, sccache doesn't honor `-B` arguments when running -# ` -E`. So even if a support binary like `cc1` may exist, GCC may -# not know where to find it. Our wrapper script works around this by ensuring -# the compiler's directory is always on PATH. -# -# This script/approach is arguably not sound for use outside of the value of -# STAGE_CC_WRAPPER in GCC's build system. You have been warned. - -set -o errexit -set -o pipefail - -dir=$(dirname $1) -cc1=${dir}/cc1 - -if [ -e "${cc1}" ]; then - export PATH=${dir}:${PATH} - exec sccache "$@" -else - exec "$@" -fi diff --git a/docs/building.rst b/docs/building.rst index dc91dea27..c6a07e254 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -104,38 +104,3 @@ You will need to specify the path to a ``sh.exe`` installed from cygwin. e.g. To build a 32-bit x86 binary, simply use an ``x86 Native Tools Command Prompt`` instead of ``x64``. - -Using sccache to Speed up Builds -================================ - -Builds can take a long time. - -python-build-standalone can automatically detect and use the -`sccache `_ compiler cache to speed -up subsequent builds on UNIX-like platforms. ``sccache`` can shave dozens -of minutes from fresh builds, even on a 16 core CPU! - -If there is an executable ``sccache`` in the source directory, it will -automatically be copied into the build environment and used. For non-container -builds, an ``sccache`` executable is also searched for on ``PATH``. - -The ``~/.python-build-standalone-env`` file is read if it exists (the format is -``key=value`` pairs) and variables are added to the build environment. - -In addition, environment variables ``AWS_ACCESS_KEY_ID``, -``AWS_SECRET_ACCESS_KEY``, and any variable beginning with ``SCCACHE_`` are -automatically added to the build environment. - -The environment variable support enables you to define remote build caches -(such as S3 buckets) to provide a persistent, shared cache across builds and -machines. - -Keep in mind that when performing builds in containers in Linux (the default -behavior), the local filesystem is local to the container and does not survive -the build of a single package. So sccache is practically meaningless unless -configured to use an external store (such as S3). - -When using remote stores (such as S3), ``sccache`` can be constrained on -network I/O. We recommend having at least a 100mbps network connection to -a remote store and employing a network store with as little latency as possible -for best results. diff --git a/pythonbuild/utils.py b/pythonbuild/utils.py index 3df0f7839..a8132ca83 100644 --- a/pythonbuild/utils.py +++ b/pythonbuild/utils.py @@ -570,17 +570,6 @@ def add_env_common(env): except FileNotFoundError: pass - # Proxy sccache settings. - for k, v in os.environ.items(): - if k.startswith("SCCACHE_"): - env[k] = v - - # Proxy cloud provider credentials variables to enable sccache to - # use stores in those providers. - for k in ("AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"): - if k in os.environ: - env[k] = os.environ[k] - def exec_and_log(args, cwd, env): p = subprocess.Popen( diff --git a/src/github.rs b/src/github.rs index 8a432841f..0d3bc9715 100644 --- a/src/github.rs +++ b/src/github.rs @@ -209,7 +209,7 @@ pub async fn command_fetch_release_distributions(args: &ArgMatches) -> Result<() for artifact in artifacts { if matches!( artifact.name.as_str(), - "pythonbuild" | "sccache" | "toolchain" + "pythonbuild" | "toolchain" ) || artifact.name.contains("install-only") { continue;