bpo-44340: Add support for building with clang full/thin lto (GH-27231) · python/cpython@b2cf251 · GitHub
Skip to content

Commit b2cf251

Browse files
authored
bpo-44340: Add support for building with clang full/thin lto (GH-27231)
1 parent 635bfe8 commit b2cf251

5 files changed

Lines changed: 107 additions & 33 deletions

File tree

Doc/using/configure.rst

Lines changed: 4 additions & 1 deletion
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add support for building with clang thin lto via --with-lto=thin/full. Patch
2+
by Dong-hee Na and Brett Holman.

aclocal.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
1+
# generated automatically by aclocal 1.16.3 -*- Autoconf -*-
22

3-
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
3+
# Copyright (C) 1996-2020 Free Software Foundation, Inc.
44

55
# This file is free software; the Free Software Foundation
66
# gives unlimited permission to copy and/or distribute it,

configure

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,8 @@ 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=[full|thin|no|yes]
1549+
enable Link-Time-Optimization in any build (default
15491550
is no)
15501551
--with-hash-algorithm=[fnv|siphash24]
15511552
select hash algorithm for use in Python/pyhash.c
@@ -3039,27 +3040,27 @@ VERSION=3.11
30393040

30403041
SOVERSION=1.0
30413042

3042-
# The later defininition of _XOPEN_SOURCE disables certain features
3043+
# The later definition of _XOPEN_SOURCE disables certain features
30433044
# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
30443045

30453046
$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
30463047

30473048

3048-
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
3049+
# The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
30493050
# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
30503051
# them.
30513052

30523053
$as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h
30533054

30543055

3055-
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
3056+
# The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
30563057
# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
30573058
# them.
30583059

30593060
$as_echo "#define __BSD_VISIBLE 1" >>confdefs.h
30603061

30613062

3062-
# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
3063+
# The later definition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
30633064
# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
30643065
# them.
30653066

@@ -6585,16 +6586,36 @@ $as_echo_n "checking for --with-lto... " >&6; }
65856586
# Check whether --with-lto was given.
65866587
if test "${with_lto+set}" = set; then :
65876588
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
6596-
$as_echo "no" >&6; };
6597-
fi
6589+
case "$withval" in
6590+
full)
6591+
Py_LTO='true'
6592+
Py_LTO_POLICY='full'
6593+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6594+
$as_echo "yes" >&6; }
6595+
;;
6596+
thin)
6597+
Py_LTO='true'
6598+
Py_LTO_POLICY='thin'
6599+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6600+
$as_echo "yes" >&6; }
6601+
;;
6602+
yes)
6603+
Py_LTO='true'
6604+
Py_LTO_POLICY='default'
6605+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
6606+
$as_echo "yes" >&6; }
6607+
;;
6608+
no)
6609+
Py_LTO='false'
6610+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6611+
$as_echo "no" >&6; }
6612+
;;
6613+
*)
6614+
Py_LTO='false'
6615+
as_fn_error $? "unknown lto option: '$withval'" "$LINENO" 5
6616+
;;
6617+
esac
6618+
65986619
else
65996620
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
66006621
$as_echo "no" >&6; }
@@ -6732,15 +6753,30 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
67326753
case $ac_sys_system in
67336754
Darwin*)
67346755
# Any changes made here should be reflected in the GCC+Darwin case below
6735-
LTOFLAGS="-flto -Wl,-export_dynamic"
6736-
LTOCFLAGS="-flto"
6756+
if test $Py_LTO_POLICY = default
6757+
then
6758+
LTOFLAGS="-flto -Wl,-export_dynamic"
6759+
LTOCFLAGS="-flto"
6760+
else
6761+
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic"
6762+
LTOCFLAGS="-flto=${Py_LTO_POLICY}"
6763+
fi
67376764
;;
67386765
*)
6739-
LTOFLAGS="-flto"
6766+
if test $Py_LTO_POLICY = default
6767+
then
6768+
LTOFLAGS="-flto"
6769+
else
6770+
LTOFLAGS="-flto=${Py_LTO_POLICY}"
6771+
fi
67406772
;;
67416773
esac
67426774
;;
67436775
*gcc*)
6776+
if test $Py_LTO_POLICY = thin
6777+
then
6778+
as_fn_error $? "thin lto is not supported under gcc compiler." "$LINENO" 5
6779+
fi
67446780
case $ac_sys_system in
67456781
Darwin*)
67466782
LTOFLAGS="-flto -Wl,-export_dynamic"

configure.ac

Lines changed: 45 additions & 12 deletions

0 commit comments

Comments
 (0)