remove detect_math_libs (#4383)

Darwin may not require libm, but it doesn't hurt to link it and simplifies configuration logic.
This commit is contained in:
Benjamin Peterson 2017-11-12 20:53:39 -08:00 committed by GitHub
parent d7d4fea4a3
commit 8acaa31eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 21 deletions

View File

@ -501,13 +501,6 @@ class PyBuildExt(build_ext):
finally:
os.unlink(tmpfile)
def detect_math_libs(self):
# Check for MacOS X, which doesn't need libm.a at all
if host_platform == 'darwin':
return []
else:
return ['m']
def detect_modules(self):
# Ensure that /usr/local is always used, but the local build
# directories (i.e. '.' and 'Include') must be first. See issue
@ -613,8 +606,6 @@ class PyBuildExt(build_ext):
if item.startswith('-L'):
lib_dirs.append(item[2:])
math_libs = self.detect_math_libs()
#
# The following modules are all pretty straightforward, and compile
# on pretty much any POSIXish platform.
@ -628,12 +619,12 @@ class PyBuildExt(build_ext):
exts.append( Extension('cmath', ['cmathmodule.c'],
extra_objects=[shared_math],
depends=['_math.h', shared_math],
libraries=math_libs) )
libraries=['m']) )
# math library functions, e.g. sin()
exts.append( Extension('math', ['mathmodule.c'],
extra_objects=[shared_math],
depends=['_math.h', shared_math],
libraries=math_libs) )
libraries=['m']) )
# time libraries: librt may be needed for clock_gettime()
time_libs = []
@ -644,10 +635,10 @@ class PyBuildExt(build_ext):
# time operations and variables
exts.append( Extension('time', ['timemodule.c'],
libraries=time_libs) )
# math_libs is needed by delta_new() that uses round() and by accum()
# that uses modf().
# libm is needed by delta_new() that uses round() and by accum() that
# uses modf().
exts.append( Extension('_datetime', ['_datetimemodule.c'],
libraries=math_libs) )
libraries=['m']) )
# random number generator implemented in C
exts.append( Extension("_random", ["_randommodule.c"]) )
# bisect
@ -732,9 +723,9 @@ class PyBuildExt(build_ext):
# According to #993173, this one should actually work fine on
# 64-bit platforms.
#
# audioop needs math_libs for floor() in multiple functions.
# audioop needs libm for floor() in multiple functions.
exts.append( Extension('audioop', ['audioop.c'],
libraries=math_libs) )
libraries=['m']) )
# readline
do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
@ -1972,7 +1963,6 @@ class PyBuildExt(build_ext):
'_ctypes/stgdict.c',
'_ctypes/cfield.c']
depends = ['_ctypes/ctypes.h']
math_libs = self.detect_math_libs()
if host_platform == 'darwin':
sources.append('_ctypes/malloc_closure.c')
@ -2003,10 +1993,10 @@ class PyBuildExt(build_ext):
libraries=[],
sources=sources,
depends=depends)
# function my_sqrt() needs math library for sqrt()
# function my_sqrt() needs libm for sqrt()
ext_test = Extension('_ctypes_test',
sources=['_ctypes/_ctypes_test.c'],
libraries=math_libs)
libraries=['m'])
self.extensions.extend([ext, ext_test])
if host_platform == 'darwin':
@ -2050,7 +2040,6 @@ class PyBuildExt(build_ext):
'Modules',
'_decimal',
'libmpdec'))]
libraries = self.detect_math_libs()
sources = [
'_decimal/_decimal.c',
'_decimal/libmpdec/basearith.c',
@ -2146,7 +2135,7 @@ class PyBuildExt(build_ext):
ext = Extension (
'_decimal',
include_dirs=include_dirs,
libraries=libraries,
libraries=['m'],
define_macros=define_macros,
undef_macros=undef_macros,
extra_compile_args=extra_compile_args,