gh-101282: move BOLT config after PGO (gh-104493)

This commit is contained in:
Gregory Szorc 2023-05-14 21:29:44 -07:00 committed by GitHub
parent 48b3617de4
commit 27d8ecd7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 242 additions and 242 deletions

360
configure generated vendored
View File

@ -883,6 +883,11 @@ CFLAGS_NODIST
BASECFLAGS BASECFLAGS
CFLAGS_ALIASING CFLAGS_ALIASING
OPT OPT
MERGE_FDATA
LLVM_BOLT
ac_ct_READELF
READELF
PREBOLT_RULE
LLVM_PROF_FOUND LLVM_PROF_FOUND
LLVM_PROFDATA LLVM_PROFDATA
LLVM_PROF_ERR LLVM_PROF_ERR
@ -890,11 +895,6 @@ LLVM_PROF_FILE
LLVM_PROF_MERGER LLVM_PROF_MERGER
PGO_PROF_USE_FLAG PGO_PROF_USE_FLAG
PGO_PROF_GEN_FLAG PGO_PROF_GEN_FLAG
MERGE_FDATA
LLVM_BOLT
ac_ct_READELF
READELF
PREBOLT_RULE
LLVM_AR_FOUND LLVM_AR_FOUND
LLVM_AR LLVM_AR
PROFILE_TASK PROFILE_TASK
@ -7903,7 +7903,181 @@ fi
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS" LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
fi fi
# Enable bolt flags # Enable PGO flags.
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}llvm-profdata", so it can be a program name with args.
set dummy ${ac_tool_prefix}llvm-profdata; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_LLVM_PROFDATA+:} false; then :
$as_echo_n "(cached) " >&6
else
case $LLVM_PROFDATA in
[\\/]* | ?:[\\/]*)
ac_cv_path_LLVM_PROFDATA="$LLVM_PROFDATA" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in ${llvm_path}
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_LLVM_PROFDATA="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
LLVM_PROFDATA=$ac_cv_path_LLVM_PROFDATA
if test -n "$LLVM_PROFDATA"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_PROFDATA" >&5
$as_echo "$LLVM_PROFDATA" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_path_LLVM_PROFDATA"; then
ac_pt_LLVM_PROFDATA=$LLVM_PROFDATA
# Extract the first word of "llvm-profdata", so it can be a program name with args.
set dummy llvm-profdata; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_ac_pt_LLVM_PROFDATA+:} false; then :
$as_echo_n "(cached) " >&6
else
case $ac_pt_LLVM_PROFDATA in
[\\/]* | ?:[\\/]*)
ac_cv_path_ac_pt_LLVM_PROFDATA="$ac_pt_LLVM_PROFDATA" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in ${llvm_path}
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_LLVM_PROFDATA="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
ac_pt_LLVM_PROFDATA=$ac_cv_path_ac_pt_LLVM_PROFDATA
if test -n "$ac_pt_LLVM_PROFDATA"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_LLVM_PROFDATA" >&5
$as_echo "$ac_pt_LLVM_PROFDATA" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_pt_LLVM_PROFDATA" = x; then
LLVM_PROFDATA="''"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
LLVM_PROFDATA=$ac_pt_LLVM_PROFDATA
fi
else
LLVM_PROFDATA="$ac_cv_path_LLVM_PROFDATA"
fi
if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
then
LLVM_PROF_FOUND="found"
else
LLVM_PROF_FOUND="not-found"
fi
if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
then
found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
if test -n "${found_llvm_profdata}"
then
# llvm-profdata isn't directly in $PATH in some cases.
# https://apple.stackexchange.com/questions/197053/
LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
LLVM_PROF_FOUND=found
{ $as_echo "$as_me:${as_lineno-$LINENO}: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&5
$as_echo "$as_me: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&6;}
fi
fi
LLVM_PROF_ERR=no
case $CC in
*clang*)
# Any changes made here should be reflected in the GCC+Darwin case below
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
if test $LLVM_PROF_FOUND = not-found
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
as_fn_error $? "llvm-profdata is required for a --enable-optimizations build but could not be found." "$LINENO" 5
fi
fi
;;
*gcc*)
case $ac_sys_system in
Darwin*)
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
if test "${LLVM_PROF_FOUND}" = "not-found"
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
as_fn_error $? "llvm-profdata is required for a --enable-optimizations build but could not be found." "$LINENO" 5
fi
fi
;;
*)
PGO_PROF_GEN_FLAG="-fprofile-generate"
PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
LLVM_PROF_MERGER="true"
LLVM_PROF_FILE=""
;;
esac
;;
*icc*)
PGO_PROF_GEN_FLAG="-prof-gen"
PGO_PROF_USE_FLAG="-prof-use"
LLVM_PROF_MERGER="true"
LLVM_PROF_FILE=""
;;
esac
# BOLT optimization. Always configured after PGO since it always runs after PGO.
Py_BOLT='false' Py_BOLT='false'
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-bolt" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-bolt" >&5
$as_echo_n "checking for --enable-bolt... " >&6; } $as_echo_n "checking for --enable-bolt... " >&6; }
@ -8300,180 +8474,6 @@ $as_echo "\"Found merge-fdata\"" >&6; }
fi fi
fi fi
# Enable PGO flags.
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}llvm-profdata", so it can be a program name with args.
set dummy ${ac_tool_prefix}llvm-profdata; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_LLVM_PROFDATA+:} false; then :
$as_echo_n "(cached) " >&6
else
case $LLVM_PROFDATA in
[\\/]* | ?:[\\/]*)
ac_cv_path_LLVM_PROFDATA="$LLVM_PROFDATA" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in ${llvm_path}
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_LLVM_PROFDATA="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
LLVM_PROFDATA=$ac_cv_path_LLVM_PROFDATA
if test -n "$LLVM_PROFDATA"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_PROFDATA" >&5
$as_echo "$LLVM_PROFDATA" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_path_LLVM_PROFDATA"; then
ac_pt_LLVM_PROFDATA=$LLVM_PROFDATA
# Extract the first word of "llvm-profdata", so it can be a program name with args.
set dummy llvm-profdata; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_ac_pt_LLVM_PROFDATA+:} false; then :
$as_echo_n "(cached) " >&6
else
case $ac_pt_LLVM_PROFDATA in
[\\/]* | ?:[\\/]*)
ac_cv_path_ac_pt_LLVM_PROFDATA="$ac_pt_LLVM_PROFDATA" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in ${llvm_path}
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_LLVM_PROFDATA="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
ac_pt_LLVM_PROFDATA=$ac_cv_path_ac_pt_LLVM_PROFDATA
if test -n "$ac_pt_LLVM_PROFDATA"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_LLVM_PROFDATA" >&5
$as_echo "$ac_pt_LLVM_PROFDATA" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_pt_LLVM_PROFDATA" = x; then
LLVM_PROFDATA="''"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
LLVM_PROFDATA=$ac_pt_LLVM_PROFDATA
fi
else
LLVM_PROFDATA="$ac_cv_path_LLVM_PROFDATA"
fi
if test -n "${LLVM_PROFDATA}" -a -x "${LLVM_PROFDATA}"
then
LLVM_PROF_FOUND="found"
else
LLVM_PROF_FOUND="not-found"
fi
if test "$ac_sys_system" = "Darwin" -a "${LLVM_PROF_FOUND}" = "not-found"
then
found_llvm_profdata=`/usr/bin/xcrun -find llvm-profdata 2>/dev/null`
if test -n "${found_llvm_profdata}"
then
# llvm-profdata isn't directly in $PATH in some cases.
# https://apple.stackexchange.com/questions/197053/
LLVM_PROFDATA='/usr/bin/xcrun llvm-profdata'
LLVM_PROF_FOUND=found
{ $as_echo "$as_me:${as_lineno-$LINENO}: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&5
$as_echo "$as_me: llvm-profdata found via xcrun: ${LLVM_PROFDATA}" >&6;}
fi
fi
LLVM_PROF_ERR=no
case $CC in
*clang*)
# Any changes made here should be reflected in the GCC+Darwin case below
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
if test $LLVM_PROF_FOUND = not-found
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
as_fn_error $? "llvm-profdata is required for a --enable-optimizations build but could not be found." "$LINENO" 5
fi
fi
;;
*gcc*)
case $ac_sys_system in
Darwin*)
PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
if test "${LLVM_PROF_FOUND}" = "not-found"
then
LLVM_PROF_ERR=yes
if test "${REQUIRE_PGO}" = "yes"
then
as_fn_error $? "llvm-profdata is required for a --enable-optimizations build but could not be found." "$LINENO" 5
fi
fi
;;
*)
PGO_PROF_GEN_FLAG="-fprofile-generate"
PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
LLVM_PROF_MERGER="true"
LLVM_PROF_FILE=""
;;
esac
;;
*icc*)
PGO_PROF_GEN_FLAG="-prof-gen"
PGO_PROF_USE_FLAG="-prof-use"
LLVM_PROF_MERGER="true"
LLVM_PROF_FILE=""
;;
esac
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
# merged with this chunk of code? # merged with this chunk of code?

