Skip to content

Commit 9ed7bf2

Browse files
authored
gh-128515: Add BOLT build to CI (gh-128845)
1 parent 3829104 commit 9ed7bf2

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

.github/workflows/build.yml

+11
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,14 @@ jobs:
231231
name: >-
232232
Ubuntu
233233
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
234+
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
234235
needs: check_source
235236
if: needs.check_source.outputs.run_tests == 'true'
236237
strategy:
237238
matrix:
239+
bolt:
240+
- false
241+
- true
238242
free-threading:
239243
- false
240244
- true
@@ -246,9 +250,16 @@ jobs:
246250
exclude:
247251
- os: ubuntu-24.04-aarch64
248252
is-fork: true
253+
# Do not test BOLT with free-threading, to conserve resources
254+
- bolt: true
255+
free-threading: true
256+
# BOLT currently crashes during instrumentation on aarch64
257+
- os: ubuntu-24.04-aarch64
258+
bolt: true
249259
uses: ./.github/workflows/reusable-ubuntu.yml
250260
with:
251261
config_hash: ${{ needs.check_source.outputs.config_hash }}
262+
bolt-optimizations: ${{ matrix.bolt }}
252263
free-threading: ${{ matrix.free-threading }}
253264
os: ${{ matrix.os }}
254265

.github/workflows/reusable-ubuntu.yml

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
config_hash:
77
required: true
88
type: string
9+
bolt-optimizations:
10+
description: Whether to enable BOLT optimizations
11+
required: false
12+
type: boolean
13+
default: false
914
free-threading:
1015
description: Whether to use free-threaded mode
1116
required: false
@@ -34,6 +39,12 @@ jobs:
3439
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
3540
- name: Install dependencies
3641
run: sudo ./.github/workflows/posix-deps-apt.sh
42+
- name: Install Clang and BOLT
43+
if: ${{ fromJSON(inputs.bolt-optimizations) }}
44+
run: |
45+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19
46+
sudo apt-get install bolt-19
47+
echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV
3748
- name: Configure OpenSSL env vars
3849
run: |
3950
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
@@ -73,14 +84,18 @@ jobs:
7384
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
7485
- name: Configure CPython out-of-tree
7586
working-directory: ${{ env.CPYTHON_BUILDDIR }}
87+
# `test_unpickle_module_race` writes to the source directory, which is
88+
# read-only during builds — so we exclude it from profiling with BOLT.
7689
run: >-
90+
PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race'
7791
../cpython-ro-srcdir/configure
7892
--config-cache
7993
--with-pydebug
8094
--enable-slower-safety
8195
--enable-safety
8296
--with-openssl="$OPENSSL_DIR"
8397
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
98+
${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }}
8499
- name: Build CPython out-of-tree
85100
if: ${{ inputs.free-threading }}
86101
working-directory: ${{ env.CPYTHON_BUILDDIR }}

Lib/test/test_perf_profiler.py

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def tearDown(self) -> None:
4747
for file in files_to_delete:
4848
file.unlink()
4949

50+
@unittest.skipIf(support.check_bolt_optimized, "fails on BOLT instrumented binaries")
5051
def test_trampoline_works(self):
5152
code = """if 1:
5253
def foo():
@@ -100,6 +101,7 @@ def baz():
100101
"Address should contain only hex characters",
101102
)
102103

104+
@unittest.skipIf(support.check_bolt_optimized, "fails on BOLT instrumented binaries")
103105
def test_trampoline_works_with_forks(self):
104106
code = """if 1:
105107
import os, sys
@@ -160,6 +162,7 @@ def baz():
160162
self.assertIn(f"py::bar_fork:{script}", child_perf_file_contents)
161163
self.assertIn(f"py::baz_fork:{script}", child_perf_file_contents)
162164

165+
@unittest.skipIf(support.check_bolt_optimized, "fails on BOLT instrumented binaries")
163166
def test_sys_api(self):
164167
code = """if 1:
165168
import sys

0 commit comments

Comments
 (0)