Skip to content

Commit 5d9762e

Browse files
authored
gh-101525: Fix make test if the --enable-bolt enabled (gh-103574)
1 parent 76933df commit 5d9762e

File tree

3 files changed

+128
-7
lines changed

3 files changed

+128
-7
lines changed

Makefile.pre.in

+13-7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ CC= @CC@
3838
CXX= @CXX@
3939
LINKCC= @LINKCC@
4040
AR= @AR@
41+
READELF= @READELF@
4142
SOABI= @SOABI@
4243
LDVERSION= @LDVERSION@
4344
LIBPYTHON= @LIBPYTHON@
@@ -670,13 +671,18 @@ profile-opt: profile-run-stamp
670671

671672
bolt-opt: @PREBOLT_RULE@
672673
rm -f *.fdata
673-
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst
674-
./$(BUILDPYTHON).bolt_inst $(PROFILE_TASK) || true
675-
@MERGE_FDATA@ $(BUILDPYTHON).*.fdata > $(BUILDPYTHON).fdata
676-
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata -update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot
677-
rm -f *.fdata
678-
rm -f $(BUILDPYTHON).bolt_inst
679-
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
674+
@if $(READELF) -p .note.bolt_info $(BUILDPYTHON) | grep BOLT > /dev/null; then\
675+
echo "skip: $(BUILDPYTHON) is already BOLTed."; \
676+
else \
677+
@LLVM_BOLT@ ./$(BUILDPYTHON) -instrument -instrumentation-file-append-pid -instrumentation-file=$(abspath $(BUILDPYTHON).bolt) -o $(BUILDPYTHON).bolt_inst; \
678+
./$(BUILDPYTHON).bolt_inst $(PROFILE_TASK) || true; \
679+
@MERGE_FDATA@ $(BUILDPYTHON).*.fdata > $(BUILDPYTHON).fdata; \
680+
@LLVM_BOLT@ ./$(BUILDPYTHON) -o $(BUILDPYTHON).bolt -data=$(BUILDPYTHON).fdata -update-debug-sections -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions -icf=1 -inline-all -split-eh -reorder-functions-use-hot-size -peepholes=none -jump-tables=aggressive -inline-ap -indirect-call-promotion=all -dyno-stats -use-gnu-stack -frame-opt=hot; \
681+
rm -f *.fdata; \
682+
rm -f $(BUILDPYTHON).bolt_inst; \
683+
mv $(BUILDPYTHON).bolt $(BUILDPYTHON); \
684+
fi
685+
680686

681687
# Compile and run with gcov
682688
.PHONY=coverage coverage-lcov coverage-report

configure

+108
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+7
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,13 @@ if test "$Py_BOLT" = 'true' ; then
19381938
DEF_MAKE_ALL_RULE="bolt-opt"
19391939
DEF_MAKE_RULE="build_all"
19401940

1941+
AC_SUBST(READELF)
1942+
AC_CHECK_TOOLS(READELF, [readelf], "notfound")
1943+
if test "$READELF" == "notfound"
1944+
then
1945+
AC_MSG_ERROR([readelf is required for a --enable-bolt build but could not be found.])
1946+
fi
1947+
19411948
# -fno-reorder-blocks-and-partition is required for bolt to work.
19421949
# Possibly GCC only.
19431950
AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[

0 commit comments

Comments
 (0)