Skip to content

Commit

Permalink
bpo-43109: Fix --with-lto configure option on macOS (GH-26341) (GH-26343
Browse files Browse the repository at this point in the history
)

Allow --with-lto configure option to work with Apple-supplied Xcode or
Command Line Tools which do not provide llvm-ar.
(cherry picked from commit 59acfd4)

Co-authored-by: Ned Deily <nad@python.org>
  • Loading branch information
miss-islington and ned-deily committed May 25, 2021
1 parent ab4da07 commit 3af61a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
@@ -0,0 +1,2 @@
Allow --with-lto configure option to work with Apple-supplied Xcode or
Command Line Tools.
9 changes: 6 additions & 3 deletions configure
Expand Up @@ -6650,10 +6650,11 @@ fi
fi
if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
then
found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
# The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
if test -n "${found_llvm_ar}"
then
LLVM_AR='/usr/bin/xcrun llvm-ar'
LLVM_AR='/usr/bin/xcrun ar'
LLVM_AR_FOUND=found
{ $as_echo "$as_me:${as_lineno-$LINENO}: llvm-ar found via xcrun: ${LLVM_AR}" >&5
$as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
Expand All @@ -6671,6 +6672,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
Darwin*)
# Any changes made here should be reflected in the GCC+Darwin case below
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOCFLAGS="-flto"
;;
*)
LTOFLAGS="-flto"
Expand All @@ -6681,6 +6683,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
case $ac_sys_system in
Darwin*)
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOCFLAGS="-flto"
;;
*)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
Expand All @@ -6696,7 +6699,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
LTOFLAGS="$LTOFLAGS -g"
fi

CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
fi

Expand Down
9 changes: 6 additions & 3 deletions configure.ac
Expand Up @@ -1388,10 +1388,11 @@ if test "$Py_LTO" = 'true' ; then
fi
if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
then
found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
# The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
if test -n "${found_llvm_ar}"
then
LLVM_AR='/usr/bin/xcrun llvm-ar'
LLVM_AR='/usr/bin/xcrun ar'
LLVM_AR_FOUND=found
AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}])
fi
Expand All @@ -1408,6 +1409,7 @@ if test "$Py_LTO" = 'true' ; then
Darwin*)
# Any changes made here should be reflected in the GCC+Darwin case below
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOCFLAGS="-flto"
;;
*)
LTOFLAGS="-flto"
Expand All @@ -1418,6 +1420,7 @@ if test "$Py_LTO" = 'true' ; then
case $ac_sys_system in
Darwin*)
LTOFLAGS="-flto -Wl,-export_dynamic"
LTOCFLAGS="-flto"
;;
*)
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
Expand All @@ -1433,7 +1436,7 @@ if test "$Py_LTO" = 'true' ; then
LTOFLAGS="$LTOFLAGS -g"
fi

CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
fi

Expand Down

0 comments on commit 3af61a7

Please sign in to comment.