Skip to content

Commit cb280e4

Browse files
committed
Always build PGO using RUSTFLAGS
There are many ways to pass flags to rustc: * `cargo rustc`, which only affects your crate and not its dependencies. * `RUSTFLAGS` environment variable, which affects dependencies as well. See https://stackoverflow.com/a/38040431 In this case I think `RUSTFLAGS` is a better choice.
1 parent 5c696e5 commit cb280e4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ jobs:
454454
--release
455455
--out pgo-wheel
456456
--interpreter ${{ matrix.maturin-interpreter || matrix.interpreter }}
457-
-- -Cprofile-generate=${{ github.workspace }}/profdata
458457
rust-toolchain: stable
459458
docker-options: -e CI
459+
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"
460460

461461
- name: detect rust host
462462
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
@@ -468,10 +468,9 @@ jobs:
468468
pip install -r tests/requirements.txt
469469
pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
470470
pytest tests/benchmarks
471-
rustup run stable bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata >> "$GITHUB_ENV"'
472471
473472
- name: merge pgo data
474-
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
473+
run: rustup run stable llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
475474

476475
- name: build pgo-optimized wheel
477476
uses: PyO3/maturin-action@v1
@@ -482,9 +481,10 @@ jobs:
482481
--release
483482
--out dist
484483
--interpreter ${{ matrix.maturin-interpreter || matrix.interpreter }}
485-
-- -Cprofile-use=${{ github.workspace }}/merged.profdata
486484
rust-toolchain: stable
487485
docker-options: -e CI
486+
env:
487+
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
488488

489489
- run: ${{ matrix.ls || 'ls -lh' }} dist/
490490

.github/workflows/codspeed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
run: pytest tests/benchmarks
6363

6464
- name: Prepare merged pgo data
65-
run: rustup run stable bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
65+
run: rustup run stable llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
6666

6767
- name: Compile pydantic-core for benchmarking
6868
# --no-default-features to avoid using mimalloc

0 commit comments

Comments
 (0)