Skip to content

Commit c8759fd

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 f215844 commit c8759fd

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
@@ -724,6 +724,9 @@ profile-pgo-apply-stamp: profile-pgo-analyze-stamp
724724
# List of binaries that BOLT runs on.
725725
BOLT_BINARIES = $(BUILDPYTHON)
726726

727+
BOLT_INSTRUMENT_FLAGS ?= @BOLT_INSTRUMENT_FLAGS@
728+
BOLT_APPLY_FLAGS ?= @BOLT_APPLY_FLAGS@
729+
727730
# Remove traces of bolt.
728731
.PHONY: clean-bolt
729732
clean-bolt:
@@ -757,7 +760,7 @@ profile-bolt-instrument-stamp: profile-bolt-prebuild-stamp
757760
done
758761
# Ensure prior BOLT state is purged.
759762
$(MAKE) clean-bolt
760-
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst
763+
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst $(BOLT_INSTRUMENT_FLAGS)
761764
touch $@
762765

763766
profile-bolt-run-stamp: profile-bolt-instrument-stamp
@@ -769,7 +772,7 @@ profile-bolt-analyze-stamp: profile-bolt-run-stamp
769772
touch $@
770773

771774
profile-bolt-apply-stamp: profile-bolt-analyze-stamp
772-
@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
775+
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata $(BOLT_APPLY_FLAGS)
773776
mv $(BUILDPYTHON) $(BUILDPYTHON).prebolt
774777
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
775778
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
@@ -2083,6 +2083,22 @@ if test "$Py_BOLT" = 'true' ; then
20832083
fi
20842084
fi
20852085

2086+
AC_ARG_VAR(BOLT_INSTRUMENT_FLAGS, Arguments to llvm-bolt when instrumenting binaries)
2087+
AC_MSG_CHECKING(BOLT_INSTRUMENT_FLAGS)
2088+
if test -z "${BOLT_INSTRUMENT_FLAGS}"
2089+
then
2090+
BOLT_INSTRUMENT_FLAGS=
2091+
fi
2092+
AC_MSG_RESULT($BOLT_INSTRUMENT_FLAGS)
2093+
2094+
AC_ARG_VAR(BOLT_APPLY_FLAGS, Arguments to llvm-bolt when creating a BOLT optimized binary)
2095+
AC_MSG_CHECKING(BOLT_APPLY_FLAGS)
2096+
if test -z "${BOLT_APPLY_FLAGS}"
2097+
then
2098+
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"
2099+
fi
2100+
AC_MSG_RESULT($BOLT_APPLY_FLAGS)
2101+
20862102
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
20872103
# merged with this chunk of code?
20882104

0 commit comments

Comments
 (0)