Skip to content

Commit

Permalink
windows: upgrade libffi to 3.4.2
Browse files Browse the repository at this point in the history
Impetus for this is it unblocks Windows ARM distributions.

Unlike CPython, we ship libffi 3.4.2 on Python <3.11.
  • Loading branch information
indygreg committed Oct 19, 2021
1 parent 98d2390 commit 3307e39
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"_bz2": {},
"_ctypes": {
"shared_depends": ["libffi-7"],
"shared_depends": ["libffi-8"],
"static_depends_no_project": ["libffi"],
},
"_decimal": {},
Expand Down Expand Up @@ -812,13 +812,28 @@ def hack_props(

libffi_props = pcbuild_path / "libffi.props"

# Always use libffi-8 / 3.4.2. (Python <= 3.11 use libffi-7 by default.)
try:
static_replace_in_file(
libffi_props,
br"""<_LIBFFIDLL Include="$(libffiOutDir)\libffi-7.dll" />""",
br"""<_LIBFFIDLL Include="$(libffiOutDir)\libffi-8.dll" />""",
)
static_replace_in_file(
libffi_props,
br"<AdditionalDependencies>libffi-7.lib;%(AdditionalDependencies)</AdditionalDependencies>",
br"<AdditionalDependencies>libffi-8.lib;%(AdditionalDependencies)</AdditionalDependencies>",
)
except NoSearchStringError:
pass

if static:
# For some reason the built .lib doesn't have the -7 suffix in
# For some reason the built .lib doesn't have the -8 suffix in
# static build mode. This is possibly a side-effect of CPython's
# libffi build script not officially supporting static-only builds.
static_replace_in_file(
libffi_props,
b"<AdditionalDependencies>libffi-7.lib;%(AdditionalDependencies)</AdditionalDependencies>",
b"<AdditionalDependencies>libffi-8.lib;%(AdditionalDependencies)</AdditionalDependencies>",
b"<AdditionalDependencies>libffi.lib;%(AdditionalDependencies)</AdditionalDependencies>",
)

Expand Down Expand Up @@ -1593,7 +1608,7 @@ def build_libffi(
"-c",
"core.autocrlf=input",
"checkout",
"ed22026f39b37f892ded95d7b30e77dfb5126334",
"16fad4855b3d8c03b5910e405ff3a04395b39a98",
],
cwd=ffi_source_path,
check=True,
Expand Down
2 changes: 1 addition & 1 deletion src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const PE_ALLOWED_LIBRARIES: &[&str] = &[
// Our libraries.
"libcrypto-1_1.dll",
"libcrypto-1_1-x64.dll",
"libffi-7.dll",
"libffi-8.dll",
"libssl-1_1.dll",
"libssl-1_1-x64.dll",
"python3.dll",
Expand Down

0 comments on commit 3307e39

Please sign in to comment.