diff options
author | Dong-hee Na <donghee.na@python.org> | 2021-07-19 10:52:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 10:52:56 (GMT) |
commit | b2cf2513f9184c850a69fab718532b4f7c6a003d (patch) | |
tree | 825b69796206e39d8703842958ef2d19ea951ca9 /configure.ac | |
parent | 635bfe8162981332b36cc556bac78e869af579c2 (diff) | |
download | cpython-b2cf2513f9184c850a69fab718532b4f7c6a003d.zip cpython-b2cf2513f9184c850a69fab718532b4f7c6a003d.tar.gz cpython-b2cf2513f9184c850a69fab718532b4f7c6a003d.tar.bz2 |
bpo-44340: Add support for building with clang full/thin lto (GH-27231)
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 57 |
1 files changed, 45 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index 11dd84f..aaff79f 100644 --- a/configure.ac +++ b/configure.ac @@ -1360,16 +1360,34 @@ 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=@<:@full|thin|no|yes@:>@], [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], +case "$withval" in + full) + Py_LTO='true' + Py_LTO_POLICY='full' + AC_MSG_RESULT(yes) + ;; + thin) + Py_LTO='true' + Py_LTO_POLICY='thin' + AC_MSG_RESULT(yes) + ;; + yes) + Py_LTO='true' + Py_LTO_POLICY='default' + AC_MSG_RESULT(yes) + ;; + no) + Py_LTO='false' + AC_MSG_RESULT(no) + ;; + *) + Py_LTO='false' + AC_MSG_ERROR([unknown lto option: '$withval']) + ;; +esac +], [AC_MSG_RESULT(no)]) if test "$Py_LTO" = 'true' ; then case $CC in @@ -1405,15 +1423,30 @@ 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" + if test $Py_LTO_POLICY = default + then + LTOFLAGS="-flto -Wl,-export_dynamic" + LTOCFLAGS="-flto" + else + LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic" + LTOCFLAGS="-flto=${Py_LTO_POLICY}" + fi ;; *) - LTOFLAGS="-flto" + if test $Py_LTO_POLICY = default + then + LTOFLAGS="-flto" + else + LTOFLAGS="-flto=${Py_LTO_POLICY}" + fi ;; esac ;; *gcc*) + if test $Py_LTO_POLICY = thin + then + AC_MSG_ERROR([thin lto is not supported under gcc compiler.]) + fi case $ac_sys_system in Darwin*) LTOFLAGS="-flto -Wl,-export_dynamic" |