summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2013-09-25 10:47:22 +0200
committerArmin Rigo <arigo@tunes.org>2013-09-25 10:47:22 +0200
commit892bfe552fb0f0c22faa716091c938eb10789a62 (patch)
tree4252cbad126e66ed2d1c89eb50717f1fbdbe882e /setup.py
parent7850c4ce5f73ec6284e4652b6746c2763ff0f2c6 (diff)
downloadcffi-892bfe552fb0f0c22faa716091c938eb10789a62.tar.gz
A redo of pull request 19: dynamically determine if the C compiler
supports "__thread" or not on this platform. Done slightly more simply in setup.py.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 9b52876..bf528eb 100644
--- a/setup.py
+++ b/setup.py
@@ -41,6 +41,17 @@ def _ask_pkg_config(resultlist, option, result_prefix='', sysroot=False):
#
resultlist[:] = res
+def ask_supports_thread():
+ import distutils.errors
+ from distutils.ccompiler import new_compiler
+ compiler = new_compiler(force=1)
+ try:
+ compiler.compile(['c/check__thread.c'])
+ except distutils.errors.CompileError:
+ print >> sys.stderr, "will not use '__thread' in the C code"
+ else:
+ define_macros.append(('USE__THREAD', None))
+
def use_pkg_config():
_ask_pkg_config(include_dirs, '--cflags-only-I', '-I', sysroot=True)
_ask_pkg_config(extra_compile_args, '--cflags-only-other')
@@ -71,6 +82,7 @@ if COMPILE_LIBFFI:
for filename in _filenames)
else:
use_pkg_config()
+ ask_supports_thread()
if __name__ == '__main__':