View File

@ -1929,68 +1929,6 @@ if test "$Py_LTO" = 'true' ; then
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS" LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
fi fi
# Enable bolt flags
Py_BOLT='false'
AC_MSG_CHECKING(for --enable-bolt)
AC_ARG_ENABLE(bolt, AS_HELP_STRING(
[--enable-bolt],
[enable usage of the llvm-bolt post-link optimizer (default is no)]),
[
if test "$enableval" != no
then
Py_BOLT='true'
AC_MSG_RESULT(yes);
else
Py_BOLT='false'
AC_MSG_RESULT(no);
fi],
[AC_MSG_RESULT(no)])
AC_SUBST(PREBOLT_RULE)
if test "$Py_BOLT" = 'true' ; then
PREBOLT_RULE="${DEF_MAKE_ALL_RULE}"
DEF_MAKE_ALL_RULE="bolt-opt"
DEF_MAKE_RULE="build_all"
AC_SUBST(READELF)
AC_CHECK_TOOLS(READELF, [readelf], "notfound")
if test "$READELF" == "notfound"
then
AC_MSG_ERROR([readelf is required for a --enable-bolt build but could not be found.])
fi
# -fno-reorder-blocks-and-partition is required for bolt to work.
# Possibly GCC only.
AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[
CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition"
])
# These flags are required for bolt to work:
LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"
# These flags are required to get good performance from bolt:
CFLAGS_NODIST="$CFLAGS_NODIST -fno-pie"
# We want to add these no-pie flags to linking executables but not shared libraries:
LINKCC="$LINKCC -fno-pie -no-pie"
AC_SUBST(LLVM_BOLT)
AC_PATH_TOOL(LLVM_BOLT, llvm-bolt, '', ${llvm_path})
if test -n "${LLVM_BOLT}" -a -x "${LLVM_BOLT}"
then
AC_MSG_RESULT("Found llvm-bolt")
else
AC_MSG_ERROR([llvm-bolt is required for a --enable-bolt build but could not be found.])
fi
AC_SUBST(MERGE_FDATA)
AC_PATH_TOOL(MERGE_FDATA, merge-fdata, '', ${llvm_path})
if test -n "${MERGE_FDATA}" -a -x "${MERGE_FDATA}"
then
AC_MSG_RESULT("Found merge-fdata")
else
AC_MSG_ERROR([merge-fdata is required for a --enable-bolt build but could not be found.])
fi
fi
# Enable PGO flags. # Enable PGO flags.
AC_SUBST(PGO_PROF_GEN_FLAG) AC_SUBST(PGO_PROF_GEN_FLAG)
AC_SUBST(PGO_PROF_USE_FLAG) AC_SUBST(PGO_PROF_USE_FLAG)
@ -2067,6 +2005,68 @@ case $CC in
;; ;;
esac esac
# BOLT optimization. Always configured after PGO since it always runs after PGO.
Py_BOLT='false'
AC_MSG_CHECKING(for --enable-bolt)
AC_ARG_ENABLE(bolt, AS_HELP_STRING(
[--enable-bolt],
[enable usage of the llvm-bolt post-link optimizer (default is no)]),
[
if test "$enableval" != no
then
Py_BOLT='true'
AC_MSG_RESULT(yes);
else
Py_BOLT='false'
AC_MSG_RESULT(no);
fi],
[AC_MSG_RESULT(no)])
AC_SUBST(PREBOLT_RULE)
if test "$Py_BOLT" = 'true' ; then
PREBOLT_RULE="${DEF_MAKE_ALL_RULE}"
DEF_MAKE_ALL_RULE="bolt-opt"
DEF_MAKE_RULE="build_all"
AC_SUBST(READELF)
AC_CHECK_TOOLS(READELF, [readelf], "notfound")
if test "$READELF" == "notfound"
then
AC_MSG_ERROR([readelf is required for a --enable-bolt build but could not be found.])
fi
# -fno-reorder-blocks-and-partition is required for bolt to work.
# Possibly GCC only.
AX_CHECK_COMPILE_FLAG([-fno-reorder-blocks-and-partition],[
CFLAGS_NODIST="$CFLAGS_NODIST -fno-reorder-blocks-and-partition"
])
# These flags are required for bolt to work:
LDFLAGS_NODIST="$LDFLAGS_NODIST -Wl,--emit-relocs"
# These flags are required to get good performance from bolt:
CFLAGS_NODIST="$CFLAGS_NODIST -fno-pie"
# We want to add these no-pie flags to linking executables but not shared libraries:
LINKCC="$LINKCC -fno-pie -no-pie"
AC_SUBST(LLVM_BOLT)
AC_PATH_TOOL(LLVM_BOLT, llvm-bolt, '', ${llvm_path})
if test -n "${LLVM_BOLT}" -a -x "${LLVM_BOLT}"
then
AC_MSG_RESULT("Found llvm-bolt")
else
AC_MSG_ERROR([llvm-bolt is required for a --enable-bolt build but could not be found.])
fi
AC_SUBST(MERGE_FDATA)
AC_PATH_TOOL(MERGE_FDATA, merge-fdata, '', ${llvm_path})
if test -n "${MERGE_FDATA}" -a -x "${MERGE_FDATA}"
then
AC_MSG_RESULT("Found merge-fdata")
else
AC_MSG_ERROR([merge-fdata is required for a --enable-bolt build but could not be found.])
fi
fi
# XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be # XXX Shouldn't the code above that fiddles with BASECFLAGS and OPT be
# merged with this chunk of code? # merged with this chunk of code?