Skip to content

Commit dadbc62

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 dadbc62

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.github/workflows/ci.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,10 @@ 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+
env:
460+
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"
460461

461462
- name: detect rust host
462463
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
@@ -468,10 +469,9 @@ jobs:
468469
pip install -r tests/requirements.txt
469470
pip install pydantic-core --no-index --no-deps --find-links pgo-wheel --force-reinstall
470471
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"'
472472
473473
- name: merge pgo data
474-
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
474+
run: rustup run stable llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata
475475

476476
- name: build pgo-optimized wheel
477477
uses: PyO3/maturin-action@v1
@@ -482,9 +482,10 @@ jobs:
482482
--release
483483
--out dist
484484
--interpreter ${{ matrix.maturin-interpreter || matrix.interpreter }}
485-
-- -Cprofile-use=${{ github.workspace }}/merged.profdata
486485
rust-toolchain: stable
487486
docker-options: -e CI
487+
env:
488+
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
488489

489490
- run: ${{ matrix.ls || 'ls -lh' }} dist/
490491

.github/workflows/codspeed.yml

+1-1
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)