Skip to content

🦃 Use sccache in CI with GHA storage, mac & wasi included #127376

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
50 changes: 25 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ jobs:
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
- name: Install Dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Add ccache to PATH
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: false
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "CC=sccache gcc" >> "$GITHUB_ENV"
echo "CXX=sccache gcc" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure CPython
run: |
# Build Python with the libpython dynamic library
Expand Down Expand Up @@ -284,13 +285,13 @@ jobs:
- name: Install OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
- name: Add ccache to PATH
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: false
echo "CC=sccache gcc" >> "$GITHUB_ENV"
echo "CXX=sccache gcc" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure CPython
run: ./configure CFLAGS="-fdiagnostics-format=json" --config-cache --enable-slower-safety --with-pydebug --with-openssl="$OPENSSL_DIR"
- name: Build CPython
Expand Down Expand Up @@ -337,13 +338,13 @@ jobs:
- name: Install OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
- name: Add ccache to PATH
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: false
echo "CC=sccache gcc" >> "$GITHUB_ENV"
echo "CXX=sccache gcc" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Setup directory envs for out-of-tree builds
run: |
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -466,14 +467,13 @@ jobs:
- name: Install OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
- name: Add ccache to PATH
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
echo "CC=sccache gcc" >> "$GITHUB_ENV"
echo "CXX=sccache gcc" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure CPython
run: ./configure --config-cache --with-address-sanitizer --without-pymalloc
- name: Build CPython
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/reusable-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
brew install pkg-config [email protected] xz gdbm tcl-tk@8 make
# Because alternate versions are not symlinked into place by default:
brew link tcl-tk@8
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "CC=sccache clang" >> "$GITHUB_ENV"
echo "CXX=sccache clang" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure CPython
run: |
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/reusable-tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@ jobs:
sudo update-alternatives --set clang++ /usr/bin/clang++-17
# Reduce ASLR to avoid TSAN crashing
sudo sysctl -w vm.mmap_rnd_bits=28
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: TSAN Option Setup
run: |
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }} handle_segv=0" >> "$GITHUB_ENV"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
echo "CC=sccache clang" >> "$GITHUB_ENV"
echo "CXX=sccache clang++" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure CPython
run: ${{ inputs.options }}
- name: Build CPython
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/reusable-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Install dependencies
run: sudo ./.github/workflows/posix-deps-apt.sh
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: Configure CC and CXX env vars
run: |
echo "CC=sccache gcc" >> "$GITHUB_ENV"
echo "CXX=sccache gcc" >> "$GITHUB_ENV"
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
- name: Configure OpenSSL env vars
run: |
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
Expand All @@ -46,14 +53,6 @@ jobs:
- name: Install OpenSSL
if: steps.cache-openssl.outputs.cache-hit != 'true'
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
- name: Add ccache to PATH
run: |
echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Configure ccache action
uses: hendrikmuhs/[email protected]
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: Setup directory envs for out-of-tree builds
run: |
echo "CPYTHON_RO_SRCDIR=$(realpath -m "${GITHUB_WORKSPACE}"/../cpython-ro-srcdir)" >> "$GITHUB_ENV"
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
WASI_SDK_PATH: /opt/wasi-sdk
CROSS_BUILD_PYTHON: cross-build/build
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
SCCACHE_GHA_ENABLED: "true"
steps:
- uses: actions/checkout@v4
# No problem resolver registered as one doesn't currently exist for Clang.
Expand All @@ -37,13 +38,8 @@ jobs:
mkdir ${{ env.WASI_SDK_PATH }} && \
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-x86_64-linux.tar.gz | \
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
- name: "Configure ccache action"
uses: hendrikmuhs/[email protected]
with:
save: ${{ github.event_name == 'push' }}
max-size: "200M"
- name: "Add ccache to PATH"
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
- name: Start sccache-cache
uses: mozilla-actions/[email protected]
- name: "Install Python"
uses: actions/setup-python@v5
with:
Expand Down
8 changes: 7 additions & 1 deletion Tools/wasm/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,16 @@ def wasi_sdk_env(context):
for env_var, binary_name in list(env.items()):
env[env_var] = os.fsdecode(wasi_sdk_path / "bin" / binary_name)

compiler_env_names = ("CC", "CPP", "CXX")
if wasi_sdk_path != pathlib.Path("/opt/wasi-sdk"):
for compiler in ["CC", "CPP", "CXX"]:
for compiler in compiler_env_names:
env[compiler] += f" --sysroot={sysroot}"

# sccache used in CI via .github/workflows/reusable-wasi.yaml
if subprocess.call(("sccache", "--version"), stderr=subprocess.DEVNULL) == 0:
for compiler in compiler_env_names:
env[compiler] = 'sccache ' + env[compiler]

env["PKG_CONFIG_PATH"] = ""
env["PKG_CONFIG_LIBDIR"] = os.pathsep.join(
map(os.fsdecode,
Expand Down
Loading