Skip to content

Commit

Permalink
use libffi instead of older vendored version
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Jul 11, 2021
1 parent efda60d commit 7f38ef7
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 1 deletion.
3 changes: 2 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ source:
- patches/pre-7.3.6-0005.patch
- patches/pre-7.3.6-0006.patch
- patches/pre-7.3.6-0007.patch
- patches/pre-7.3.6-0008.patch

- url: https://downloads.python.org/pypy/pypy2.7-v7.3.5-win64.zip # [win]
sha256: 0b90eded11ba89a526c4288f17fff7e75000914ac071bd6d67912748ae89d761 # [win]
folder: pypy2-binary # [win]

build:
number: 3
number: 4
skip: True # [name_suffix=="3.6"]
skip_compile_pyc:
- lib*
Expand Down
113 changes: 113 additions & 0 deletions recipe/patches/pre-7.3.6-0008.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Branch py3.7
# Node ID 914662db611500eb62661bf6d1dcb38e327f25c2
# Parent d23b62357222d2768c072fbceb0650a174acd7e5

diff -r d23b62357222 -r 914662db6115 lib-python/3/venv/__init__.py
--- a/lib-python/3/venv/__init__.py Fri Jul 09 19:45:42 2021 +0100
+++ b/lib-python/3/venv/__init__.py Sun Jul 11 12:46:37 2021 +0300
@@ -259,9 +259,9 @@
if not os.path.islink(path):
os.chmod(path, 0o755)
#
- # PyPy extension: also copy the main library, not just the
+ # PyPy extension: also copy needed dlls, not just the
# small executable
- for libname in ['libpypy3-c.so', 'libpypy3-c.dylib']:
+ for libname in ['libpypy3-c.so', 'libpypy3-c.dylib', 'libffi-7.dll']:
dest_library = os.path.join(binpath, libname)
src_library = os.path.join(os.path.dirname(context.executable),
libname)
diff -r d23b62357222 -r 914662db6115 pypy/tool/release/package.py
--- a/pypy/tool/release/package.py Fri Jul 09 19:45:42 2021 +0100
+++ b/pypy/tool/release/package.py Sun Jul 11 12:46:37 2021 +0300
@@ -185,7 +185,9 @@
print('Picking {} as pypy.exe'.format(src))
# Can't rename a DLL
win_extras = [('lib' + POSIX_EXE + '-c.dll', None),
- ('sqlite3.dll', lib_pypy)]
+ ('sqlite3.dll', lib_pypy),
+ ('libffi-7.dll', None),
+ ]
if not options.no__tkinter:
tkinter_dir = lib_pypy.join('_tkinter')
win_extras += [('tcl86t.dll', tkinter_dir), ('tk86t.dll', tkinter_dir)]
diff -r d23b62357222 -r 914662db6115 rpython/rlib/clibffi.py
--- a/rpython/rlib/clibffi.py Fri Jul 09 19:45:42 2021 +0100
+++ b/rpython/rlib/clibffi.py Sun Jul 11 12:46:37 2021 +0300
@@ -38,10 +38,7 @@

if _WIN32:
from rpython.rlib import rwin32
-
-if _WIN32:
separate_module_sources = ['''
- #include "src/precommondefs.h"
#include <stdio.h>
#include <windows.h>

@@ -107,22 +104,22 @@
])
else:
USE_C_LIBFFI_MSVC = True
- libffidir = py.path.local(cdir).join('src', 'libffi_msvc')
+ # libffidir = py.path.local(cdir).join('src', 'libffi_msvc')
if not _WIN64:
asm_ifc = 'win32.c'
else:
asm_ifc = 'win64.asm'
eci = ExternalCompilationInfo(
includes = ['ffi.h', 'windows.h'],
- libraries = ['kernel32'],
- include_dirs = [libffidir, cdir],
+ libraries = ['kernel32', 'libffi-7'],
+ # include_dirs = [libffidir, cdir],
separate_module_sources = separate_module_sources,
post_include_bits = post_include_bits,
- separate_module_files = [libffidir.join('ffi.c'),
- libffidir.join('prep_cif.c'),
- libffidir.join(asm_ifc),
- libffidir.join('pypy_ffi.c'),
- ],
+ # separate_module_files = [libffidir.join('ffi.c'),
+ # libffidir.join('prep_cif.c'),
+ # libffidir.join(asm_ifc),
+ # libffidir.join('pypy_ffi.c'),
+ # ],
)

FFI_TYPE_P = lltype.Ptr(lltype.ForwardReference())
@@ -265,7 +262,7 @@
return rffi.llexternal(name, args, result, compilation_info=eci, calling_conv='win')


-if not _MSVC:
+if 1 or not _MSVC:
def check_fficall_result(result, flags):
pass # No check
else:
@@ -329,7 +326,7 @@

c_ffi_prep_cif = external('ffi_prep_cif', [FFI_CIFP, FFI_ABI, rffi.UINT,
FFI_TYPE_P, FFI_TYPE_PP], rffi.INT)
-if _MSVC:
+if 0 and _MSVC:
c_ffi_call_return_type = rffi.INT
else:
c_ffi_call_return_type = lltype.Void

diff -r d23b62357222 -r 914662db6115 rpython/translator/driver.py
--- a/rpython/translator/driver.py Fri Jul 09 19:45:42 2021 +0100
+++ b/rpython/translator/driver.py Sun Jul 11 12:46:37 2021 +0300
@@ -507,6 +507,11 @@
newname = newexename.new(basename=soname.basename)
shutil.copyfile(str(name), str(newname.new(ext=ext)))
self.log.info("copied: %s" % (newname,))
+ # HACK: copy libcffi-7.dll which is required for venvs
+ # At some point, we should stop doing this, and instead
+ # use the artifact from packaging the build instead
+ libffi = py.path.local.sysfind('libffi-7.dll')
+ shutil.copyfile(str(libffi), os.getcwd() + r'\libffi-7.dll')
self.c_entryp = newexename
self.log.info("created: %s" % (self.c_entryp,))


0 comments on commit 7f38ef7

Please sign in to comment.