From 3286aeb38afcf131a39044e737d548cd5f3c976c Mon Sep 17 00:00:00 2001 From: Ahajha <44127594+Ahajha@users.noreply.github.com> Date: Tue, 28 May 2024 12:09:41 -0400 Subject: [PATCH] (#23362) libffi: Add 3.4.6, remove 3.4.2 and 3.4.3 * 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 --------- Signed-off-by: Uilian Ries Co-authored-by: Uilian Ries --- recipes/libffi/all/conandata.yml | 28 +++------- recipes/libffi/all/conanfile.py | 32 +++++------ ...atch => 0002-3.4.6-fix-libtool-path.patch} | 6 +- .../0004-3.4.6-fix-complex-type-msvc.patch | 56 +++++++++++++++++++ ...raries-to-arch-dependent-directories.patch | 11 ---- ...raries-to-arch-dependent-directories.patch | 11 ---- ...0006-3.4.2-library-no-version-suffix.patch | 11 ---- ...006-3.4.6-library-no-version-suffix.patch} | 8 ++- recipes/libffi/config.yml | 6 +- 9 files changed, 88 insertions(+), 81 deletions(-) rename recipes/libffi/all/patches/{0002-3.4.2-fix-libtool-path.patch => 0002-3.4.6-fix-libtool-path.patch} (84%) create mode 100644 recipes/libffi/all/patches/0004-3.4.6-fix-complex-type-msvc.patch delete mode 100644 recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch delete mode 100644 recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch delete mode 100644 recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch rename recipes/libffi/all/patches/{0006-3.4.3-library-no-version-suffix.patch => 0006-3.4.6-library-no-version-suffix.patch} (80%) diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index 5984134b2d8b9..4ae82714f72f8 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -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" @@ -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" diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index e46a94d1b4462..cc062fca08904 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -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 @@ -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: @@ -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"): @@ -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() @@ -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] diff --git a/recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch b/recipes/libffi/all/patches/0002-3.4.6-fix-libtool-path.patch similarity index 84% rename from recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch rename to recipes/libffi/all/patches/0002-3.4.6-fix-libtool-path.patch index fad9e64adff17..e557baacf2699 100644 --- a/recipes/libffi/all/patches/0002-3.4.2-fix-libtool-path.patch +++ b/recipes/libffi/all/patches/0002-3.4.6-fix-libtool-path.patch @@ -1,6 +1,6 @@ --- configure +++ configure -@@ -8979,7 +8979,7 @@ +@@ -9882,7 +9882,7 @@ LIBTOOL_DEPS=$ltmain # Always use our own libtool. @@ -9,7 +9,7 @@ -@@ -9072,7 +9072,7 @@ +@@ -9974,7 +9974,7 @@ esac # Global variables: @@ -17,4 +17,4 @@ +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 diff --git a/recipes/libffi/all/patches/0004-3.4.6-fix-complex-type-msvc.patch b/recipes/libffi/all/patches/0004-3.4.6-fix-complex-type-msvc.patch new file mode 100644 index 0000000000000..4779afe0a2e85 --- /dev/null +++ b/recipes/libffi/all/patches/0004-3.4.6-fix-complex-type-msvc.patch @@ -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 + #include + ++#include ++ + /* 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 diff --git a/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch deleted file mode 100644 index 8e14796ab662a..0000000000000 --- a/recipes/libffi/all/patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -517,7 +517,7 @@ - target_os = @target_os@ - target_vendor = @target_vendor@ - toolexecdir = @toolexecdir@ --toolexeclibdir = @toolexeclibdir@ -+toolexeclibdir = @libdir@ - top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ diff --git a/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch deleted file mode 100644 index e82abf24a4fb1..0000000000000 --- a/recipes/libffi/all/patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -520,7 +520,7 @@ - target_vendor = @target_vendor@ - tmake_file = @tmake_file@ - toolexecdir = @toolexecdir@ --toolexeclibdir = @toolexeclibdir@ -+toolexeclibdir = @libdir@ - top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ diff --git a/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch deleted file mode 100644 index 80c36df06441e..0000000000000 --- a/recipes/libffi/all/patches/0006-3.4.2-library-no-version-suffix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -610,7 +610,7 @@ - @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 --libffi_version_info = -version-info `grep -v '^\#' $(srcdir)/libtool-version` -+libffi_version_info = -avoid-version - libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS) - libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep) - AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src diff --git a/recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.4.6-library-no-version-suffix.patch similarity index 80% rename from recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch rename to recipes/libffi/all/patches/0006-3.4.6-library-no-version-suffix.patch index 0ad4d29b1c4ce..726e8c1eb4a47 100644 --- a/recipes/libffi/all/patches/0006-3.4.3-library-no-version-suffix.patch +++ b/recipes/libffi/all/patches/0006-3.4.6-library-no-version-suffix.patch @@ -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 diff --git a/recipes/libffi/config.yml b/recipes/libffi/config.yml index af3a9af92b306..e6382ec734d6d 100644 --- a/recipes/libffi/config.yml +++ b/recipes/libffi/config.yml @@ -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"