Skip to content

Commit 38de7cd

Browse files
committed
add support for clang thin lto via --with-lto=thin
1 parent e915db3 commit 38de7cd

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

configure

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ Optional Packages:
15451545
--with-trace-refs enable tracing references for debugging purpose
15461546
(default is no)
15471547
--with-assertions build with C assertions enabled (default is no)
1548-
--with-lto enable Link-Time-Optimization in any build (default
1548+
--with-lto[=no|thin] enable Link-Time-Optimization in any build (default
15491549
is no)
15501550
--with-hash-algorithm=[fnv|siphash24]
15511551
select hash algorithm for use in Python/pyhash.c
@@ -6585,16 +6585,23 @@ $as_echo_n "checking for --with-lto... " >&6; }
65856585
# Check whether --with-lto was given.
65866586
if test "${with_lto+set}" = set; then :
65876587
withval=$with_lto;
6588-
if test "$withval" != no
6589-
then
6590-
Py_LTO='true'
6591-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6592-
$as_echo "yes" >&6; };
6593-
else
6594-
Py_LTO='false'
6595-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6588+
LTO_ARG=''
6589+
if test "$withval" = no
6590+
then
6591+
Py_LTO='false'
6592+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
65966593
$as_echo "no" >&6; };
6597-
fi
6594+
elif test "$withval" = yes
6595+
then
6596+
Py_LTO='true'
6597+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6598+
$as_echo "yes" >&6; };
6599+
else
6600+
Py_LTO='true'
6601+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$withval\"" >&5
6602+
$as_echo "\"$withval\"" >&6; };
6603+
LTO_ARG="=$withval"
6604+
fi
65986605
else
65996606
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
66006607
$as_echo "no" >&6; }
@@ -6732,11 +6739,11 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
67326739
case $ac_sys_system in
67336740
Darwin*)
67346741
# Any changes made here should be reflected in the GCC+Darwin case below
6735-
LTOFLAGS="-flto -Wl,-export_dynamic"
6736-
LTOCFLAGS="-flto"
6742+
LTOFLAGS="-flto$LTO_ARG -Wl,-export_dynamic"
6743+
LTOCFLAGS="-flto$LTO_ARG"
67376744
;;
67386745
*)
6739-
LTOFLAGS="-flto"
6746+
LTOFLAGS="-flto$LTO_ARG"
67406747
;;
67416748
esac
67426749
;;

configure.ac

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,16 +1360,23 @@ fi
13601360

13611361
# Enable LTO flags
13621362
AC_MSG_CHECKING(for --with-lto)
1363-
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto], [enable Link-Time-Optimization in any build (default is no)]),
1363+
AC_ARG_WITH(lto, AS_HELP_STRING([--with-lto@<:@=no|thin@:>@], [enable Link-Time-Optimization in any build (default is no)]),
1364+
13641365
[
1365-
if test "$withval" != no
1366-
then
1367-
Py_LTO='true'
1368-
AC_MSG_RESULT(yes);
1369-
else
1370-
Py_LTO='false'
1371-
AC_MSG_RESULT(no);
1372-
fi],
1366+
LTO_ARG=''
1367+
if test "$withval" = no
1368+
then
1369+
Py_LTO='false'
1370+
AC_MSG_RESULT(no);
1371+
elif test "$withval" = yes
1372+
then
1373+
Py_LTO='true'
1374+
AC_MSG_RESULT(yes);
1375+
else
1376+
Py_LTO='true'
1377+
AC_MSG_RESULT("$withval");
1378+
LTO_ARG="=$withval"
1379+
fi],
13731380
[AC_MSG_RESULT(no)])
13741381
if test "$Py_LTO" = 'true' ; then
13751382
case $CC in
@@ -1405,11 +1412,11 @@ if test "$Py_LTO" = 'true' ; then
14051412
case $ac_sys_system in
14061413
Darwin*)
14071414
# Any changes made here should be reflected in the GCC+Darwin case below
1408-
LTOFLAGS="-flto -Wl,-export_dynamic"
1409-
LTOCFLAGS="-flto"
1415+
LTOFLAGS="-flto$LTO_ARG -Wl,-export_dynamic"
1416+
LTOCFLAGS="-flto$LTO_ARG"
14101417
;;
14111418
*)
1412-
LTOFLAGS="-flto"
1419+
LTOFLAGS="-flto$LTO_ARG"
14131420
;;
14141421
esac
14151422
;;

0 commit comments

Comments
 (0)