Skip to content

Commit 3958f46

Browse files
committed
add build-pgo make target
1 parent d08d269 commit 3958f46

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,35 @@ install-rust-coverage:
1616
cargo install rustfilt coverage-prepare
1717
rustup component add llvm-tools-preview
1818

19+
.PHONY: install-pgo
20+
rustup component add llvm-tools-preview
21+
1922
.PHONY: build-dev
2023
build-dev:
2124
@rm -f python/pydantic_core/*.so
22-
cargo build --features extension-module
23-
@rm -f target/debug/lib_pydantic_core.d
24-
@rm -f target/debug/lib_pydantic_core.rlib
25-
@mv target/debug/lib_pydantic_core.* python/pydantic_core/_pydantic_core.so
25+
pip install -v -e . --config-settings=build-args='--profile dev'
2626

2727
.PHONY: build-prod
2828
build-prod:
2929
@rm -f python/pydantic_core/*.so
30-
maturin develop --release
30+
pip install -v -e .
3131

3232
.PHONY: build-coverage
3333
build-coverage:
34-
rm -f python/pydantic_core/*.so
35-
maturin develop -- -C instrument-coverage
34+
@rm -f python/pydantic_core/*.so
35+
RUSTFLAGS='-C instrument-coverage' pip install -v -e .
36+
37+
.PHONY: build-pgo
38+
build-pgo:
39+
@rm -f python/pydantic_core/*.so
40+
$(eval PROFDATA := $(shell mktemp -d))
41+
RUSTFLAGS='-Cprofile-generate=$(PROFDATA)' pip install -v -e .
42+
pytest tests/benchmarks
43+
$(eval LLVM_PROFDATA := $(shell rustup run stable bash -c 'echo $$RUSTUP_HOME/toolchains/$$RUSTUP_TOOLCHAIN/lib/rustlib/$$(rustc -Vv | grep host | cut -d " " -f 2)/bin/llvm-profdata'))
44+
$(LLVM_PROFDATA) merge -o $(PROFDATA)/merged.profdata $(PROFDATA)
45+
RUSTFLAGS='-Cprofile-use=$(PROFDATA)/merged.profdata' pip install -v -e .
46+
@rm -rf $(PROFDATA)
47+
3648

3749
.PHONY: build-wasm
3850
build-wasm:

0 commit comments

Comments
 (0)