Skip to content

Commit 2821eb2

Browse files
committed
gh-xxxx: move BOLT arguments to configure
This allows easily customizing the arguments to `llvm-bolt` without having to edit the Makefile. Arguments can be passed to configure and are reflected in configure output, which can be useful for log analysis. When defined in the Makefile we use `?=` syntax so the flags can be overridden via `make VAR=VALUE` syntax or via environment variables. Super useful for iterating on different BOLT flags.
1 parent 5a0c351 commit 2821eb2

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

Makefile.pre.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ profile-pgo-apply-stamp: profile-pgo-analyze-stamp
698698
# List of binaries that BOLT runs on.
699699
BOLT_BINARIES = $(BUILDPYTHON)
700700

701+
BOLT_INSTRUMENT_FLAGS ?= @BOLT_INSTRUMENT_FLAGS@
702+
BOLT_APPLY_FLAGS ?= @BOLT_APPLY_FLAGS@
703+
701704
# Remove traces of bolt.
702705
.PHONY: clean-bolt
703706
clean-bolt:
@@ -731,7 +734,7 @@ profile-bolt-instrument-stamp: profile-bolt-prebuild-stamp
731734
done
732735
# Ensure prior BOLT state is purged.
733736
$(MAKE) clean-bolt
734-
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst
737+
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst $(BOLT_INSTRUMENT_FLAGS)
735738
touch $@
736739

737740
profile-bolt-run-stamp: profile-bolt-instrument-stamp
@@ -743,7 +746,7 @@ profile-bolt-analyze-stamp: profile-bolt-run-stamp
743746
touch $@
744747

745748
profile-bolt-apply-stamp: profile-bolt-analyze-stamp
746-
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata -update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=all -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot
749+
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata $(BOLT_APPLY_FLAGS)
747750
mv $(BUILDPYTHON) $(BUILDPYTHON).prebolt
748751
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
749752
touch $@

configure

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,6 +2066,22 @@ if test "$Py_BOLT" = 'true' ; then
20662066
fi
20672067
fi
20682068

2069+
AC_ARG_VAR(BOLT_INSTRUMENT_FLAGS, Arguments to llvm-bolt when instrumenting binaries)
2070+
AC_MSG_CHECKING(BOLT_INSTRUMENT_FLAGS)
2071+
if test -z "${BOLT_INSTRUMENT_FLAGS}"
2072+
then
2073+
BOLT_INSTRUMENT_FLAGS=
2074+
fi
2075+
AC_MSG_RESULT($BOLT_INSTRUMENT_FLAGS)
2076+
2077+
AC_ARG_VAR(BOLT_APPLY_FLAGS, Arguments to llvm-bolt when creating a BOLT optimized binary)
2078+
AC_MSG_CHECKING(BOLT_APPLY_FLAGS)
2079+
if test -z "${BOLT_APPLY_FLAGS}"
2080+
then
2081+
BOLT_APPLY_FLAGS="-update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions=3 -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=all -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot"
2082+
fi
2083+
AC_MSG_RESULT($BOLT_APPLY_FLAGS)
2084+
20692085
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
20702086
# merged with this chunk of code?
20712087

0 commit comments

Comments
 (0)