提交 3b6922d3 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Always add '-m32' or '-m64' to module cache key

This is to avoid loading modules compiled with one architecture from a Python with a different one.
上级 69e02775
...@@ -1619,6 +1619,39 @@ class GCC_compiler(object): ...@@ -1619,6 +1619,39 @@ class GCC_compiler(object):
cxxflags.append("-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL") cxxflags.append("-D NPY_ARRAY_UPDATE_ALL=NPY_UPDATE_ALL")
cxxflags.append("-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS") cxxflags.append("-D NPY_ARRAY_C_CONTIGUOUS=NPY_C_CONTIGUOUS")
cxxflags.append("-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS") cxxflags.append("-D NPY_ARRAY_F_CONTIGUOUS=NPY_F_CONTIGUOUS")
# Platform-specific flags.
# We put them here, rather than in compile_str(), so they en up
# in the key of the compiled module, avoiding potential conflicts.
# Figure out whether the current Python executable is 32
# or 64 bit and compile accordingly.
n_bits = local_bitwidth()
cxxflags.append('-m%d' % n_bits)
_logger.debug("Compiling for %s bit architecture", n_bits)
if sys.platform != 'win32':
# Under Windows it looks like fPIC is useless. Compiler warning:
# '-fPIC ignored for target (all code is position independent)'
cxxflags.append('-fPIC')
if sys.platform == 'win32' and local_bitwidth() == 64:
# Under 64-bit Windows installation, sys.platform is 'win32'.
# We need to define MS_WIN64 for the preprocessor to be able to
# link with libpython.
cxxflags.append('-DMS_WIN64')
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
if sys.platform == 'darwin':
cxxflags.extend(['-undefined', 'dynamic_lookup'])
python_inc = distutils.sysconfig.get_python_inc()
# link with the framework library *if specifically requested*
# config.mac_framework_link is by default False, since on some mac
# installs linking with -framework causes a Bus Error
if (python_inc.count('Python.framework') > 0 and
config.cmodule.mac_framework_link):
cxxflags.extend(['-framework', 'Python'])
return cxxflags return cxxflags
@staticmethod @staticmethod
...@@ -1744,40 +1777,10 @@ class GCC_compiler(object): ...@@ -1744,40 +1777,10 @@ class GCC_compiler(object):
else: else:
preargs = list(preargs) preargs = list(preargs)
if sys.platform != 'win32':
# Under Windows it looks like fPIC is useless. Compiler warning:
# '-fPIC ignored for target (all code is position independent)'
preargs.append('-fPIC')
if sys.platform == 'win32' and local_bitwidth() == 64:
# Under 64-bit Windows installation, sys.platform is 'win32'.
# We need to define MS_WIN64 for the preprocessor to be able to
# link with libpython.
preargs.append('-DMS_WIN64')
# We also add "-m64", in case the installed gcc is 32-bit
preargs.append('-m64')
include_dirs = include_dirs + std_include_dirs() include_dirs = include_dirs + std_include_dirs()
libs = std_libs() + libs libs = std_libs() + libs
lib_dirs = std_lib_dirs() + lib_dirs lib_dirs = std_lib_dirs() + lib_dirs
#DSE Patch 1 for supporting OSX frameworks; add -framework Python
if sys.platform == 'darwin':
preargs.extend(['-undefined', 'dynamic_lookup'])
python_inc = distutils.sysconfig.get_python_inc()
# link with the framework library *if specifically requested*
# config.mac_framework_link is by default False, since on some mac
# installs linking with -framework causes a Bus Error
if (python_inc.count('Python.framework') > 0 and
config.cmodule.mac_framework_link):
preargs.extend(['-framework', 'Python'])
# Figure out whether the current Python executable is 32
# or 64 bit and compile accordingly.
n_bits = local_bitwidth()
preargs.extend(['-m%s' % n_bits])
_logger.debug("OS X: compiling for %s bit architecture", n_bits)
# sometimes, the linker cannot find -lpython so we need to tell it # sometimes, the linker cannot find -lpython so we need to tell it
# explicitly where it is located # explicitly where it is located
# this returns somepath/lib/python2.x # this returns somepath/lib/python2.x
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论