Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59acfd4

Browse files
authored
bpo-43109: Fix --with-lto configure option on macOS (GH-26341)
Allow --with-lto configure option to work with Apple-supplied Xcode or Command Line Tools which do not provide llvm-ar.
1 parent 2f3a878 commit 59acfd4

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Allow --with-lto configure option to work with Apple-supplied Xcode or
2+
Command Line Tools.

configure

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6711,10 +6711,11 @@ fi
67116711
fi
67126712
if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
67136713
then
6714-
found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
6714+
# The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
6715+
found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
67156716
if test -n "${found_llvm_ar}"
67166717
then
6717-
LLVM_AR='/usr/bin/xcrun llvm-ar'
6718+
LLVM_AR='/usr/bin/xcrun ar'
67186719
LLVM_AR_FOUND=found
67196720
{ $as_echo "$as_me:${as_lineno-$LINENO}: llvm-ar found via xcrun: ${LLVM_AR}" >&5
67206721
$as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
@@ -6732,6 +6733,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
67326733
Darwin*)
67336734
# Any changes made here should be reflected in the GCC+Darwin case below
67346735
LTOFLAGS="-flto -Wl,-export_dynamic"
6736+
LTOCFLAGS="-flto"
67356737
;;
67366738
*)
67376739
LTOFLAGS="-flto"
@@ -6742,6 +6744,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
67426744
case $ac_sys_system in
67436745
Darwin*)
67446746
LTOFLAGS="-flto -Wl,-export_dynamic"
6747+
LTOCFLAGS="-flto"
67456748
;;
67466749
*)
67476750
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
@@ -6757,7 +6760,7 @@ $as_echo "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
67576760
LTOFLAGS="$LTOFLAGS -g"
67586761
fi
67596762

6760-
CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
6763+
CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
67616764
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
67626765
fi
67636766

configure.ac

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,10 +1385,11 @@ if test "$Py_LTO" = 'true' ; then
13851385
fi
13861386
if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
13871387
then
1388-
found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
1388+
# The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
1389+
found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
13891390
if test -n "${found_llvm_ar}"
13901391
then
1391-
LLVM_AR='/usr/bin/xcrun llvm-ar'
1392+
LLVM_AR='/usr/bin/xcrun ar'
13921393
LLVM_AR_FOUND=found
13931394
AC_MSG_NOTICE([llvm-ar found via xcrun: ${LLVM_AR}])
13941395
fi
@@ -1405,6 +1406,7 @@ if test "$Py_LTO" = 'true' ; then
14051406
Darwin*)
14061407
# Any changes made here should be reflected in the GCC+Darwin case below
14071408
LTOFLAGS="-flto -Wl,-export_dynamic"
1409+
LTOCFLAGS="-flto"
14081410
;;
14091411
*)
14101412
LTOFLAGS="-flto"
@@ -1415,6 +1417,7 @@ if test "$Py_LTO" = 'true' ; then
14151417
case $ac_sys_system in
14161418
Darwin*)
14171419
LTOFLAGS="-flto -Wl,-export_dynamic"
1420+
LTOCFLAGS="-flto"
14181421
;;
14191422
*)
14201423
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
@@ -1430,7 +1433,7 @@ if test "$Py_LTO" = 'true' ; then
14301433
LTOFLAGS="$LTOFLAGS -g"
14311434
fi
14321435

1433-
CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
1436+
CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
14341437
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
14351438
fi
14361439

0 commit comments

Comments
 (0)