[pypy-svn] r71945 - in pypy/release/1.2.x/pypy: rlib rpython/lltypesystem translator/platform translator/tool
arigo at codespeak.net
arigo at codespeak.net
Tue Mar 9 13:43:37 CET 2010
Author: arigo
Date: Tue Mar 9 13:43:36 2010
New Revision: 71945
Modified:
pypy/release/1.2.x/pypy/rlib/libffi.py
pypy/release/1.2.x/pypy/rpython/lltypesystem/ll2ctypes.py
pypy/release/1.2.x/pypy/translator/platform/linux.py
pypy/release/1.2.x/pypy/translator/tool/cbuild.py
Log:
svn merge svn+ssh://codespeak.net/svn/pypy/trunk -r71943:71944
Modified: pypy/release/1.2.x/pypy/rlib/libffi.py
==============================================================================
--- pypy/release/1.2.x/pypy/rlib/libffi.py (original)
+++ pypy/release/1.2.x/pypy/rlib/libffi.py Tue Mar 9 13:43:36 2010
@@ -53,11 +53,13 @@
separate_module_sources = []
if not _MSVC:
+ # On some platforms, we try to link statically libffi, which is small
+ # anyway and avoids endless troubles for installing. On other platforms
+ # libffi.a is typically not there, so we link dynamically.
if _MINGW:
includes = ['windows.h', 'ffi.h']
else:
includes = ['dlfcn.h', 'ffi.h']
- include_dirs = platform.include_dirs_for_libffi()
if _MAC_OS:
pre_include_bits = ['#define MACOSX']
@@ -65,9 +67,25 @@
pre_include_bits = []
if _FREEBSD_7 or _MINGW:
- libraries = ['ffi']
+ libraries = []
else:
- libraries = ['ffi', 'dl']
+ libraries = ['dl']
+
+ def find_libffi_a():
+ dirlist = platform.library_dirs_for_libffi_a()
+ for dir in dirlist:
+ result = os.path.join(dir, 'libffi.a')
+ if os.path.exists(result):
+ return result
+ raise ImportError("'libffi.a' not found in %s" % (dirlist,))
+
+ if hasattr(platform, 'library_dirs_for_libffi_a'):
+ # platforms on which we want static linking
+ link_files = [find_libffi_a()]
+ else:
+ # platforms on which we want dynamic linking
+ libraries = ['ffi'] + libraries
+ link_files = []
eci = ExternalCompilationInfo(
pre_include_bits = pre_include_bits,
@@ -76,6 +94,8 @@
separate_module_sources = separate_module_sources,
include_dirs = platform.include_dirs_for_libffi(),
library_dirs = platform.library_dirs_for_libffi(),
+ link_files = link_files,
+ testonly_libraries = ['ffi'],
)
else:
libffidir = py.path.local(pypydir).join('translator', 'c', 'src', 'libffi_msvc')
Modified: pypy/release/1.2.x/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/release/1.2.x/pypy/rpython/lltypesystem/ll2ctypes.py (original)
+++ pypy/release/1.2.x/pypy/rpython/lltypesystem/ll2ctypes.py Tue Mar 9 13:43:36 2010
@@ -853,7 +853,7 @@
eci = old_eci.compile_shared_lib()
_eci_cache[old_eci] = eci
- libraries = list(eci.libraries + eci.frameworks)
+ libraries = eci.testonly_libraries + eci.libraries + eci.frameworks
FUNCTYPE = lltype.typeOf(funcptr).TO
if not libraries:
Modified: pypy/release/1.2.x/pypy/translator/platform/linux.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/platform/linux.py (original)
+++ pypy/release/1.2.x/pypy/translator/platform/linux.py Tue Mar 9 13:43:36 2010
@@ -24,6 +24,10 @@
def library_dirs_for_libffi(self):
return ['/usr/lib/libffi']
+ def library_dirs_for_libffi_a(self):
+ # places where we need to look for libffi.a
+ return self.library_dirs_for_libffi() + ['/usr/lib']
+
class Linux64(Linux):
shared_only = ['-fPIC']
Modified: pypy/release/1.2.x/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/tool/cbuild.py (original)
+++ pypy/release/1.2.x/pypy/translator/tool/cbuild.py Tue Mar 9 13:43:36 2010
@@ -18,7 +18,7 @@
'post_include_bits', 'libraries', 'library_dirs',
'separate_module_sources', 'separate_module_files',
'export_symbols', 'compile_extra', 'link_extra',
- 'frameworks', 'link_files']
+ 'frameworks', 'link_files', 'testonly_libraries']
_DUPLICATES_OK = ['compile_extra', 'link_extra']
_EXTRA_ATTRIBUTES = ['use_cpp_linker', 'platform']
@@ -36,6 +36,7 @@
link_extra = [],
frameworks = [],
link_files = [],
+ testonly_libraries = [],
use_cpp_linker = False,
platform = None):
"""
@@ -82,6 +83,10 @@
link_files: list of file names which will be directly passed to the
linker
+ testonly_libraries: list of libraries that are searched for during
+ testing only, by ll2ctypes. Useful to search for a name in a dynamic
+ library during testing but use the static library for compilation.
+
use_cpp_linker: a flag to tell if g++ should be used instead of gcc
when linking (a bit custom so far)
More information about the Pypy-commit
mailing list