bpo-35903: Use autoconfig to probe for shm_open() and shm_unlink(). (#11765)

Use autoconfig to probe for shm_open() and shm_unlink().  Set SHM_NEEDS_LIBRT if we must
link with librt to get the shm_* functions.  Change setup.py to use the autoconfig defines.  These
changes should make it more likely that _multiprocessing/posixshmem.c gets built correctly on
different platforms.
This commit is contained in:
Neil Schemenauer 2019-02-08 10:48:46 -08:00 committed by GitHub
parent 64360ada0f
commit 5741c45acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 142 additions and 3 deletions

View file

@ -1592,12 +1592,13 @@ class PyBuildExt(build_ext):
if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not
sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
multiprocessing_srcs.append('_multiprocessing/semaphore.c')
if (self.compiler.find_library_file(lib_dirs, 'rt') or
host_platform != 'cygwin'):
if (sysconfig.get_config_var('HAVE_SHM_OPEN') and
sysconfig.get_config_var('HAVE_SHM_UNLINK')):
posixshmem_srcs = [ '_multiprocessing/posixshmem.c',
]
libs = []
if self.compiler.find_library_file(lib_dirs, 'rt'):
if sysconfig.get_config_var('SHM_NEEDS_LIBRT'):
# need to link with librt to get shm_open()
libs.append('rt')
exts.append( Extension('_posixshmem', posixshmem_srcs,
define_macros={},