Skip to content

Commit ae4cee9

Browse files
authored
Merge pull request #327 from faster-cpython/easier-clang
Fix #326: Add a checkbox to build with clang
2 parents 02820f5 + 79530b6 commit ae4cee9

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

bench_runner/flags.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Flag:
1717
Flag("tier2", "PYTHON_UOPS", "tier 2 interpreter", "T2"),
1818
Flag("jit", "JIT", "JIT", "JIT"),
1919
Flag("nogil", "NOGIL", "free threading", "NOGIL"),
20+
Flag("clang", "CLANG", "build with latest clang", "CLANG"),
2021
]
2122

2223

bench_runner/templates/_benchmark.src.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ name: _benchmark
4848
benchmarks:
4949
description: "Benchmarks to run (comma-separated; empty runs all benchmarks)"
5050
type: string
51-
pgo:
52-
description: "Build with PGO"
53-
type: boolean
5451
force:
5552
description: "Rerun and replace results if commit already exists"
5653
type: boolean
@@ -109,13 +106,19 @@ jobs:
109106
repository: mdboom/pyperformance
110107
path: pyperformance
111108
ref: ${{ env.PYPERFORMANCE_HASH }}
109+
- name: Build with clang
110+
if: ${{ inputs.clang }}
111+
run: |
112+
Write-Error "Using the latest clang compiler on Windows isn't currently supported by bench-runner"
113+
exit 1
112114
- name: Build Python
113115
if: ${{ steps.should_run.outputs.should_run != 'false' }}
114116
run: |
115117
cd cpython
116118
PCbuild\build.bat ($env:BUILD_FLAGS -split ' ') ${{ inputs.pgo == true && '--pgo' || '' }} ${{ inputs.jit == true && '--experimental-jit' || '' }} ${{ inputs.tier2 == true && '--experimental-jit-interpreter' || '' }} ${{ inputs.nogil == true && '--disable-gil' || '' }} -c Release
117119
# Copy the build products to a place that libraries can find them.
118120
Copy-Item -Path $env:BUILD_DEST -Destination "libs" -Recurse
121+
$env:BUILD_DEST\python.exe -VV
119122
- name: Install pyperformance
120123
if: ${{ steps.should_run.outputs.should_run != 'false' }}
121124
run: |
@@ -198,12 +201,19 @@ jobs:
198201
repository: mdboom/pyperformance
199202
path: pyperformance
200203
ref: ${{ env.PYPERFORMANCE_HASH }}
204+
- name: Build with clang
205+
if: ${{ inputs.clang }}
206+
run: |
207+
echo "CC=`which clang-19`" >> $GITHUB_ENV
208+
echo "LLVM_AR=`which llvm-ar-19`" >> $GITHUB_ENV
209+
echo "LLVM_PROFDATA=`which llvm-profdata-19`" >> $GITHUB_ENV
201210
- name: Build Python
202211
if: ${{ steps.should_run.outputs.should_run != 'false' }}
203212
run: |
204213
cd cpython
205214
./configure ${{ inputs.pgo == true && '--enable-optimizations --with-lto=yes' || '' }} ${{ inputs.tier2 == true && '--enable-experimental-jit=interpreter' || '' }} ${{ inputs.jit == true && '--enable-experimental-jit=yes' || '' }} ${{ inputs.nogil == true && '--disable-gil' || '' }}
206215
make ${{ runner.arch == 'ARM64' && '-j' || '-j4' }}
216+
./python -VV
207217
- name: Install pyperformance
208218
if: ${{ steps.should_run.outputs.should_run != 'false' }}
209219
run: |
@@ -299,12 +309,20 @@ jobs:
299309
if: ${{ steps.should_run.outputs.should_run != 'false' }}
300310
run: |
301311
echo "PKG_CONFIG_PATH=$(brew --prefix [email protected])/lib/pkgconfig" >> $GITHUB_ENV
312+
- name: Build with clang
313+
if: ${{ inputs.clang }}
314+
run: |
315+
echo "PATH=$(brew --prefix llvm)/bin:$PATH" >> $GITHUB_ENV
316+
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
317+
echo "LDFLAGS=-L$(brew --prefix llvm)/lib" >> $GITHUB_ENV
318+
echo "CFLAGS=-I$(brew --prefix llvm)/include" >> $GITHUB_ENV
302319
- name: Build Python
303320
if: ${{ steps.should_run.outputs.should_run != 'false' }}
304321
run: |
305322
cd cpython
306323
./configure ${{ inputs.pgo == true && '--enable-optimizations --with-lto=yes' || '' }} ${{ inputs.tier2 == true && '--enable-experimental-jit=interpreter' || '' }} ${{ inputs.jit == true && '--enable-experimental-jit=yes' || '' }} ${{ inputs.nogil == true && '--disable-gil' || '' }}
307324
make -j4
325+
./python.exe -VV
308326
# On macos ARM64, actions/setup-python isn't available, so we rely on a
309327
# pre-installed homebrew one, used through a venv
310328
- name: Install pyperformance

tests/test_gh.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ def get_args(args, **kwargs):
5858
"jit=false",
5959
"-f",
6060
"nogil=false",
61+
"-f",
62+
"clang=false",
6163
]

0 commit comments

Comments
 (0)