-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-44340: Add support for building with clang thin lto via --with-lto=thin #26585
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Add support for building with clang's "thin" link time optimization using | ||
``--with-lto=thin``. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1545,7 +1545,7 @@ Optional Packages: | |
--with-trace-refs enable tracing references for debugging purpose | ||
(default is no) | ||
--with-assertions build with C assertions enabled (default is no) | ||
--with-lto enable Link-Time-Optimization in any build (default | ||
--with-lto[=no|thin] enable Link-Time-Optimization in any build (default | ||
is no) | ||
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. the current Following options should be available. |
||
--with-hash-algorithm=[fnv|siphash24] | ||
select hash algorithm for use in Python/pyhash.c | ||
|
@@ -6585,16 +6585,23 @@ $as_echo_n "checking for --with-lto... " >&6; } | |
# Check whether --with-lto was given. | ||
if test "${with_lto+set}" = set; then : | ||
withval=$with_lto; | ||
if test "$withval" != no | ||
then | ||
Py_LTO='true' | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | ||
$as_echo "yes" >&6; }; | ||
else | ||
Py_LTO='false' | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | ||
LTO_ARG='' | ||
if test "$withval" = no | ||
then | ||
Py_LTO='false' | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | ||
$as_echo "no" >&6; }; | ||
fi | ||
elif test "$withval" = yes | ||
then | ||
Py_LTO='true' | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | ||
$as_echo "yes" >&6; }; | ||
else | ||
Py_LTO='true' | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$withval\"" >&5 | ||
$as_echo "\"$withval\"" >&6; }; | ||
LTO_ARG="=$withval" | ||
fi | ||
else | ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | ||
$as_echo "no" >&6; } | ||
|
@@ -6732,11 +6739,11 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;} | |
case $ac_sys_system in | ||
Darwin*) | ||
# Any changes made here should be reflected in the GCC+Darwin case below | ||
LTOFLAGS="-flto -Wl,-export_dynamic" | ||
LTOCFLAGS="-flto" | ||
LTOFLAGS="-flto$LTO_ARG -Wl,-export_dynamic" | ||
LTOCFLAGS="-flto$LTO_ARG" | ||
;; | ||
*) | ||
LTOFLAGS="-flto" | ||
LTOFLAGS="-flto$LTO_ARG" | ||
;; | ||
esac | ||
;; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1360,16 +1360,23 @@ fi | |
|
||
# Enable LTO flags | ||
AC_MSG_CHECKING(for --with-lto) | ||
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [enable Link-Time-Optimization in any build (default is no)]), | ||
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto@<:@=no|thin@:>@], [enable Link-Time-Optimization in any build (default is no)]), | ||
|
||
[ | ||
if test "$withval" != no | ||
then | ||
Py_LTO='true' | ||
AC_MSG_RESULT(yes); | ||
else | ||
Py_LTO='false' | ||
AC_MSG_RESULT(no); | ||
fi], | ||
LTO_ARG='' | ||
if test "$withval" = no | ||
then | ||
Py_LTO='false' | ||
AC_MSG_RESULT(no); | ||
elif test "$withval" = yes | ||
then | ||
Py_LTO='true' | ||
AC_MSG_RESULT(yes); | ||
else | ||
Py_LTO='true' | ||
AC_MSG_RESULT("$withval"); | ||
LTO_ARG="=$withval" | ||
fi], | ||
[AC_MSG_RESULT(no)]) | ||
if test "$Py_LTO" = 'true' ; then | ||
case $CC in | ||
|
@@ -1405,11 +1412,11 @@ if test "$Py_LTO" = 'true' ; then | |
case $ac_sys_system in | ||
Darwin*) | ||
# Any changes made here should be reflected in the GCC+Darwin case below | ||
LTOFLAGS="-flto -Wl,-export_dynamic" | ||
LTOCFLAGS="-flto" | ||
LTOFLAGS="-flto$LTO_ARG -Wl,-export_dynamic" | ||
LTOCFLAGS="-flto$LTO_ARG" | ||
;; | ||
*) | ||
LTOFLAGS="-flto" | ||
LTOFLAGS="-flto$LTO_ARG" | ||
Comment on lines
+1415
to
+1419
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. Are the flags ( 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. No. Thinlto is a more recent implementation than the default that is specific to clang. 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. Here's something I think about supporting the LTO options. 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. Then we should probably need show an error if the compiler doesn't support it or/and document the limitation, because otherwise, it seems that is a general option that we are exposing regardless of the compiler. 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. @corona10 - I like it. That's more readable and provides a warning as @pablogsal suggested. 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. @corona10 Nitpick: gcc doesn't have a concept of 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. I think given that these options are only available on clang we should just fail if the compiler is not clang. Adding checks to other compilers one by one is going to be suboptimal because CPython can be compiled with almost any C compiler: 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. Let's discuss the supporting option with the attached PR.
|
||
;; | ||
esac | ||
;; | ||
|
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.
What about