8000 [WIP] gh-104523 overhaul build rules for optimized binaries by indygreg · Pull Request #104525 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[WIP] gh-104523 overhaul build rules for optimized binaries #104525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-104523: inline minimal PGO rules
Various rules were only ever invoked once and had minimal bodies.
I don't see a benefit to the indirection.

So this commit inlines rules to simplify the PGO logic.

skip news (trivial, non-user-visible change)
  • Loading branch information
indygreg committed May 16, 2023
commit dd66e38c35a96c60005769e8e25f878b56673f31
20 changes: 4 additions & 16 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ profile-gen-stamp: profile-clean-stamp
exit 1;\
fi
@echo "Building with support for profile generation:"
$(MAKE) build_all_generate_profile
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"
touch $@

# Run task with profile generation build to create profile information.
Expand All @@ -652,28 +652,16 @@ profile-run-stamp:
# enabled.
$(MAKE) profile-gen-stamp
# Next, run the profile task to generate the profile information.
$(MAKE) run_profile_task
$(MAKE) build_all_merge_profile
@ # FIXME: can't run for a cross build
$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true
$(LLVM_PROF_MERGER)
# Remove profile generation binary since we are done with it.
$(MAKE) clean-retain-profile
# This is an expensive target to build and it does not have proper
# makefile dependency information. So, we create a "stamp" file
# to record its completion and avoid re-running it.
touch $@

.PHONY: build_all_generate_profile
build_all_generate_profile:
$(MAKE) @DEF_MAKE_RULE@ CFLAGS_NODIST="$(CFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LDFLAGS_NODIST="$(LDFLAGS_NODIST) $(PGO_PROF_GEN_FLAG)" LIBS="$(LIBS)"

.PHONY: run_profile_task
run_profile_task:
@ # FIXME: can't run for a cross build
$(LLVM_PROF_FILE) $(RUNSHARED) ./$(BUILDPYTHON) $(PROFILE_TASK) || true

.PHONY: build_all_merge_profile
build_all_merge_profile:
$(LLVM_PROF_MERGER)

# Compile Python binary with profile guided optimization.
# To force re-running of the profile task, remove the profile-run-stamp file.
.PHONY: profile-opt
Expand Down
0