summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-03 05:19:44 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-02-03 05:19:44 (GMT)
commit63d096ddabc430ede485bc5fb8ce11bb78cb8afa (patch)
tree0dc97e87fa4a31a976ab7c43f414fafe9ec3d14c
parentbc85e35fe66edf18c7998d98bfa5682a9cbb0269 (diff)
downloadcpython-63d096ddabc430ede485bc5fb8ce11bb78cb8afa.zip
cpython-63d096ddabc430ede485bc5fb8ce11bb78cb8afa.tar.gz
cpython-63d096ddabc430ede485bc5fb8ce11bb78cb8afa.tar.bz2
Issue #24421: Compile _math.c separately to avoid race condition
-rw-r--r--Makefile.pre.in6
-rw-r--r--Misc/NEWS4
-rw-r--r--setup.py12
3 files changed, 17 insertions, 5 deletions
diff --git a/Makefile.pre.in b/Makefile.pre.in
index 91fa06e..9b4ab8d 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -586,11 +586,15 @@ pybuilddir.txt: $(BUILDPYTHON)
exit 1 ; \
fi
+# This is shared by the math and cmath modules
+Modules/_math.o: Modules/_math.c Modules/_math.h
+ $(CC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $<
+
# Build the shared modules
# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
# -s, --silent or --quiet is always the first char.
# Under BSD make, MAKEFLAGS might be " -s -v x=y".
-sharedmods: $(BUILDPYTHON) pybuilddir.txt
+sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
@case "$$MAKEFLAGS" in \
*\ -s*|s*) quiet="-q";; \
*) quiet="";; \
diff --git a/Misc/NEWS b/Misc/NEWS
index 029b334..18d3efe 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -261,6 +261,10 @@ Tests
Build
-----
+- Issue #24421: Compile Modules/_math.c once, before building extensions.
+ Previously it could fail to compile properly if the math and cmath builds
+ were concurrent.
+
- Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
``PCbuild\build.bat`` for building with Profile-Guided Optimization. The
old ``PCbuild\build_pgo.bat`` script is now deprecated, and simply calls
diff --git a/setup.py b/setup.py
index 3ebc3de..de6e5ad 100644
--- a/setup.py
+++ b/setup.py
@@ -598,13 +598,17 @@ class PyBuildExt(build_ext):
# array objects
exts.append( Extension('array', ['arraymodule.c']) )
+
+ shared_math = 'Modules/_math.o'
# complex math library functions
- exts.append( Extension('cmath', ['cmathmodule.c', '_math.c'],
- depends=['_math.h'],
+ exts.append( Extension('cmath', ['cmathmodule.c'],
+ extra_objects=[shared_math],
+ depends=['_math.h', shared_math],
libraries=math_libs) )
# math library functions, e.g. sin()
- exts.append( Extension('math', ['mathmodule.c', '_math.c'],
- depends=['_math.h'],
+ exts.append( Extension('math', ['mathmodule.c'],
+ extra_objects=[shared_math],
+ depends=['_math.h', shared_math],
libraries=math_libs) )
# time libraries: librt may be needed for clock_gettime()