]> granicus.if.org Git - python/commitdiff
Issue #24421: Compile _math.c separately to avoid race condition
authorMartin Panter <vadmium+py@gmail.com>
Wed, 3 Feb 2016 05:19:44 +0000 (05:19 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Wed, 3 Feb 2016 05:19:44 +0000 (05:19 +0000)
Makefile.pre.in
Misc/NEWS
setup.py

index 3b43f1be8e7430b33792e7a5a798cadfa8c23bb8..cf9bec3afcfbf1537726e653a3e2eb2226475982 100644 (file)
@@ -528,11 +528,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_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="";; \
index 10eee93ea2870ec2cb1a4fc8cbf030eeafa7c947..49d3fd1059075ecf571c0ce8bd2bb2e135dc0d65 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -143,6 +143,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 #25824: Fixes sys.winver to not include any architecture suffix.
 
 - Issue #25348: Added ``--pgo`` and ``--pgo-job`` arguments to
index 094318849a7977e2760881702bc172302402a096..780889fb8e647904752966c14e55f08a890be484 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -584,13 +584,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) )
         # fast string operations implemented in C
         exts.append( Extension('strop', ['stropmodule.c']) )