Skip to content

Commit 25a9cf1

Browse files
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. (cherry picked from commit 59acfd4a09df1c141dac7845eed008af8970fce7) Co-authored-by: Ned Deily <[email protected]>
1 parent 8677987 commit 25a9cf1

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed
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

+6-3
Original file line numberDiff line numberDiff line change
@@ -7322,10 +7322,11 @@ fi
73227322
fi
73237323
if test "$ac_sys_system" = "Darwin" -a "${LLVM_AR_FOUND}" = "not-found"
73247324
then
7325-
found_llvm_ar=`/usr/bin/xcrun -find llvm-ar 2>/dev/null`
7325+
# The Apple-supplied ar in Xcode or the Command Line Tools is apparently sufficient
7326+
found_llvm_ar=`/usr/bin/xcrun -find ar 2>/dev/null`
73267327
if test -n "${found_llvm_ar}"
73277328
then
7328-
LLVM_AR='/usr/bin/xcrun llvm-ar'
7329+
LLVM_AR='/usr/bin/xcrun ar'
73297330
LLVM_AR_FOUND=found
73307331
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: llvm-ar found via xcrun: ${LLVM_AR}" >&5
73317332
printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
@@ -7343,6 +7344,7 @@ printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
73437344
Darwin*)
73447345
# Any changes made here should be reflected in the GCC+Darwin case below
73457346
LTOFLAGS="-flto -Wl,-export_dynamic"
7347+
LTOCFLAGS="-flto"
73467348
;;
73477349
*)
73487350
LTOFLAGS="-flto"
@@ -7353,6 +7355,7 @@ printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
73537355
case $ac_sys_system in
73547356
Darwin*)
73557357
LTOFLAGS="-flto -Wl,-export_dynamic"
7358+
LTOCFLAGS="-flto"
73567359
;;
73577360
*)
73587361
LTOFLAGS="-flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none"
@@ -7368,7 +7371,7 @@ printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
73687371
LTOFLAGS="$LTOFLAGS -g"
73697372
fi
73707373

7371-
CFLAGS_NODIST="$CFLAGS_NODIST $LTOFLAGS"
7374+
CFLAGS_NODIST="$CFLAGS_NODIST ${LTOCFLAGS-$LTOFLAGS}"
73727375
LDFLAGS_NODIST="$LDFLAGS_NODIST $LTOFLAGS"
73737376
fi
73747377

configure.ac

+6-3
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)