Skip to content

Commit 35f3d24

Browse files
authored
bpo-30104: configure now detects when cc is clang (#1233)
Detect when the "cc" compiler (and the $CC variable) is the Clang compiler. The test is needed to add the -fno-strict-aliasing option on FreeBSD where cc is clang.
1 parent 28205b2 commit 35f3d24

2 files changed

Lines changed: 42 additions & 16 deletions

File tree

configure

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6812,19 +6812,32 @@ then
68126812
WRAP="-fwrapv"
68136813
fi
68146814

6815-
# Clang also needs -fwrapv
68166815
case $CC in
68176816
*clang*)
6818-
WRAP="-fwrapv"
6819-
# bpo-30104: Python/dtoa.c requires to be build with
6820-
# -fno-strict-aliasing to fix compiler issue on the
6821-
# double/ULong[2] union using clang 4.0 and optimization level
6822-
# -O2 or higher
6823-
# https://bugs.llvm.org//show_bug.cgi?id=31928
6824-
ALIASING="-fno-strict-aliasing"
6817+
cc_is_clang=1
68256818
;;
6819+
*)
6820+
if $CC --version 2>&1 | grep -q clang
6821+
then
6822+
cc_is_clang=1
6823+
else
6824+
cc_is_clang=
6825+
fi
68266826
esac
68276827

6828+
if test -n "${cc_is_clang}"
6829+
then
6830+
# Clang also needs -fwrapv
6831+
WRAP="-fwrapv"
6832+
6833+
# bpo-30104: Python/dtoa.c requires to be build with
6834+
# -fno-strict-aliasing to fix compiler issue on the
6835+
# double/ULong[2] union using clang 4.0 and optimization level
6836+
# -O2 or higher
6837+
# https://bugs.llvm.org//show_bug.cgi?id=31928
6838+
ALIASING="-fno-strict-aliasing"
6839+
fi
6840+
68286841
case $ac_cv_prog_cc_g in
68296842
yes)
68306843
if test "$Py_DEBUG" = 'true' ; then

configure.ac

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,19 +1452,32 @@ then
14521452
WRAP="-fwrapv"
14531453
fi
14541454

1455-
# Clang also needs -fwrapv
14561455
case $CC in
14571456
*clang*)
1458-
WRAP="-fwrapv"
1459-
# bpo-30104: Python/dtoa.c requires to be build with
1460-
# -fno-strict-aliasing to fix compiler issue on the
1461-
# double/ULong[2] union using clang 4.0 and optimization level
1462-
# -O2 or higher
1463-
# https://bugs.llvm.org//show_bug.cgi?id=31928
1464-
ALIASING="-fno-strict-aliasing"
1457+
cc_is_clang=1
14651458
;;
1459+
*)
1460+
if $CC --version 2>&1 | grep -q clang
1461+
then
1462+
cc_is_clang=1
1463+
else
1464+
cc_is_clang=
1465+
fi
14661466
esac
14671467

1468+
if test -n "${cc_is_clang}"
1469+
then
1470+
# Clang also needs -fwrapv
1471+
WRAP="-fwrapv"
1472+
1473+
# bpo-30104: Python/dtoa.c requires to be build with
1474+
# -fno-strict-aliasing to fix compiler issue on the
1475+
# double/ULong[2] union using clang 4.0 and optimization level
1476+
# -O2 or higher
1477+
# https://bugs.llvm.org//show_bug.cgi?id=31928
1478+
ALIASING="-fno-strict-aliasing"
1479+
fi
1480+
14681481
case $ac_cv_prog_cc_g in
14691482
yes)
14701483
if test "$Py_DEBUG" = 'true' ; then

0 commit comments

Comments
 (0)