Skip to content

Commit

Permalink
(#23362) libffi: Add 3.4.6, remove 3.4.2 and 3.4.3
Browse files Browse the repository at this point in the history
* Add libffi 3.4.6

* Fix MSVC build

* Don't define FFI_BUILDING if not necessary

* ffi static defines only necessary for MSVC

* Keep static defines for now

* Disable Mac ARM build on 3.3

* Fix patch name

* Remove some dead code

* Remove unused import

* Remove libffi 3.4.2 and 3.4.3

* remove unused versions from conandata.yml

Signed-off-by: Uilian Ries <[email protected]>

---------

Signed-off-by: Uilian Ries <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
Ahajha and uilianries authored May 28, 2024
1 parent 454cc39 commit 3286aeb
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 81 deletions.
28 changes: 8 additions & 20 deletions recipes/libffi/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
sources:
"3.4.6":
url: "https://github.com/libffi/libffi/releases/download/v3.4.6/libffi-3.4.6.tar.gz"
sha256: "b0dea9df23c863a7a50e825440f3ebffabd65df1497108e5d437747843895a4e"
"3.4.4":
url: "https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz"
sha256: "d66c56ad259a82cf2a9dfc408b32bf5da52371500b84745f7fb8b645712df676"
"3.4.3":
url: "https://github.com/libffi/libffi/releases/download/v3.4.3/libffi-3.4.3.tar.gz"
sha256: "4416dd92b6ae8fcb5b10421e711c4d3cb31203d77521a77d85d0102311e6c3b8"
"3.4.2":
url: "https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz"
sha256: "540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620"
"3.3":
url: "https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz"
sha256: "72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056"
patches:
"3.4.6":
- patch_file: "patches/0002-3.4.6-fix-libtool-path.patch"
- patch_file: "patches/0004-3.4.6-fix-complex-type-msvc.patch"
- patch_file: "patches/0005-3.4.4-do-not-install-libraries-to-arch-dependent-directories.patch"
- patch_file: "patches/0006-3.4.6-library-no-version-suffix.patch"
"3.4.4":
- patch_file: "patches/0002-3.4.3-fix-libtool-path.patch"
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
Expand All @@ -21,20 +23,6 @@ patches:
patch_type: "portability"
patch_source: "https://github.com/libffi/libffi/pull/764"
patch_description: "Forward declare the open_temp_exec_file function which is required by the C99 standard"
"3.4.3":
- patch_file: "patches/0002-3.4.3-fix-libtool-path.patch"
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
- patch_file: "patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch"
- patch_file: "patches/0006-3.4.3-library-no-version-suffix.patch"
- patch_file: "patches/0007-3.4.3-forward-declare-open_temp_exec_file.patch"
patch_type: "portability"
patch_source: "https://github.com/libffi/libffi/pull/764"
patch_description: "Forward declare the open_temp_exec_file function which is required by the C99 standard"
"3.4.2":
- patch_file: "patches/0002-3.4.2-fix-libtool-path.patch"
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
- patch_file: "patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch"
- patch_file: "patches/0006-3.4.2-library-no-version-suffix.patch"
"3.3":
- patch_file: "patches/0002-3.3-fix-libtool-path.patch"
- patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch"
Expand Down
32 changes: 14 additions & 18 deletions recipes/libffi/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from conan import ConanFile
from conan.tools.apple import fix_apple_shared_install_name
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import fix_apple_shared_install_name, is_apple_os
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, rm, rmdir
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import check_min_vs, is_msvc, is_msvc_static_runtime, msvc_runtime_flag, unix_path
Expand Down Expand Up @@ -42,6 +43,10 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def validate(self):
if is_apple_os(self) and self.settings.arch == "armv8" and Version(self.version) < "3.4.0":
raise ConanInvalidConfiguration(f"{self.ref} does not support Apple ARM CPUs")

def configure(self):
if self.options.shared:
Expand Down Expand Up @@ -78,9 +83,12 @@ def generate(self):
if self._settings_build.compiler == "apple-clang":
tc.configure_args.append("--disable-multi-os-directory")

tc.extra_defines.append("FFI_BUILDING")
if self.options.shared:
tc.extra_defines.append("FFI_BUILDING_DLL")
if Version(self.version) < "3.4.6":
tc.extra_defines.append("FFI_BUILDING")
elif not self.options.shared:
tc.extra_defines.append("FFI_STATIC_BUILD")

env = tc.environment()
if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"):
Expand Down Expand Up @@ -134,22 +142,9 @@ def generate(self):
env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh")))
tc.generate(env=env)

def _patch_source(self):
def build(self):
apply_conandata_patches(self)

if Version(self.version) < "3.3":
if self.settings.compiler == "clang" and Version(str(self.settings.compiler.version)) >= 7.0:
# https://android.googlesource.com/platform/external/libffi/+/ca22c3cb49a8cca299828c5ffad6fcfa76fdfa77
sysv_s_src = os.path.join(self.source_folder, "src", "arm", "sysv.S")
replace_in_file(self, sysv_s_src, "fldmiad", "vldmia")
replace_in_file(self, sysv_s_src, "fstmiad", "vstmia")
replace_in_file(self, sysv_s_src, "fstmfdd\tsp!,", "vpush")

# https://android.googlesource.com/platform/external/libffi/+/7748bd0e4a8f7d7c67b2867a3afdd92420e95a9f
replace_in_file(self, sysv_s_src, "stmeqia", "stmiaeq")

def build(self):
self._patch_source()
autotools = Autotools(self)
autotools.configure()
autotools.make()
Expand All @@ -170,4 +165,5 @@ def package_info(self):
self.cpp_info.libs = ["{}ffi".format("lib" if is_msvc(self) else "")]
self.cpp_info.set_property("pkg_config_name", "libffi")
if not self.options.shared:
self.cpp_info.defines = ["FFI_BUILDING"]
static_define = "FFI_STATIC_BUILD" if Version(self.version) >= "3.4.6" else "FFI_BUILDING"
self.cpp_info.defines = [static_define]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- configure
+++ configure
@@ -8979,7 +8979,7 @@
@@ -9882,7 +9882,7 @@
LIBTOOL_DEPS=$ltmain

# Always use our own libtool.
Expand All @@ -9,12 +9,12 @@



@@ -9072,7 +9072,7 @@
@@ -9974,7 +9974,7 @@
esac

# Global variables:
-ofile=libtool
+ofile=libtool.sh
can_build_shared=yes

# All known linkers require a '.a' archive for static linking (except MSVC,
# All known linkers require a '.a' archive for static linking (except MSVC and
56 changes: 56 additions & 0 deletions recipes/libffi/all/patches/0004-3.4.6-fix-complex-type-msvc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/src/types.c b/src/types.c
index c1c27f3..d5d52bb 100644
--- a/src/types.c
+++ b/src/types.c
@@ -31,6 +31,8 @@
#include <ffi.h>
#include <ffi_common.h>

+#include <complex.h>
+
/* Type definitions */

#define FFI_TYPEDEF(name, type, id, maybe_const)\
@@ -45,17 +47,17 @@ maybe_const ffi_type ffi_type_##name = { \
id, NULL \
}

