[Python-checkins] cpython: Issue #24421: Compile _math.c separately to avoid race condition
martin.panter
python-checkins at python.org
Tue Feb 2 00:59:14 EST 2016
https://hg.python.org/cpython/rev/76624d47ee99
changeset: 100143:76624d47ee99
user: Martin Panter <vadmium+py at gmail.com>
date: Wed Feb 03 05:19:44 2016 +0000
summary:
Issue #24421: Compile _math.c separately to avoid race condition
files:
Makefile.pre.in | 6 +++++-
Misc/NEWS | 4 ++++
setup.py | 12 ++++++++----
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -586,11 +586,15 @@
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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -671,6 +671,10 @@
- Issue #24986: It is now possible to build Python on Windows without errors
when external libraries are not available.
+- 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 #25798: Update OS X 10.5 installer to use OpenSSL 1.0.2e.
Windows
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -582,13 +582,17 @@
# 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()
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list