summaryrefslogtreecommitdiff
path: root/Makefile.pre.in
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-04-28 15:07:10 +0200
committerGitHub <noreply@github.com>2017-04-28 15:07:10 +0200
commit826f83f1d562a7b878499bc3af2267cfdfe5f2f9 (patch)
treed35096a04bd036d1e807309764002f40d4274f9e /Makefile.pre.in
parent5a4e3d8f9c37e700402b23fafbfc413e5ca3113d (diff)
downloadcpython-git-826f83f1d562a7b878499bc3af2267cfdfe5f2f9.tar.gz
bpo-30104: Only use -fno-strict-aliasing on dtoa.c (#1340)
On clang, only compile dtoa.c with -fno-strict-aliasing, use strict aliasing to compile all other C files.
Diffstat (limited to 'Makefile.pre.in')
-rw-r--r--Makefile.pre.in9
1 files changed, 9 insertions, 0 deletions
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 4145634c03..e5141f11da 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -107,6 +107,8 @@ ARFLAGS= @ARFLAGS@
CFLAGSFORSHARED=@CFLAGSFORSHARED@
# C flags used for building the interpreter object files
PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
+# Strict or non-strict aliasing flags used to compile dtoa.c, see above
+CFLAGS_ALIASING=@CFLAGS_ALIASING@
# Machine-dependent subdirectories
@@ -1536,6 +1538,13 @@ config.status: $(srcdir)/configure
.c.o:
$(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
+# bpo-30104: dtoa.c uses union to cast double to unsigned long[2]. clang 4.0
+# with -O2 or higher and strict aliasing miscompiles the ratio() function
+# causing rounding issues. Compile dtoa.c using -fno-strict-aliasing on clang.
+# https://bugs.llvm.org//show_bug.cgi?id=31928
+Python/dtoa.o: Python/dtoa.c
+ $(CC) -c $(PY_CORE_CFLAGS) $(CFLAGS_ALIASING) -o $@ $<
+
# Run reindent on the library
reindent:
./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib