summaryrefslogtreecommitdiffstats
path: root/Makefile.pre.in
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-05-02 08:47:37 (GMT)
committerGitHub <noreply@github.com>2017-05-02 08:47:37 (GMT)
commit809101f14f27ddb394cd77c477470761ecf99f41 (patch)
treec72865d73dfa042b3aa4826ed4c33ace4dd5295e /Makefile.pre.in
parent78b23ab6827410960577c01a33df8afc8fd4496e (diff)
downloadcpython-809101f14f27ddb394cd77c477470761ecf99f41.zip
cpython-809101f14f27ddb394cd77c477470761ecf99f41.tar.gz
cpython-809101f14f27ddb394cd77c477470761ecf99f41.tar.bz2
bpo-30104: Use -fno-strict-aliasing on clang (#1376)
Python/dtoa.c is not compiled correctly with clang 4.0 and optimization level -O2 or higher, because of an aliasing issue on the double/ULong[2] union. Only compile dtoa.c with -fno-strict-aliasing. LLVM bug report: https://bugs.llvm.org//show_bug.cgi?id=31928
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 8f27d73..3eef424 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
@@ -1535,6 +1537,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