Skip to content

Commit 40c28bb

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 8c0596c commit 40c28bb

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

725+
BOLT_INSTRUMENT_FLAGS ?= @BOLT_INSTRUMENT_FLAGS@
726+
BOLT_APPLY_FLAGS ?= @BOLT_APPLY_FLAGS@
727+
725728
# Remove traces of bolt.
726729
.PHONY: clean-bolt
727730
clean-bolt:
@@ -755,7 +758,7 @@ profile-bolt-instrument-stamp: profile-bolt-prebuild-stamp
755758
done
756759
# Ensure prior BOLT state is purged.
757760
$(MAKE) clean-bolt
758-
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst
761+
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst $(BOLT_INSTRUMENT_FLAGS)
759762
touch $@
760763

761764
profile-bolt-run-stamp: profile-bolt-instrument-stamp
@@ -767,7 +770,7 @@ profile-bolt-analyze-stamp: profile-bolt-run-stamp
767770
touch $@
768771

769772
profile-bolt-apply-stamp: profile-bolt-analyze-stamp
770-
@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
773+
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata $(BOLT_APPLY_FLAGS)
771774
mv $(BUILDPYTHON) $(BUILDPYTHON).prebolt
772775
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
773776
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)