-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-101525: Use only safe identical code folding with BOLT #134642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2129,6 +2129,29 @@ if test "$Py_BOLT" = 'true' ; then | |||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||
AC_MSG_ERROR([merge-fdata is required for a --enable-bolt build but could not be found.]) | ||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
py_bolt_icf_flag="-icf=safe" | ||||||||||||||||||||||||||||||||||||||||||||||
AC_CACHE_CHECK( | ||||||||||||||||||||||||||||||||||||||||||||||
[whether ${LLVM_BOLT} supports safe identical code folding], | ||||||||||||||||||||||||||||||||||||||||||||||
[py_cv_bolt_icf_safe], | ||||||||||||||||||||||||||||||||||||||||||||||
[ | ||||||||||||||||||||||||||||||||||||||||||||||
saved_cflags="$CFLAGS" | ||||||||||||||||||||||||||||||||||||||||||||||
saved_ldflags="$LDFLAGS" | ||||||||||||||||||||||||||||||||||||||||||||||
CFLAGS="$CFLAGS_NODIST" | ||||||||||||||||||||||||||||||||||||||||||||||
LDFLAGS="$LDFLAGS_NODIST" | ||||||||||||||||||||||||||||||||||||||||||||||
AC_LINK_IFELSE( | ||||||||||||||||||||||||||||||||||||||||||||||
[AC_LANG_PROGRAM([[]], [[]])], | ||||||||||||||||||||||||||||||||||||||||||||||
[py_cv_bolt_icf_safe=no | ||||||||||||||||||||||||||||||||||||||||||||||
${LLVM_BOLT} -icf=safe -o conftest.bolt conftest$EXEEXT >&AS_MESSAGE_LOG_FD 2>&1 dnl | ||||||||||||||||||||||||||||||||||||||||||||||
&& py_cv_bolt_icf_safe=yes], | ||||||||||||||||||||||||||||||||||||||||||||||
[AC_MSG_FAILURE([could not compile empty test program])]) | ||||||||||||||||||||||||||||||||||||||||||||||
CFLAGS="$saved_cflags" | ||||||||||||||||||||||||||||||||||||||||||||||
LDFLAGS="$saved_ldflags" | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+2138
to
+2149
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using our
Suggested change
Moreover, the double brackets ( |
||||||||||||||||||||||||||||||||||||||||||||||
] | ||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||
if test "$py_cv_bolt_icf_safe" = no; then | ||||||||||||||||||||||||||||||||||||||||||||||
py_bolt_icf_flag="" | ||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
dnl Enable BOLT of libpython if built. | ||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -2184,7 +2207,7 @@ then | |||||||||||||||||||||||||||||||||||||||||||||
-reorder-blocks=ext-tsp | ||||||||||||||||||||||||||||||||||||||||||||||
-reorder-functions=cdsort | ||||||||||||||||||||||||||||||||||||||||||||||
-split-functions | ||||||||||||||||||||||||||||||||||||||||||||||
-icf=1 | ||||||||||||||||||||||||||||||||||||||||||||||
${py_bolt_icf_flag} | ||||||||||||||||||||||||||||||||||||||||||||||
-inline-all | ||||||||||||||||||||||||||||||||||||||||||||||
-split-eh | ||||||||||||||||||||||||||||||||||||||||||||||
-reorder-functions-use-hot-size | ||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to be a bit more descriptive than "compilation failed".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The autoconf syntax here is a little confusing. This message isn't from the attempt to optimize with
-icf=safe
, it's from actually compiling the test program. BOLT is a post-link optimizer, so we give it a compiled and linked executable as an argument. (There is also ICF support in many linkers, to make things more confusing.) I'm using autoconf's function for running test-compiles for the side effect of creating a binary to pass to BOLT, but we need to handle the case where the compile, for whatever reason, fails. I don't expect anyone to hit this error because if you couldn't compile programs you probably couldn't get this far in ./configure anyway, but it's good to have something for the "can't happen" case.The pseudo-Python equivalent of this check is
It does occur to me, writing this out, that you could theoretically hit this failure case if your compiler and linker don't support the flags needed to produce a BOLT-able binary (
Wl,--emit-relocs -fno-pie -no-pie
), because this is the first time we're asking autoconf to use those flags in a test-compile. I have no idea why you would ask for BOLT if you don't have a vaguely compatible compiler, though, and you'd previously get a random compile error at some later point in the process, so I don't think this is making anything worse... but we could change the message to "could not compile and link test program with flags needed for BOLT" or something.I would also accept the argument that I need wider indentation or some comments or something to make the autoconf readable.