-#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \
+#define FFI_COMPLEX_TYPEDEF(name, complex_type, maybe_const) \
static ffi_type *ffi_elements_complex_##name [2] = { \
(ffi_type *)(&ffi_type_##name), NULL \
}; \
struct struct_align_complex_##name { \
char c; \
- _Complex type x; \
+ complex_type x; \
}; \
FFI_EXTERN \
maybe_const ffi_type ffi_type_complex_##name = { \
- sizeof(_Complex type), \
+ sizeof(complex_type), \
offsetof(struct struct_align_complex_##name, x), \
FFI_TYPE_COMPLEX, \
(ffi_type **)ffi_elements_complex_##name \
@@ -99,8 +101,18 @@ const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST);
#endif

+#ifdef _MSC_VER
+# define FLOAT_COMPLEX _C_float_complex
+# define DOUBLE_COMPLEX _C_double_complex
+# define LDOUBLE_COMPLEX _C_ldouble_complex
+#else
+# define FLOAT_COMPLEX float _Complex
+# define DOUBLE_COMPLEX double _Complex
+# define LDOUBLE_COMPLEX long double _Complex
+#endif
+
#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
-FFI_COMPLEX_TYPEDEF(float, float, const);
-FFI_COMPLEX_TYPEDEF(double, double, const);
-FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST);
+FFI_COMPLEX_TYPEDEF(float, FLOAT_COMPLEX, const);
+FFI_COMPLEX_TYPEDEF(double, DOUBLE_COMPLEX, const);
+FFI_COMPLEX_TYPEDEF(longdouble, LDOUBLE_COMPLEX, FFI_LDBL_CONST);
#endif

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
--- Makefile.in
+++ Makefile.in
@@ -615,7 +615,7 @@
diff --git a/Makefile.in b/Makefile.in
index 450200a..abcee85 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -618,7 +618,7 @@ AM_CFLAGS = $(am__append_3)
@LIBFFI_BUILD_VERSIONED_SHLIB_FALSE@libffi_version_dep =
@LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi_version_dep = libffi.map-sun
Expand Down
6 changes: 2 additions & 4 deletions recipes/libffi/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
versions:
"3.4.4":
folder: "all"
"3.4.3":
"3.4.6":
folder: "all"
"3.4.2":
"3.4.4":
folder: "all"
"3.3":
folder: "all"

0 comments on commit 3286aeb

Please sign in to comment.