From b6a5f2c8e98af96c7d40e0464bfb9d82f43d60e7 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Sat, 10 Sep 2022 08:49:18 +0200 Subject: [PATCH 01/47] Added Conan v2 support Based on this template: https://github.com/conan-io/conan-center-index/tree/master/docs/package_templates/autotools_package Contribute to CURA-9628 --- recipes/libffi/all/conandata.yml | 42 +-- recipes/libffi/all/conanfile.py | 246 +++++++++--------- .../libffi/all/test_package/CMakeLists.txt | 17 +- recipes/libffi/all/test_package/conanfile.py | 22 +- .../libffi/all/test_v1_package/CMakeLists.txt | 11 + .../libffi/all/test_v1_package/conanfile.py | 17 ++ .../libffi/all/test_v1_package/test_package.c | 99 +++++++ 7 files changed, 284 insertions(+), 170 deletions(-) create mode 100644 recipes/libffi/all/test_v1_package/CMakeLists.txt create mode 100644 recipes/libffi/all/test_v1_package/conanfile.py create mode 100644 recipes/libffi/all/test_v1_package/test_package.c diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index 4ce9946df3a32..8cfac8e09d592 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -22,33 +22,19 @@ patches: - base_path: "source_subfolder" patch_file: "patches/0006-3.4.3-library-no-version-suffix.patch" "3.4.2": - - base_path: "source_subfolder" - patch_file: "patches/0002-3.4.2-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.4.2-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.4.2-library-no-version-suffix.patch" + - 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": - - base_path: "source_subfolder" - patch_file: "patches/0002-3.3-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.3-library-no-version-suffix.patch" + - patch_file: "patches/0002-3.3-fix-libtool-path.patch" + - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" + - patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch" + - patch_file: "patches/0006-3.3-library-no-version-suffix.patch" "3.2.1": - - base_path: "source_subfolder" - patch_file: "patches/0001-3.2.1-add-support-windows-dll.patch" - - base_path: "source_subfolder" - patch_file: "patches/0002-3.2.1-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0003-3.2.1-fix-win64-assembly.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" + - patch_file: "patches/0001-3.2.1-add-support-windows-dll.patch" + - patch_file: "patches/0002-3.2.1-fix-libtool-path.patch" + - patch_file: "patches/0003-3.2.1-fix-win64-assembly.patch" + - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" + - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" + - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 0c3c43ae18843..9be794595ba5e 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,51 +1,46 @@ -from conan.tools.microsoft import msvc_runtime_flag -from conans import ConanFile, tools, AutoToolsBuildEnvironment -import contextlib import os -import shutil -required_conan_version = ">=1.36" +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches +from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path +required_conan_version = ">=1.51.3" -class LibffiConan(ConanFile): + +class PackageConan(ConanFile): name = "libffi" description = "A portable, high level programming interface to various calling conventions" - topics = ("libffi", "runtime", "foreign-function-interface", "runtime-library") + license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://sourceware.org/libffi/" - license = "MIT" - + topics = ("libffi", "runtime", "foreign-function-interface", "runtime-library") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], } default_options = { - "shared": False, + "shared": False + , "fPIC": True, } - _autotools = None - - @property - def _source_subfolder(self): - return "source_subfolder" - - @property - def _is_msvc(self): - return str(self.settings.compiler) in ["Visual Studio", "msvc"] - @property def _settings_build(self): + # TODO: Remove for Conan v2 return getattr(self, "settings_build", self.settings) @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) + def win_bash(self): + return self._settings_build.os == "Windows" def export_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - self.copy(patch["patch_file"]) + for p in self.conan_data.get("patches", {}).get(self.version, []): + copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) def config_options(self): if self.settings.os == "Windows": @@ -53,44 +48,61 @@ def config_options(self): def configure(self): if self.options.shared: - del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + try: + del self.options.fPIC + except Exception: + pass + try: + del self.settings.compiler.libcxx + except Exception: + pass + try: + del self.settings.compiler.cppstd + except Exception: + pass + + def layout(self): + basic_layout(self, src_folder="libffi") + + def validate(self): + if self.info.settings.os not in ["Linux", "FreeBSD", "MacOS", "Windows"]: + raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") def build_requirements(self): - if self._settings_build.os == "Windows" and not tools.get_env("CONAN_BASH_PATH"): - self.build_requires("msys2/cci.latest") - self.build_requires("gnu-config/cci.20201022") + if self.win_bash and not os.environ.get("CONAN_BASH_PATH"): + self.tool_requires("msys2/cci.latest") + self.tool_requires("automake/1.16.5") + self.tool_requires("libtool/2.4.7") def source(self): - tools.get(**self.conan_data["sources"][self.version], - destination=self._source_subfolder, strip_root=True) - - def _patch_sources(self): - for patch in self.conan_data.get("patches", {}).get(self.version, []): - tools.patch(**patch) - # Generate rpath friendly shared lib on macOS - configure_path = os.path.join(self._source_subfolder, "configure") - tools.replace_in_file(configure_path, "-install_name \\$rpath/", "-install_name @rpath/") - - if tools.Version(self.version) < "3.3": - if self.settings.compiler == "clang" and tools.Version(str(self.settings.compiler.version)) >= 7.0: - # https://android.googlesource.com/platform/external/libffi/+/ca22c3cb49a8cca299828c5ffad6fcfa76fdfa77 - sysv_s_src = os.path.join(self._source_subfolder, "src", "arm", "sysv.S") - tools.replace_in_file(sysv_s_src, "fldmiad", "vldmia") - tools.replace_in_file(sysv_s_src, "fstmiad", "vstmia") - tools.replace_in_file(sysv_s_src, "fstmfdd\tsp!,", "vpush") - - # https://android.googlesource.com/platform/external/libffi/+/7748bd0e4a8f7d7c67b2867a3afdd92420e95a9f - tools.replace_in_file(sysv_s_src, "stmeqia", "stmiaeq") - - @contextlib.contextmanager - def _build_context(self): - extra_env_vars = {} - if tools.os_info.is_windows and (self._is_msvc or self.settings.compiler == "clang") : - msvcc = tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "msvcc.sh")) + get(self, **self.conan_data["sources"][self.version], + destination=self.source_folder, strip_root=True) + + def generate(self): + yes_no = lambda v: "yes" if v else "no" + tc = AutotoolsToolchain(self) + tc.configure_args.extend([ + f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}", + "--enable-builddir=no", + "--enable-docs=no", + ]) + + if is_msvc(self): + build = "{}-{}-{}".format( + "x86_64" if self._settings_build.arch == "x86_64" else "i686", + "pc" if self._settings_build.arch == "x86" else "win64", + "mingw64") + host = "{}-{}-{}".format( + "x86_64" if self.settings.arch == "x86_64" else "i686", + "pc" if self.settings.arch == "x86" else "win64", + "mingw64") + tc.configure_args.append(f"--build={build}") + tc.configure_args.append(f"--host={host}") + + if is_msvc(self) or self.settings.compiler == "clang": + msvcc = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) msvcc_args = [] - if self._is_msvc: + if is_msvc(self): if self.settings.arch == "x86_64": msvcc_args.append("-m64") elif self.settings.arch == "x86": @@ -99,87 +111,65 @@ def _build_context(self): msvcc_args.append("-clang-cl") if msvcc_args: - msvcc = "{} {}".format(msvcc, " ".join(msvcc_args)) - extra_env_vars.update(tools.vcvars_dict(self.settings)) - extra_env_vars.update({ - "INSTALL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "install-sh")), - "LIBTOOL": tools.unix_path(os.path.join(self.source_folder, self._source_subfolder, "ltmain.sh")), - "CC": msvcc, - "CXX": msvcc, - "LD": "link", - "CPP": "cl -nologo -EP", - "CXXCPP": "cl -nologo -EP", - }) - with tools.environment_append(extra_env_vars): - yield - - def _configure_autotools(self): - if self._autotools: - return self._autotools - self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows) - yes_no = lambda v: "yes" if v else "no" - config_args = [ - "--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")), - "--enable-shared={}".format(yes_no(self.options.shared)), - "--enable-static={}".format(yes_no(not self.options.shared)), - ] - self._autotools.defines.append("FFI_BUILDING") - if self.options.shared: - self._autotools.defines.append("FFI_BUILDING_DLL") - if self._is_msvc: + msvcc_args = " ".join(msvcc_args) + msvcc = f"{msvcc} {msvcc_args}" + + if is_msvc(self): if "MT" in msvc_runtime_flag(self): - self._autotools.defines.append("USE_STATIC_RTL") + tc.extra_defines.append("USE_STATIC_RTL") if "d" in msvc_runtime_flag(self): - self._autotools.defines.append("USE_DEBUG_RTL") - build = None - host = None - if self._is_msvc: - build = "{}-{}-{}".format( - "x86_64" if self._settings_build.arch == "x86_64" else "i686", - "pc" if self._settings_build.arch == "x86" else "w64", - "cygwin") - host = "{}-{}-{}".format( - "x86_64" if self.settings.arch == "x86_64" else "i686", - "pc" if self.settings.arch == "x86" else "w64", - "cygwin") + tc.extra_defines.append("d") + + if self.options.shared: + tc.extra_defines.append("FFI_BUILDING_DLL") else: - if self._autotools.host and "x86-" in self._autotools.host: - self._autotools.host = self._autotools.host.replace("x86", "i686") - self._autotools.configure(args=config_args, configure_dir=self._source_subfolder, build=build, host=host) - return self._autotools + tc.extra_defines.append("FFI_BUILDING") + + if self.settings.build_type == "Debug": + tc.extra_defines.append("FFI_DEBUG") + + env = tc.environment() + if is_msvc(self) or self.settings.compiler == "clang": + env.define("LD", "link") + env.define_path("CXX", msvcc) + env.define_path("CC", msvcc) + env.define("CXXCPP", "cl -nologo -EP") + env.define("CPP", "cl -nologo -EP") + env.define("AR", unix_path(self, self.conf.get('tools.automake:ar-lib'))) + env.define("LD", "link") + env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, 'ltmain.sh'))) + env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) + env.define("NM", "dumpbin -symbols") + env.define("OBJDUMP", ":") + env.define("RANLIB", ":") + env.define("STRIP", ":") + + tc.generate(env) + + ms = VirtualBuildEnv(self) + ms.generate(scope="build") def build(self): - self._patch_sources() - shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, - os.path.join(self._source_subfolder, "config.sub")) - shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, - os.path.join(self._source_subfolder, "config.guess")) - - with self._build_context(): - autotools = self._configure_autotools() - autotools.make() - if tools.get_env("CONAN_RUN_TESTS", False): - autotools.make(target="check") + apply_conandata_patches(self) + + autotools = Autotools(self) + autotools.configure() + autotools.make() def package(self): - self.copy("LICENSE", src=self._source_subfolder, dst="licenses") - if self._is_msvc: - if self.options.shared: - self.copy("libffi.dll", src=".libs", dst="bin") - self.copy("libffi.lib", src=".libs", dst="lib") - self.copy("*.h", src="include", dst="include") - else: - with self._build_context(): - autotools = self._configure_autotools() - autotools.install() + autotools = Autotools(self) + autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem - tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) - tools.rmdir(os.path.join(self.package_folder, "share")) - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la") + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=os.path.join(self.package_folder, "lib")) + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + + # some files extensions and folders are not allowed. Please, read the FAQs to get informed. + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) 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") - self.cpp_info.libs = ["{}ffi".format("lib" if self._is_msvc else "")] if not self.options.shared: self.cpp_info.defines = ["FFI_BUILDING"] - diff --git a/recipes/libffi/all/test_package/CMakeLists.txt b/recipes/libffi/all/test_package/CMakeLists.txt index abdb4e55993d7..2fe7e3a093f39 100644 --- a/recipes/libffi/all/test_package/CMakeLists.txt +++ b/recipes/libffi/all/test_package/CMakeLists.txt @@ -1,11 +1,12 @@ -cmake_minimum_required(VERSION 3.1) -project(test_package C) +cmake_minimum_required(VERSION 3.8) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() -if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d") - add_compile_definitions(DISABLE_FFI_CALL) -endif() +project(test_package C) # if the project is pure C +# project(test_package CXX) # if the project uses c++ + +find_package(libffi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +# don't link to ${CONAN_LIBS} or CONAN_PKG::package +target_link_libraries(${PROJECT_NAME} PRIVATE libffi::libffi) +# In case the target project need a specific C++ standard +# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libffi/all/test_package/conanfile.py b/recipes/libffi/all/test_package/conanfile.py index d4128b0450777..1111583fea732 100644 --- a/recipes/libffi/all/test_package/conanfile.py +++ b/recipes/libffi/all/test_package/conanfile.py @@ -1,10 +1,20 @@ -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake import os +# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) def build(self): cmake = CMake(self) @@ -12,6 +22,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/libffi/all/test_v1_package/CMakeLists.txt b/recipes/libffi/all/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..abdb4e55993d7 --- /dev/null +++ b/recipes/libffi/all/test_v1_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package C) + +include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") +conan_basic_setup() +if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d") + add_compile_definitions(DISABLE_FFI_CALL) +endif() + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libffi/all/test_v1_package/conanfile.py b/recipes/libffi/all/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..d4128b0450777 --- /dev/null +++ b/recipes/libffi/all/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/libffi/all/test_v1_package/test_package.c b/recipes/libffi/all/test_v1_package/test_package.c new file mode 100644 index 0000000000000..ec8d8480055a3 --- /dev/null +++ b/recipes/libffi/all/test_v1_package/test_package.c @@ -0,0 +1,99 @@ +#if defined(_MSC_VER) +#pragma runtime_checks("s", off) +#endif + +#include + +#include +#include +#include + +unsigned print_uint(unsigned arg) { + printf("print_int(%u)\n", arg); + return 3 * arg; +} + +typedef struct { + FILE *stream; +} puts_binding_userdata; + +void puts_binding(ffi_cif *cif, void *ret, void** args, void *userdata) +{ + fputs(*(char **)args[0], ((puts_binding_userdata *)userdata)->stream); + *((unsigned*)ret) = 1337; +} + +int main() +{ + { + ffi_type *argtypes[1] = {&ffi_type_uint32}; + ffi_cif cif; + ffi_status status = FFI_BAD_ABI; + status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes); + if (status != FFI_OK) + { + puts("1 ffi_prep_cif FAILED.\n\n"); + return EXIT_FAILURE; + } + #ifndef DISABLE_FFI_CALL + // this fails on msvc debug runtime because of https://github.com/libffi/libffi/issues/456 + unsigned rvalue = 0; + unsigned arg1 = 13; + const unsigned expected_ret = 3 * arg1; + void *args[] = {(void*)(&arg1)}; + ffi_call(&cif, FFI_FN(&print_uint), (void *) &rvalue, args); + printf("ffi_call returns %d (should be %d)\n", rvalue, expected_ret); + if (rvalue != expected_ret) { + printf("ffi_call FAILED. Expected %d, but got %d.\n", expected_ret, rvalue); + return EXIT_FAILURE; + } + #endif + return EXIT_SUCCESS; + } + { + #ifdef FFI_CLOSURES + ffi_type *argtypes[1] = {&ffi_type_uint}; + ffi_cif cif; + ffi_status status = FFI_BAD_ABI; + status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes); + if (status != FFI_OK) + { + puts("2 ffi_prep_cif FAILED.\n\n"); + return EXIT_FAILURE; + } + unsigned (*bound_puts)(const char *) = NULL; + ffi_closure *closure = NULL; + closure = (ffi_closure *) ffi_closure_alloc(sizeof(ffi_closure), (void **)&bound_puts); + if (closure == NULL) { + puts("ffi_closure_alloc FAILED\n"); + return EXIT_FAILURE; + } + + puts_binding_userdata userdata; + userdata.stream = stdout; + status = ffi_prep_closure_loc(closure, &cif, puts_binding, + &userdata, (void *) bound_puts); + if (status != FFI_OK) { + puts("ffi_prep_closure_loc FAILED\n"); + return EXIT_FAILURE; + } + puts("Start calling bound_put():"); + bound_puts("Hello"); + bound_puts(" "); + bound_puts("World"); + unsigned rc = bound_puts("\n"); + printf("bounds_puts returned %d.\n", rc); + if (rc != 1337) { + puts("bounds_put returned wrong number."); + return EXIT_FAILURE; + } + + ffi_closure_free(closure); + #endif + } + return EXIT_SUCCESS; +} + +#if defined(_MSC_VER) +#pragma runtime_checks("s", restore) +#endif From c468c848570f4a496d7a9202e997c4f189d0df9d Mon Sep 17 00:00:00 2001 From: "j.spijker@ultimaker.com" Date: Mon, 12 Sep 2022 09:24:59 +0200 Subject: [PATCH 02/47] catch ValueError instead of broad Exception catch Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 9be794595ba5e..33816d6f8bc7a 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -50,15 +50,15 @@ def configure(self): if self.options.shared: try: del self.options.fPIC - except Exception: + except ValueError: pass try: del self.settings.compiler.libcxx - except Exception: + except ValueError: pass try: del self.settings.compiler.cppstd - except Exception: + except ValueError: pass def layout(self): From d19abd5fa9d9bbf2c475740272b7fd29de7f97f4 Mon Sep 17 00:00:00 2001 From: jelle Spijker Date: Mon, 12 Sep 2022 09:25:37 +0200 Subject: [PATCH 03/47] Validating not needed in this recipe Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 33816d6f8bc7a..b860c48ab5825 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -64,10 +64,6 @@ def configure(self): def layout(self): basic_layout(self, src_folder="libffi") - def validate(self): - if self.info.settings.os not in ["Linux", "FreeBSD", "MacOS", "Windows"]: - raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.info.settings.os}.") - def build_requirements(self): if self.win_bash and not os.environ.get("CONAN_BASH_PATH"): self.tool_requires("msys2/cci.latest") From 8077e01e822b96fcfd0ee86b6ba689f8763d47af Mon Sep 17 00:00:00 2001 From: jelle Spijker Date: Mon, 12 Sep 2022 09:41:10 +0200 Subject: [PATCH 04/47] Clean-up various path references Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index b860c48ab5825..927036c511f51 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,10 +1,7 @@ -import os - from conan import ConanFile -from conan.errors import ConanInvalidConfiguration from conan.tools.env import VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches -from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps, PkgConfigDeps +from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path @@ -65,7 +62,7 @@ def layout(self): basic_layout(self, src_folder="libffi") def build_requirements(self): - if self.win_bash and not os.environ.get("CONAN_BASH_PATH"): + if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): self.tool_requires("msys2/cci.latest") self.tool_requires("automake/1.16.5") self.tool_requires("libtool/2.4.7") @@ -79,6 +76,7 @@ def generate(self): tc = AutotoolsToolchain(self) tc.configure_args.extend([ f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}", + "--datarootdir=${prefix}/res", "--enable-builddir=no", "--enable-docs=no", ]) @@ -96,7 +94,7 @@ def generate(self): tc.configure_args.append(f"--host={host}") if is_msvc(self) or self.settings.compiler == "clang": - msvcc = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) + msvcc = unix_path(self, self.source_path.joinpath("msvcc.sh")) msvcc_args = [] if is_msvc(self): if self.settings.arch == "x86_64": @@ -131,10 +129,10 @@ def generate(self): env.define_path("CC", msvcc) env.define("CXXCPP", "cl -nologo -EP") env.define("CPP", "cl -nologo -EP") - env.define("AR", unix_path(self, self.conf.get('tools.automake:ar-lib'))) + env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") env.define("LD", "link") - env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, 'ltmain.sh'))) - env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) + env.define("LIBTOOL", unix_path(self, self.source_path.joinpath("ltmain.sh"))) + env.define("INSTALL", unix_path(self, self.source_path.joinpath("install-sh"))) env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") env.define("RANLIB", ":") @@ -156,13 +154,12 @@ def package(self): autotools = Autotools(self) autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem - copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=os.path.join(self.package_folder, "lib")) - copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + copy(self, pattern="*.dll", dst=self.package_path.joinpath("bin"), src=self.package_path.joinpath("lib")) + copy(self, pattern="LICENSE", dst=self.package_path.joinpath("licenses"), src=self.source_folder) - # some files extensions and folders are not allowed. Please, read the FAQs to get informed. - rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) - rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) - rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.la", self.package_path.joinpath("lib"), recursive=True) + rmdir(self, self.package_path.joinpath("lib", "pkgconfig")) + rmdir(self, self.package_path.joinpath("share")) def package_info(self): self.cpp_info.libs = ["{}ffi".format("lib" if is_msvc(self) else "")] From d945949b772eb46b42fb6d77d1bd8c736bc81278 Mon Sep 17 00:00:00 2001 From: jellespijker Date: Mon, 12 Sep 2022 09:47:12 +0200 Subject: [PATCH 05/47] Use modern apple rpath fix Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 927036c511f51..94b7052f929a2 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -4,6 +4,7 @@ from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os required_conan_version = ">=1.51.3" @@ -154,6 +155,9 @@ def package(self): autotools = Autotools(self) autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem + if is_apple_os(self): + fix_apple_shared_install_name(self) + copy(self, pattern="*.dll", dst=self.package_path.joinpath("bin"), src=self.package_path.joinpath("lib")) copy(self, pattern="LICENSE", dst=self.package_path.joinpath("licenses"), src=self.source_folder) From 02d6ace1b744b6f1860a3cfedc85ea37a25c5df7 Mon Sep 17 00:00:00 2001 From: jelle Spijker Date: Mon, 12 Sep 2022 09:51:05 +0200 Subject: [PATCH 06/47] Reapplied patches again Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 21 +++++++++++++++++--- recipes/libffi/all/test_package/conanfile.py | 1 - 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 94b7052f929a2..d0aeb45984c7c 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,10 +1,11 @@ from conan import ConanFile +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os from conan.tools.env import VirtualBuildEnv -from conan.tools.files import copy, get, rm, rmdir, apply_conandata_patches +from conan.tools.files import apply_conandata_patches, copy, get, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path -from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.scm import Version required_conan_version = ">=1.51.3" @@ -144,9 +145,23 @@ def generate(self): ms = VirtualBuildEnv(self) ms.generate(scope="build") - def build(self): + def _patch_source(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 = self.source_path.joinpath("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() diff --git a/recipes/libffi/all/test_package/conanfile.py b/recipes/libffi/all/test_package/conanfile.py index 1111583fea732..a9fb96656f203 100644 --- a/recipes/libffi/all/test_package/conanfile.py +++ b/recipes/libffi/all/test_package/conanfile.py @@ -4,7 +4,6 @@ import os -# It will become the standard on Conan 2.x class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" From 35126eaac1a753d3af6598b47201eaf83d8937d8 Mon Sep 17 00:00:00 2001 From: "j.spijker@ultimaker.com" Date: Mon, 12 Sep 2022 10:44:44 +0200 Subject: [PATCH 07/47] convert Path to str before passing to unix_path Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index d0aeb45984c7c..55c2d48330cdb 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -96,7 +96,7 @@ def generate(self): tc.configure_args.append(f"--host={host}") if is_msvc(self) or self.settings.compiler == "clang": - msvcc = unix_path(self, self.source_path.joinpath("msvcc.sh")) + msvcc = unix_path(self, str(self.source_path.joinpath("msvcc.sh"))) msvcc_args = [] if is_msvc(self): if self.settings.arch == "x86_64": @@ -133,8 +133,8 @@ def generate(self): env.define("CPP", "cl -nologo -EP") env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") env.define("LD", "link") - env.define("LIBTOOL", unix_path(self, self.source_path.joinpath("ltmain.sh"))) - env.define("INSTALL", unix_path(self, self.source_path.joinpath("install-sh"))) + env.define("LIBTOOL", unix_path(self, str(self.source_path.joinpath("ltmain.sh")))) + env.define("INSTALL", unix_path(self, str(self.source_path.joinpath("install-sh")))) env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") env.define("RANLIB", ":") From 31883300f8b70727066045a92c6989a5fd322411 Mon Sep 17 00:00:00 2001 From: "j.spijker@ultimaker.com" Date: Mon, 12 Sep 2022 11:23:16 +0200 Subject: [PATCH 08/47] Removed clang exception in generate Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 55c2d48330cdb..91464fdacb1d8 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -95,22 +95,18 @@ def generate(self): tc.configure_args.append(f"--build={build}") tc.configure_args.append(f"--host={host}") - if is_msvc(self) or self.settings.compiler == "clang": + if is_msvc(self): msvcc = unix_path(self, str(self.source_path.joinpath("msvcc.sh"))) msvcc_args = [] - if is_msvc(self): - if self.settings.arch == "x86_64": - msvcc_args.append("-m64") - elif self.settings.arch == "x86": - msvcc_args.append("-m32") - elif self.settings.compiler == "clang": - msvcc_args.append("-clang-cl") + if self.settings.arch == "x86_64": + msvcc_args.append("-m64") + elif self.settings.arch == "x86": + msvcc_args.append("-m32") if msvcc_args: msvcc_args = " ".join(msvcc_args) msvcc = f"{msvcc} {msvcc_args}" - if is_msvc(self): if "MT" in msvc_runtime_flag(self): tc.extra_defines.append("USE_STATIC_RTL") if "d" in msvc_runtime_flag(self): @@ -125,7 +121,7 @@ def generate(self): tc.extra_defines.append("FFI_DEBUG") env = tc.environment() - if is_msvc(self) or self.settings.compiler == "clang": + if is_msvc(self): env.define("LD", "link") env.define_path("CXX", msvcc) env.define_path("CC", msvcc) From 5021f702f065f482bbcafba1d2c28f7d94aa196d Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 14 Sep 2022 08:31:32 +0200 Subject: [PATCH 09/47] Use user_info.ar_lib as a workaround Should be reverted once https://github.com/conan-io/conan-center-index/pull/12898 has been merged Contribute to CURA-9628 and CURA-9575 --- recipes/libffi/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 91464fdacb1d8..515ee085929c5 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -127,7 +127,8 @@ def generate(self): env.define_path("CC", msvcc) env.define("CXXCPP", "cl -nologo -EP") env.define("CPP", "cl -nologo -EP") - env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") + # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged + env.define("AR", f"{unix_path(self, self.deps_user_info['automake'].ar_lib)} lib") env.define("LD", "link") env.define("LIBTOOL", unix_path(self, str(self.source_path.joinpath("ltmain.sh")))) env.define("INSTALL", unix_path(self, str(self.source_path.joinpath("install-sh")))) From 98a8c71f653de9d6c703e90ad18ced60e1de1590 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Wed, 14 Sep 2022 11:27:19 +0200 Subject: [PATCH 10/47] disable multi os directory when compiling with apple-clang Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 515ee085929c5..ab564218c27d7 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -92,8 +92,15 @@ def generate(self): "x86_64" if self.settings.arch == "x86_64" else "i686", "pc" if self.settings.arch == "x86" else "win64", "mingw64") - tc.configure_args.append(f"--build={build}") - tc.configure_args.append(f"--host={host}") + tc.configure_args.extend([ + f"--build={build}", + f"--host={host}", + ]) + + if self._settings_build.compiler == "apple-clang": + tc.configure_args.extend([ + "--disable-multi-os-directory", + ]) if is_msvc(self): msvcc = unix_path(self, str(self.source_path.joinpath("msvcc.sh"))) From d56e09d0c2a01b91e189a3c375619f89f5a51832 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Sat, 17 Sep 2022 18:09:17 +0200 Subject: [PATCH 11/47] Use conf for AR variable Contributes to CURA-9628 --- recipes/libffi/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index ab564218c27d7..7f572b97a31ca 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -134,8 +134,8 @@ def generate(self): env.define_path("CC", msvcc) env.define("CXXCPP", "cl -nologo -EP") env.define("CPP", "cl -nologo -EP") - # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged - env.define("AR", f"{unix_path(self, self.deps_user_info['automake'].ar_lib)} lib") + env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged + #env.define("AR", f"{unix_path(self, self.deps_user_info['automake'].ar_lib)} lib") # FIXME: deps_user_info only seems to work with run scoped dependencies env.define("LD", "link") env.define("LIBTOOL", unix_path(self, str(self.source_path.joinpath("ltmain.sh")))) env.define("INSTALL", unix_path(self, str(self.source_path.joinpath("install-sh")))) From 09263f592d089f79a6f0173d11b969e796b04c1b Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 7 Oct 2022 15:36:00 -0500 Subject: [PATCH 12/47] Slight clean up --- recipes/libffi/all/conandata.yml | 12 +-- recipes/libffi/all/conanfile.py | 12 +-- .../libffi/all/test_package/CMakeLists.txt | 6 +- .../libffi/all/test_v1_package/CMakeLists.txt | 2 +- .../libffi/all/test_v1_package/test_package.c | 99 ------------------- 5 files changed, 11 insertions(+), 120 deletions(-) delete mode 100644 recipes/libffi/all/test_v1_package/test_package.c diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index 8cfac8e09d592..e39bdd333bf68 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -13,14 +13,10 @@ sources: sha256: "d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37" patches: "3.4.3": - - base_path: "source_subfolder" - patch_file: "patches/0002-3.4.3-fix-libtool-path.patch" - - base_path: "source_subfolder" - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" - - base_path: "source_subfolder" - patch_file: "patches/0005-3.4.3-do-not-install-libraries-to-arch-dependent-directories.patch" - - base_path: "source_subfolder" - patch_file: "patches/0006-3.4.3-library-no-version-suffix.patch" + - 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" "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" diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 7f572b97a31ca..c55cf244a817b 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,13 +1,13 @@ from conan import ConanFile 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, get, replace_in_file, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path from conan.tools.scm import Version -required_conan_version = ">=1.51.3" +required_conan_version = ">=1.52.0" class PackageConan(ConanFile): @@ -16,15 +16,14 @@ class PackageConan(ConanFile): license = "MIT" url = "https://github.com/conan-io/conan-center-index" homepage = "https://sourceware.org/libffi/" - topics = ("libffi", "runtime", "foreign-function-interface", "runtime-library") + topics = ("runtime", "foreign-function-interface", "runtime-library") settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], } default_options = { - "shared": False - , + "shared": False, "fPIC": True, } @@ -38,8 +37,7 @@ def win_bash(self): return self._settings_build.os == "Windows" def export_sources(self): - for p in self.conan_data.get("patches", {}).get(self.version, []): - copy(self, p["patch_file"], self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) def config_options(self): if self.settings.os == "Windows": diff --git a/recipes/libffi/all/test_package/CMakeLists.txt b/recipes/libffi/all/test_package/CMakeLists.txt index 2fe7e3a093f39..80fe7087b6f9f 100644 --- a/recipes/libffi/all/test_package/CMakeLists.txt +++ b/recipes/libffi/all/test_package/CMakeLists.txt @@ -1,12 +1,8 @@ cmake_minimum_required(VERSION 3.8) -project(test_package C) # if the project is pure C -# project(test_package CXX) # if the project uses c++ +project(test_package LANGUAGES C) find_package(libffi REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.c) -# don't link to ${CONAN_LIBS} or CONAN_PKG::package target_link_libraries(${PROJECT_NAME} PRIVATE libffi::libffi) -# In case the target project need a specific C++ standard -# target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/recipes/libffi/all/test_v1_package/CMakeLists.txt b/recipes/libffi/all/test_v1_package/CMakeLists.txt index abdb4e55993d7..5b6f863b5bbc1 100644 --- a/recipes/libffi/all/test_v1_package/CMakeLists.txt +++ b/recipes/libffi/all/test_v1_package/CMakeLists.txt @@ -7,5 +7,5 @@ if(CONAN_SETTINGS_COMPILER_RUNTIME MATCHES ".*d") add_compile_definitions(DISABLE_FFI_CALL) endif() -add_executable(${PROJECT_NAME} test_package.c) +add_executable(${PROJECT_NAME} ../test_package/test_package.c) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/libffi/all/test_v1_package/test_package.c b/recipes/libffi/all/test_v1_package/test_package.c deleted file mode 100644 index ec8d8480055a3..0000000000000 --- a/recipes/libffi/all/test_v1_package/test_package.c +++ /dev/null @@ -1,99 +0,0 @@ -#if defined(_MSC_VER) -#pragma runtime_checks("s", off) -#endif - -#include - -#include -#include -#include - -unsigned print_uint(unsigned arg) { - printf("print_int(%u)\n", arg); - return 3 * arg; -} - -typedef struct { - FILE *stream; -} puts_binding_userdata; - -void puts_binding(ffi_cif *cif, void *ret, void** args, void *userdata) -{ - fputs(*(char **)args[0], ((puts_binding_userdata *)userdata)->stream); - *((unsigned*)ret) = 1337; -} - -int main() -{ - { - ffi_type *argtypes[1] = {&ffi_type_uint32}; - ffi_cif cif; - ffi_status status = FFI_BAD_ABI; - status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes); - if (status != FFI_OK) - { - puts("1 ffi_prep_cif FAILED.\n\n"); - return EXIT_FAILURE; - } - #ifndef DISABLE_FFI_CALL - // this fails on msvc debug runtime because of https://github.com/libffi/libffi/issues/456 - unsigned rvalue = 0; - unsigned arg1 = 13; - const unsigned expected_ret = 3 * arg1; - void *args[] = {(void*)(&arg1)}; - ffi_call(&cif, FFI_FN(&print_uint), (void *) &rvalue, args); - printf("ffi_call returns %d (should be %d)\n", rvalue, expected_ret); - if (rvalue != expected_ret) { - printf("ffi_call FAILED. Expected %d, but got %d.\n", expected_ret, rvalue); - return EXIT_FAILURE; - } - #endif - return EXIT_SUCCESS; - } - { - #ifdef FFI_CLOSURES - ffi_type *argtypes[1] = {&ffi_type_uint}; - ffi_cif cif; - ffi_status status = FFI_BAD_ABI; - status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint32, argtypes); - if (status != FFI_OK) - { - puts("2 ffi_prep_cif FAILED.\n\n"); - return EXIT_FAILURE; - } - unsigned (*bound_puts)(const char *) = NULL; - ffi_closure *closure = NULL; - closure = (ffi_closure *) ffi_closure_alloc(sizeof(ffi_closure), (void **)&bound_puts); - if (closure == NULL) { - puts("ffi_closure_alloc FAILED\n"); - return EXIT_FAILURE; - } - - puts_binding_userdata userdata; - userdata.stream = stdout; - status = ffi_prep_closure_loc(closure, &cif, puts_binding, - &userdata, (void *) bound_puts); - if (status != FFI_OK) { - puts("ffi_prep_closure_loc FAILED\n"); - return EXIT_FAILURE; - } - puts("Start calling bound_put():"); - bound_puts("Hello"); - bound_puts(" "); - bound_puts("World"); - unsigned rc = bound_puts("\n"); - printf("bounds_puts returned %d.\n", rc); - if (rc != 1337) { - puts("bounds_put returned wrong number."); - return EXIT_FAILURE; - } - - ffi_closure_free(closure); - #endif - } - return EXIT_SUCCESS; -} - -#if defined(_MSC_VER) -#pragma runtime_checks("s", restore) -#endif From 1658a0c1c5dbde68ab641203c5fb14f16fa14d43 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Sat, 8 Oct 2022 09:32:56 -0500 Subject: [PATCH 13/47] Evaluate ar-lib path --- recipes/libffi/all/conanfile.py | 53 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index c55cf244a817b..09fb4966b3439 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,11 +1,12 @@ from conan import ConanFile -from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.apple import fix_apple_shared_install_name from conan.tools.env import VirtualBuildEnv from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path from conan.tools.scm import Version +import os required_conan_version = ">=1.52.0" @@ -32,10 +33,6 @@ def _settings_build(self): # TODO: Remove for Conan v2 return getattr(self, "settings_build", self.settings) - @property - def win_bash(self): - return self._settings_build.os == "Windows" - def export_sources(self): export_conandata_patches(self) @@ -62,8 +59,10 @@ def layout(self): basic_layout(self, src_folder="libffi") def build_requirements(self): - if self._settings_build.os == "Windows" and not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): - self.tool_requires("msys2/cci.latest") + if self._settings_build.os == "Windows": + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + self.tool_requires("msys2/cci.latest") + self.win_bash = True self.tool_requires("automake/1.16.5") self.tool_requires("libtool/2.4.7") @@ -76,7 +75,6 @@ def generate(self): tc = AutotoolsToolchain(self) tc.configure_args.extend([ f"--enable-debug={yes_no(self.settings.build_type == 'Debug')}", - "--datarootdir=${prefix}/res", "--enable-builddir=no", "--enable-docs=no", ]) @@ -96,12 +94,10 @@ def generate(self): ]) if self._settings_build.compiler == "apple-clang": - tc.configure_args.extend([ - "--disable-multi-os-directory", - ]) + tc.configure_args.append("--disable-multi-os-directory") if is_msvc(self): - msvcc = unix_path(self, str(self.source_path.joinpath("msvcc.sh"))) + msvcc = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) msvcc_args = [] if self.settings.arch == "x86_64": msvcc_args.append("-m64") @@ -127,16 +123,20 @@ def generate(self): env = tc.environment() if is_msvc(self): - env.define("LD", "link") env.define_path("CXX", msvcc) env.define_path("CC", msvcc) env.define("CXXCPP", "cl -nologo -EP") env.define("CPP", "cl -nologo -EP") - env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))} lib") # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged - #env.define("AR", f"{unix_path(self, self.deps_user_info['automake'].ar_lib)} lib") # FIXME: deps_user_info only seems to work with run scoped dependencies + + # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged + # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") + [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) + automake_version = f"{version_major}.{version_minor}" + ar_lib = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib")) + env.define("AR", f"{ar_lib} lib") env.define("LD", "link") - env.define("LIBTOOL", unix_path(self, str(self.source_path.joinpath("ltmain.sh")))) - env.define("INSTALL", unix_path(self, str(self.source_path.joinpath("install-sh")))) + env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) + env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") env.define("RANLIB", ":") @@ -153,7 +153,7 @@ def _patch_source(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 = self.source_path.joinpath("src", "arm", "sysv.S") + 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") @@ -163,7 +163,6 @@ def _patch_source(self): def build(self): self._patch_source() - autotools = Autotools(self) autotools.configure() autotools.make() @@ -171,16 +170,12 @@ def build(self): def package(self): autotools = Autotools(self) autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem - - if is_apple_os(self): - fix_apple_shared_install_name(self) - - copy(self, pattern="*.dll", dst=self.package_path.joinpath("bin"), src=self.package_path.joinpath("lib")) - copy(self, pattern="LICENSE", dst=self.package_path.joinpath("licenses"), src=self.source_folder) - - rm(self, "*.la", self.package_path.joinpath("lib"), recursive=True) - rmdir(self, self.package_path.joinpath("lib", "pkgconfig")) - rmdir(self, self.package_path.joinpath("share")) + fix_apple_shared_install_name(self) + copy(self, "*.dll", os.path.join(self.package_folder, "lib"), os.path.join(self.package_folder, "bin")) + copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) + rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rmdir(self, os.path.join(self.package_folder, "share")) def package_info(self): self.cpp_info.libs = ["{}ffi".format("lib" if is_msvc(self) else "")] From ba3cdaaa74f16d708936d02537e605cf7a229d1a Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 12 Oct 2022 08:09:00 -0500 Subject: [PATCH 14/47] Update recipes/libffi/all/conanfile.py Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com> --- recipes/libffi/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 09fb4966b3439..91f2148c9b922 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -111,7 +111,7 @@ def generate(self): if "MT" in msvc_runtime_flag(self): tc.extra_defines.append("USE_STATIC_RTL") if "d" in msvc_runtime_flag(self): - tc.extra_defines.append("d") + tc.extra_defines.append("USE_DEBUG_RTL") if self.options.shared: tc.extra_defines.append("FFI_BUILDING_DLL") From f2aaf08f9007b5b805774532883afc42a1b2300b Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 12 Oct 2022 08:12:59 -0500 Subject: [PATCH 15/47] Move DLL's to the bin directory --- recipes/libffi/all/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 91f2148c9b922..cbbc346ac6a02 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -6,7 +6,9 @@ from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path from conan.tools.scm import Version +import glob import os +import shutil required_conan_version = ">=1.52.0" @@ -171,7 +173,8 @@ def package(self): autotools = Autotools(self) autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem fix_apple_shared_install_name(self) - copy(self, "*.dll", os.path.join(self.package_folder, "lib"), os.path.join(self.package_folder, "bin")) + for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): + shutil.move(dll, os.path.join(self.package_folder, "bin")) copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) From 4d75e3d59ef0850b8ca74a718206dbec1f6c08a8 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 13 Oct 2022 07:53:57 -0500 Subject: [PATCH 16/47] Rename source folder to src --- recipes/libffi/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index cbbc346ac6a02..863e0bea2dc16 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -58,7 +58,7 @@ def configure(self): pass def layout(self): - basic_layout(self, src_folder="libffi") + basic_layout(self, src_folder="src") def build_requirements(self): if self._settings_build.os == "Windows": From 7cf5dfe6a520ac08752c2b73b121060db3ccb3f7 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Tue, 18 Oct 2022 14:08:04 -0500 Subject: [PATCH 17/47] Small fixes --- recipes/libffi/all/conanfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 863e0bea2dc16..6ae641a7a76e4 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -46,15 +46,15 @@ def configure(self): if self.options.shared: try: del self.options.fPIC - except ValueError: + except Exception: pass try: del self.settings.compiler.libcxx - except ValueError: + except Exception: pass try: del self.settings.compiler.cppstd - except ValueError: + except Exception: pass def layout(self): @@ -62,9 +62,9 @@ def layout(self): def build_requirements(self): if self._settings_build.os == "Windows": + self.win_bash = True if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): self.tool_requires("msys2/cci.latest") - self.win_bash = True self.tool_requires("automake/1.16.5") self.tool_requires("libtool/2.4.7") From 5a3ba1996b22a27f6dce3961827c9ccfe3fae849 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Tue, 18 Oct 2022 16:31:59 -0500 Subject: [PATCH 18/47] Fix renaming DLL's --- recipes/libffi/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 6ae641a7a76e4..dacf985756f8d 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -174,7 +174,7 @@ def package(self): autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem fix_apple_shared_install_name(self) for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): - shutil.move(dll, os.path.join(self.package_folder, "bin")) + shutil.move(dll, os.path.join(self.package_folder, "bin", os.path.basename(dll))) copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) From 9e9d327053d6b69f53421609d8bb579c7677a87c Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Tue, 18 Oct 2022 19:17:13 -0500 Subject: [PATCH 19/47] Make bin directory --- recipes/libffi/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index dacf985756f8d..97df216b8dc2a 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name from conan.tools.env import VirtualBuildEnv -from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file, rm, rmdir +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path @@ -173,8 +173,9 @@ def package(self): autotools = Autotools(self) autotools.install(args=[f"DESTDIR={unix_path(self, self.package_folder)}"]) # Need to specify the `DESTDIR` as a Unix path, aware of the subsystem fix_apple_shared_install_name(self) + mkdir(self, os.path.join(self.package_folder, "bin")) for dll in glob.glob(os.path.join(self.package_folder, "lib", "*.dll")): - shutil.move(dll, os.path.join(self.package_folder, "bin", os.path.basename(dll))) + shutil.move(dll, os.path.join(self.package_folder, "bin")) copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) rm(self, "*.la", os.path.join(self.package_folder, "lib"), recursive=True) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) From adf40f0aef65b7108d1f92a63c2d24a6eab1519a Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Tue, 18 Oct 2022 21:16:23 -0500 Subject: [PATCH 20/47] Be sure to set DISABLE_FFI_CALL properly --- recipes/libffi/all/test_package/conanfile.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/test_package/conanfile.py b/recipes/libffi/all/test_package/conanfile.py index a9fb96656f203..2d636399fa711 100644 --- a/recipes/libffi/all/test_package/conanfile.py +++ b/recipes/libffi/all/test_package/conanfile.py @@ -1,12 +1,13 @@ from conan import ConanFile from conan.tools.build import can_run -from conan.tools.cmake import cmake_layout, CMake +from conan.tools.cmake import cmake_layout, CMake, CMakeDeps, CMakeToolchain +from conan.tools.env import VirtualRunEnv +from conan.tools.microsoft import msvc_runtime_flag import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" test_type = "explicit" def requirements(self): @@ -15,6 +16,16 @@ def requirements(self): def layout(self): cmake_layout(self) + def generate(self): + cmake_deps = CMakeDeps(self) + cmake_deps.generate() + tc = CMakeToolchain(self) + if "d" in msvc_runtime_flag(self): + tc.preprocessor_definitions["DISABLE_FFI_CALL"] = 1 + tc.generate() + virtual_run_env = VirtualRunEnv(self) + virtual_run_env.generate() + def build(self): cmake = CMake(self) cmake.configure() From 1c0ffea89762cbce568ef5b93783eb884c51d90f Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Tue, 18 Oct 2022 22:14:10 -0500 Subject: [PATCH 21/47] Remove stuff AutotoolsToolchain should set --- recipes/libffi/all/conanfile.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 97df216b8dc2a..f810010742163 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -81,35 +81,11 @@ def generate(self): "--enable-docs=no", ]) - if is_msvc(self): - build = "{}-{}-{}".format( - "x86_64" if self._settings_build.arch == "x86_64" else "i686", - "pc" if self._settings_build.arch == "x86" else "win64", - "mingw64") - host = "{}-{}-{}".format( - "x86_64" if self.settings.arch == "x86_64" else "i686", - "pc" if self.settings.arch == "x86" else "win64", - "mingw64") - tc.configure_args.extend([ - f"--build={build}", - f"--host={host}", - ]) - if self._settings_build.compiler == "apple-clang": tc.configure_args.append("--disable-multi-os-directory") if is_msvc(self): msvcc = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) - msvcc_args = [] - if self.settings.arch == "x86_64": - msvcc_args.append("-m64") - elif self.settings.arch == "x86": - msvcc_args.append("-m32") - - if msvcc_args: - msvcc_args = " ".join(msvcc_args) - msvcc = f"{msvcc} {msvcc_args}" - if "MT" in msvc_runtime_flag(self): tc.extra_defines.append("USE_STATIC_RTL") if "d" in msvc_runtime_flag(self): From aa9ccad8d1de0bd54ee537a5679a1fff85488b38 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 19 Oct 2022 13:08:30 -0500 Subject: [PATCH 22/47] Clean up compiler wrapper --- recipes/libffi/all/conanfile.py | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index f810010742163..0062560ba809a 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,6 +1,6 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name -from conan.tools.env import VirtualBuildEnv +from conan.tools.env import Environment, VirtualBuildEnv from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout @@ -98,32 +98,36 @@ def generate(self): if self.settings.build_type == "Debug": tc.extra_defines.append("FFI_DEBUG") + + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") - env = tc.environment() if is_msvc(self): - env.define_path("CXX", msvcc) - env.define_path("CC", msvcc) - env.define("CXXCPP", "cl -nologo -EP") - env.define("CPP", "cl -nologo -EP") - + env = Environment() + compile_wrapper = unix_path(self, os.path.join(self.source_folder, "build-aux", "compile")) # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) automake_version = f"{version_major}.{version_minor}" - ar_lib = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib")) - env.define("AR", f"{ar_lib} lib") - env.define("LD", "link") - env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) - env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) + ar_wrapper = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib")) + env.define("CC", f"{compile_wrapper} cl -nologo") + env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("LD", "link -nologo") + env.define("AR", f"{ar_wrapper} \"lib -nologo\"") env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") env.define("RANLIB", ":") env.define("STRIP", ":") + env.vars(self).save_script("conanbuild_libffi_msvc") - tc.generate(env) + # env.define("CXXCPP", "cl -nologo -EP") + # env.define("CPP", "cl -nologo -EP") + # env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) + # env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) - ms = VirtualBuildEnv(self) - ms.generate(scope="build") + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() def _patch_source(self): apply_conandata_patches(self) From f2f714bc1db2a6bfb6c9c247d89ad5b9921bfc98 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 19 Oct 2022 13:48:52 -0500 Subject: [PATCH 23/47] Move VirtualBuildEnv before MSVC settings --- recipes/libffi/all/conanfile.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 0062560ba809a..fddff08068230 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -73,6 +73,9 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): + virtual_build_env = VirtualBuildEnv(self) + virtual_build_env.generate() + yes_no = lambda v: "yes" if v else "no" tc = AutotoolsToolchain(self) tc.configure_args.extend([ @@ -84,13 +87,6 @@ def generate(self): if self._settings_build.compiler == "apple-clang": tc.configure_args.append("--disable-multi-os-directory") - if is_msvc(self): - msvcc = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) - if "MT" in msvc_runtime_flag(self): - tc.extra_defines.append("USE_STATIC_RTL") - if "d" in msvc_runtime_flag(self): - tc.extra_defines.append("USE_DEBUG_RTL") - if self.options.shared: tc.extra_defines.append("FFI_BUILDING_DLL") else: @@ -98,12 +94,17 @@ def generate(self): if self.settings.build_type == "Debug": tc.extra_defines.append("FFI_DEBUG") - - if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ - (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): - tc.extra_cflags.append("-FS") if is_msvc(self): + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ + (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): + tc.extra_cflags.append("-FS") + + if "MT" in msvc_runtime_flag(self): + tc.extra_defines.append("USE_STATIC_RTL") + if "d" in msvc_runtime_flag(self): + tc.extra_defines.append("USE_DEBUG_RTL") + env = Environment() compile_wrapper = unix_path(self, os.path.join(self.source_folder, "build-aux", "compile")) # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged @@ -126,9 +127,6 @@ def generate(self): # env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) # env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) - virtual_build_env = VirtualBuildEnv(self) - virtual_build_env.generate() - def _patch_source(self): apply_conandata_patches(self) From af1d8f72b7bd24abce26882344c5c91b32ba6f35 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 19 Oct 2022 14:10:16 -0500 Subject: [PATCH 24/47] Add missing generate method for toolchain --- recipes/libffi/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index fddff08068230..72a940699f7e4 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -126,6 +126,7 @@ def generate(self): # env.define("CPP", "cl -nologo -EP") # env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) # env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) + tc.generate() def _patch_source(self): apply_conandata_patches(self) From 32287b2e243e0b93c7fb3d9b3dacd6bf955366ba Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Wed, 19 Oct 2022 15:43:14 -0500 Subject: [PATCH 25/47] Use provided compile wrapper and add missing defines --- recipes/libffi/all/conanfile.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 72a940699f7e4..a6e5ebbe25cd0 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -106,7 +106,7 @@ def generate(self): tc.extra_defines.append("USE_DEBUG_RTL") env = Environment() - compile_wrapper = unix_path(self, os.path.join(self.source_folder, "build-aux", "compile")) + compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) @@ -120,12 +120,11 @@ def generate(self): env.define("OBJDUMP", ":") env.define("RANLIB", ":") env.define("STRIP", ":") + env.define("CXXCPP", "cl -nologo -EP") + env.define("CPP", "cl -nologo -EP") + env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) + env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) env.vars(self).save_script("conanbuild_libffi_msvc") - - # env.define("CXXCPP", "cl -nologo -EP") - # env.define("CPP", "cl -nologo -EP") - # env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) - # env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) tc.generate() def _patch_source(self): From d2fbc943b153efd0adb6d31cfccecfe135e85188 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 09:06:08 -0500 Subject: [PATCH 26/47] Set build and host --- recipes/libffi/all/conanfile.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index a6e5ebbe25cd0..7859e8e05618d 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -96,6 +96,19 @@ def generate(self): tc.extra_defines.append("FFI_DEBUG") if is_msvc(self): + build = "{}-{}-{}".format( + "x86_64" if self._settings_build.arch == "x86_64" else "i686", + "pc" if self._settings_build.arch == "x86" else "win64", + "mingw64") + host = "{}-{}-{}".format( + "x86_64" if self.settings.arch == "x86_64" else "i686", + "pc" if self.settings.arch == "x86" else "win64", + "mingw64") + tc.configure_args.extend([ + f"--build={build}", + f"--host={host}", + ]) + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") From d9af364393aa20d01faf2b94289931c46e382971 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 09:23:28 -0500 Subject: [PATCH 27/47] Add architecture flags --- recipes/libffi/all/conanfile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 7859e8e05618d..8e0df997023bd 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -109,6 +109,11 @@ def generate(self): f"--host={host}", ]) + if self.settings.arch == "x86_64": + tc.extra_cflags.append("-m64") + elif self.settings.arch == "x86": + tc.extra_cflags.append("-m32") + if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") From 6296b004a23869cff61f1504d5232528fd1e217b Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 09:30:57 -0500 Subject: [PATCH 28/47] Pass architecture flag to compiler wrapper --- recipes/libffi/all/conanfile.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 8e0df997023bd..18f3bf1b8ea19 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -109,11 +109,6 @@ def generate(self): f"--host={host}", ]) - if self.settings.arch == "x86_64": - tc.extra_cflags.append("-m64") - elif self.settings.arch == "x86": - tc.extra_cflags.append("-m32") - if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) >= "12") or \ (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") @@ -123,8 +118,16 @@ def generate(self): if "d" in msvc_runtime_flag(self): tc.extra_defines.append("USE_DEBUG_RTL") + architecture_flag = "" + if self.settings.arch == "x86_64": + architecture_flag = "-m64" + elif self.settings.arch == "x86": + architecture_flag = "-m32" + env = Environment() compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) + if architecture_flag: + compiler_wrapper = f"{compile_wrapper} {architecture_flag}" # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) From cc2cd14274696b38db906e0710f0a74c01635ee3 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 09:45:27 -0500 Subject: [PATCH 29/47] Fix for Clang on Windows --- recipes/libffi/all/conanfile.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 18f3bf1b8ea19..bdfcae11813fc 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -95,7 +95,7 @@ def generate(self): if self.settings.build_type == "Debug": tc.extra_defines.append("FFI_DEBUG") - if is_msvc(self): + if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"): build = "{}-{}-{}".format( "x86_64" if self._settings_build.arch == "x86_64" else "i686", "pc" if self._settings_build.arch == "x86" else "win64", @@ -119,10 +119,13 @@ def generate(self): tc.extra_defines.append("USE_DEBUG_RTL") architecture_flag = "" - if self.settings.arch == "x86_64": - architecture_flag = "-m64" - elif self.settings.arch == "x86": - architecture_flag = "-m32" + if is_msvc(self): + if self.settings.arch == "x86_64": + architecture_flag = "-m64" + elif self.settings.arch == "x86": + architecture_flag = "-m32" + elif self.settings.compiler == "clang": + architecture_flag = "-clang-cl" env = Environment() compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) From 79d2f4eacebb792b7cc731b379cbb1ed02ff34d0 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:11:42 -0500 Subject: [PATCH 30/47] Use gnu-config --- recipes/libffi/all/conanfile.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index bdfcae11813fc..a32db0a239ace 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -35,6 +35,10 @@ def _settings_build(self): # TODO: Remove for Conan v2 return getattr(self, "settings_build", self.settings) + @property + def _user_info_build(self): + return getattr(self, "user_info_build", self.deps_user_info) + def export_sources(self): export_conandata_patches(self) @@ -67,6 +71,7 @@ def build_requirements(self): self.tool_requires("msys2/cci.latest") self.tool_requires("automake/1.16.5") self.tool_requires("libtool/2.4.7") + self.tool_requires("gnu-config/cci.20210814") def source(self): get(self, **self.conan_data["sources"][self.version], @@ -154,6 +159,11 @@ def generate(self): def _patch_source(self): apply_conandata_patches(self) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, + os.path.join(self._source_subfolder, "config.sub")) + shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, + os.path.join(self._source_subfolder, "config.guess")) + 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 From f9b541c4c2e855dcd70c015714c38dfab50523f2 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:12:36 -0500 Subject: [PATCH 31/47] Fix copy-paste --- recipes/libffi/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index a32db0a239ace..faa17fd416489 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -160,9 +160,9 @@ def _patch_source(self): apply_conandata_patches(self) shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, - os.path.join(self._source_subfolder, "config.sub")) + os.path.join(self.source_folder, "config.sub")) shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, - os.path.join(self._source_subfolder, "config.guess")) + os.path.join(self.source_folder, "config.guess")) if Version(self.version) < "3.3": if self.settings.compiler == "clang" and Version(str(self.settings.compiler.version)) >= 7.0: From 0ef94c6e07af1458ea561716d91495a9c1ea1050 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:16:22 -0500 Subject: [PATCH 32/47] Use cygwin triplet --- recipes/libffi/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index faa17fd416489..e92e7f483e048 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -104,11 +104,11 @@ def generate(self): build = "{}-{}-{}".format( "x86_64" if self._settings_build.arch == "x86_64" else "i686", "pc" if self._settings_build.arch == "x86" else "win64", - "mingw64") + "cygwin") host = "{}-{}-{}".format( "x86_64" if self.settings.arch == "x86_64" else "i686", "pc" if self.settings.arch == "x86" else "win64", - "mingw64") + "cygwin") tc.configure_args.extend([ f"--build={build}", f"--host={host}", From 1ce5ba96ba90cea90b2043296ade3efa6d8e64b8 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:18:51 -0500 Subject: [PATCH 33/47] Use the VCVars generator --- recipes/libffi/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index e92e7f483e048..79657c0879dba 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars from conan.tools.scm import Version import glob import os @@ -78,6 +78,8 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): + ms = VCVars(self) + ms.generate() virtual_build_env = VirtualBuildEnv(self) virtual_build_env.generate() From a2a7b9ecbd293eb43034e908ecf1cbfa056c9705 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:20:40 -0500 Subject: [PATCH 34/47] Revert "Use cygwin triplet" This reverts commit 0ef94c6e07af1458ea561716d91495a9c1ea1050. --- recipes/libffi/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 79657c0879dba..4cdc94a50b942 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -106,11 +106,11 @@ def generate(self): build = "{}-{}-{}".format( "x86_64" if self._settings_build.arch == "x86_64" else "i686", "pc" if self._settings_build.arch == "x86" else "win64", - "cygwin") + "mingw64") host = "{}-{}-{}".format( "x86_64" if self.settings.arch == "x86_64" else "i686", "pc" if self.settings.arch == "x86" else "win64", - "cygwin") + "mingw64") tc.configure_args.extend([ f"--build={build}", f"--host={host}", From cfe17555befe0b1bb959b030d50e4f19f91e21ae Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:22:01 -0500 Subject: [PATCH 35/47] Revert "Use gnu-config" This reverts commit 79d2f4eacebb792b7cc731b379cbb1ed02ff34d0. --- recipes/libffi/all/conanfile.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 4cdc94a50b942..3fedb79294c5e 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -35,10 +35,6 @@ def _settings_build(self): # TODO: Remove for Conan v2 return getattr(self, "settings_build", self.settings) - @property - def _user_info_build(self): - return getattr(self, "user_info_build", self.deps_user_info) - def export_sources(self): export_conandata_patches(self) @@ -71,7 +67,6 @@ def build_requirements(self): self.tool_requires("msys2/cci.latest") self.tool_requires("automake/1.16.5") self.tool_requires("libtool/2.4.7") - self.tool_requires("gnu-config/cci.20210814") def source(self): get(self, **self.conan_data["sources"][self.version], @@ -161,11 +156,6 @@ def generate(self): def _patch_source(self): apply_conandata_patches(self) - shutil.copy(self._user_info_build["gnu-config"].CONFIG_SUB, - os.path.join(self.source_folder, "config.sub")) - shutil.copy(self._user_info_build["gnu-config"].CONFIG_GUESS, - os.path.join(self.source_folder, "config.guess")) - 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 From 617b205447ebe7ec66f809adb623edd4546e3f1f Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:29:31 -0500 Subject: [PATCH 36/47] Fix wrapper --- recipes/libffi/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 3fedb79294c5e..2fb534edecc9e 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -138,8 +138,8 @@ def generate(self): [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) automake_version = f"{version_major}.{version_minor}" ar_wrapper = unix_path(self, os.path.join(self.dependencies.direct_build['automake'].cpp_info.resdirs[0], f"automake-{automake_version}", "ar-lib")) - env.define("CC", f"{compile_wrapper} cl -nologo") - env.define("CXX", f"{compile_wrapper} cl -nologo") + env.define("CC", f"{compile_wrapper}") + env.define("CXX", f"{compile_wrapper}") env.define("LD", "link -nologo") env.define("AR", f"{ar_wrapper} \"lib -nologo\"") env.define("NM", "dumpbin -symbols") From c6e32ddbb0df2be7332f04df868108fecb45a4c2 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 10:55:53 -0500 Subject: [PATCH 37/47] Define the assembler in the wrapper script --- recipes/libffi/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 2fb534edecc9e..320db85b0172b 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -141,6 +141,10 @@ def generate(self): env.define("CC", f"{compile_wrapper}") env.define("CXX", f"{compile_wrapper}") env.define("LD", "link -nologo") + if self.settings.arch == "x86_64": + env.define("AS", "ml64 -nologo") + else: + env.define("AS", "ml -nologo") env.define("AR", f"{ar_wrapper} \"lib -nologo\"") env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") From 6b1439787abd1f370b861d91275b429c6a81ddcb Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 11:08:28 -0500 Subject: [PATCH 38/47] Remove VCVars --- recipes/libffi/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 320db85b0172b..e21b9a8e11cee 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -73,8 +73,6 @@ def source(self): destination=self.source_folder, strip_root=True) def generate(self): - ms = VCVars(self) - ms.generate() virtual_build_env = VirtualBuildEnv(self) virtual_build_env.generate() From 6b5b62c64a833c07f3e7ca796e3588d31b493733 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 11:17:33 -0500 Subject: [PATCH 39/47] Use the toolchain's environment --- recipes/libffi/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index e21b9a8e11cee..a484bc9c2a1d2 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, mkdir, replace_in_file, rm, rmdir from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path, VCVars +from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path from conan.tools.scm import Version import glob import os @@ -127,7 +127,7 @@ def generate(self): elif self.settings.compiler == "clang": architecture_flag = "-clang-cl" - env = Environment() + env = tc.environment() compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) if architecture_flag: compiler_wrapper = f"{compile_wrapper} {architecture_flag}" @@ -152,7 +152,7 @@ def generate(self): env.define("CPP", "cl -nologo -EP") env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) - env.vars(self).save_script("conanbuild_libffi_msvc") + # env.vars(self).save_script("conanbuild_libffi_msvc") tc.generate() def _patch_source(self): From b992e6fb5fc87fedf4874248788c831b8d5faa20 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 11:27:46 -0500 Subject: [PATCH 40/47] Fix Windows to use wrapper script --- recipes/libffi/all/conanfile.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index a484bc9c2a1d2..386373407ce68 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -95,6 +95,7 @@ def generate(self): if self.settings.build_type == "Debug": tc.extra_defines.append("FFI_DEBUG") + env = tc.environment() if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"): build = "{}-{}-{}".format( "x86_64" if self._settings_build.arch == "x86_64" else "i686", @@ -127,10 +128,9 @@ def generate(self): elif self.settings.compiler == "clang": architecture_flag = "-clang-cl" - env = tc.environment() compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) if architecture_flag: - compiler_wrapper = f"{compile_wrapper} {architecture_flag}" + compile_wrapper = f"{compile_wrapper} {architecture_flag}" # FIXME: Use the conf once https://github.com/conan-io/conan-center-index/pull/12898 is merged # env.define("AR", f"{unix_path(self, self.conf.get('tools.automake:ar-lib'))}") [version_major, version_minor, _] = self.dependencies.direct_build['automake'].ref.version.split(".", 2) @@ -139,10 +139,6 @@ def generate(self): env.define("CC", f"{compile_wrapper}") env.define("CXX", f"{compile_wrapper}") env.define("LD", "link -nologo") - if self.settings.arch == "x86_64": - env.define("AS", "ml64 -nologo") - else: - env.define("AS", "ml -nologo") env.define("AR", f"{ar_wrapper} \"lib -nologo\"") env.define("NM", "dumpbin -symbols") env.define("OBJDUMP", ":") @@ -152,8 +148,7 @@ def generate(self): env.define("CPP", "cl -nologo -EP") env.define("LIBTOOL", unix_path(self, os.path.join(self.source_folder, "ltmain.sh"))) env.define("INSTALL", unix_path(self, os.path.join(self.source_folder, "install-sh"))) - # env.vars(self).save_script("conanbuild_libffi_msvc") - tc.generate() + tc.generate(env=env) def _patch_source(self): apply_conandata_patches(self) From 5ef89bb0a81d5b1367ade7a5e53c3cec356744f2 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Thu, 20 Oct 2022 11:49:00 -0500 Subject: [PATCH 41/47] Align with updated autotools template --- recipes/libffi/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 386373407ce68..638c01f139d69 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -63,10 +63,10 @@ def layout(self): def build_requirements(self): if self._settings_build.os == "Windows": self.win_bash = True - if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=bool): + if not self.conf.get("tools.microsoft.bash:path", default=False, check_type=str): self.tool_requires("msys2/cci.latest") - self.tool_requires("automake/1.16.5") - self.tool_requires("libtool/2.4.7") + if is_msvc(self): + self.tool_requires("automake/1.16.5") def source(self): get(self, **self.conan_data["sources"][self.version], From 7c2e389ecdeadfe25830b7cc302a5a54a1d7cff9 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 21 Oct 2022 07:52:41 -0500 Subject: [PATCH 42/47] Always define FFI_BUILDING --- recipes/libffi/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 638c01f139d69..9bb62751182c8 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -87,10 +87,9 @@ 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") - else: - tc.extra_defines.append("FFI_BUILDING") if self.settings.build_type == "Debug": tc.extra_defines.append("FFI_DEBUG") From 4abd072409fb644480f74c1439fab6fa2011147b Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 21 Oct 2022 07:52:57 -0500 Subject: [PATCH 43/47] Don't define FFI_DEBUG --- recipes/libffi/all/conanfile.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 9bb62751182c8..5e508dad3e9ce 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -91,9 +91,6 @@ def generate(self): if self.options.shared: tc.extra_defines.append("FFI_BUILDING_DLL") - if self.settings.build_type == "Debug": - tc.extra_defines.append("FFI_DEBUG") - env = tc.environment() if self._settings_build.os == "Windows" and (is_msvc(self) or self.settings.compiler == "clang"): build = "{}-{}-{}".format( From f15d3e4e292e5b7edd5fd43ea0d1db7990b09783 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 21 Oct 2022 15:30:12 -0500 Subject: [PATCH 44/47] Try patching version 3.2.1 --- recipes/libffi/all/conandata.yml | 1 + .../0007-3.2.1-fix-msvc-version-check.patch | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index e39bdd333bf68..0f8d832d8c134 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -34,3 +34,4 @@ patches: - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" + - patch_file: "patches/0007-3.2.1-fix-msvc-version-check.patch" diff --git a/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch b/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch new file mode 100644 index 0000000000000..ee4bff6704fc9 --- /dev/null +++ b/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch @@ -0,0 +1,24 @@ +From e061243958d63080956887e121d275533570f7cc Mon Sep 17 00:00:00 2001 +From: Pan7 +Date: Mon, 14 Sep 2015 08:25:09 +0200 +Subject: [PATCH] Fix configuring msvc compiler + +--- + msvcc.sh | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/msvcc.sh b/msvcc.sh +index 65fbfef7e..1a6e73f1f 100755 +--- a/msvcc.sh ++++ b/msvcc.sh +@@ -55,6 +55,10 @@ while [ $# -gt 0 ] + do + case $1 + in ++ --version) ++ args="-help" ++ shift 1 ++ ;; + -fexceptions) + # Don't enable exceptions for now. + #args="$args -EHac" From 33dd7ee6b138efea2090c693617104eb27dd1b6a Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 21 Oct 2022 15:42:39 -0500 Subject: [PATCH 45/47] Revert "Try patching version 3.2.1" This reverts commit f15d3e4e292e5b7edd5fd43ea0d1db7990b09783. --- recipes/libffi/all/conandata.yml | 1 - .../0007-3.2.1-fix-msvc-version-check.patch | 24 ------------------- 2 files changed, 25 deletions(-) delete mode 100644 recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index 0f8d832d8c134..e39bdd333bf68 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -34,4 +34,3 @@ patches: - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" - - patch_file: "patches/0007-3.2.1-fix-msvc-version-check.patch" diff --git a/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch b/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch deleted file mode 100644 index ee4bff6704fc9..0000000000000 --- a/recipes/libffi/all/patches/0007-3.2.1-fix-msvc-version-check.patch +++ /dev/null @@ -1,24 +0,0 @@ -From e061243958d63080956887e121d275533570f7cc Mon Sep 17 00:00:00 2001 -From: Pan7 -Date: Mon, 14 Sep 2015 08:25:09 +0200 -Subject: [PATCH] Fix configuring msvc compiler - ---- - msvcc.sh | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/msvcc.sh b/msvcc.sh -index 65fbfef7e..1a6e73f1f 100755 ---- a/msvcc.sh -+++ b/msvcc.sh -@@ -55,6 +55,10 @@ while [ $# -gt 0 ] - do - case $1 - in -+ --version) -+ args="-help" -+ shift 1 -+ ;; - -fexceptions) - # Don't enable exceptions for now. - #args="$args -EHac" From 828566ab7d3a6992edd8b6ec4b49d3194fc8f4e1 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Fri, 21 Oct 2022 15:45:41 -0500 Subject: [PATCH 46/47] Drop version 3.2.1 This is no longer building and I don't know why. It's also from 2014, so hopefully it's okay to drop. --- recipes/libffi/all/conandata.yml | 10 -- .../0001-3.2.1-add-support-windows-dll.patch | 163 ------------------ .../patches/0002-3.2.1-fix-libtool-path.patch | 20 --- .../0003-3.2.1-fix-win64-assembly.patch | 92 ---------- .../0004-3.2.1-fix-complex-type-msvc.patch | 55 ------ ...raries-to-arch-dependent-directories.patch | 32 ---- ...0006-3.2.1-library-no-version-suffix.patch | 11 -- recipes/libffi/config.yml | 2 - 8 files changed, 385 deletions(-) delete mode 100644 recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch delete mode 100644 recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch delete mode 100644 recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch delete mode 100644 recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch delete mode 100644 recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch delete mode 100644 recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch diff --git a/recipes/libffi/all/conandata.yml b/recipes/libffi/all/conandata.yml index e39bdd333bf68..869663acc18e9 100644 --- a/recipes/libffi/all/conandata.yml +++ b/recipes/libffi/all/conandata.yml @@ -8,9 +8,6 @@ sources: "3.3": url: "https://github.com/libffi/libffi/releases/download/v3.3/libffi-3.3.tar.gz" sha256: "72fba7922703ddfa7a028d513ac15a85c8d54c8d67f55fa5a4802885dc652056" - "3.2.1": - url: "https://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz" - sha256: "d06ebb8e1d9a22d19e38d63fdb83954253f39bedc5d46232a05645685722ca37" patches: "3.4.3": - patch_file: "patches/0002-3.4.3-fix-libtool-path.patch" @@ -27,10 +24,3 @@ patches: - patch_file: "patches/0004-3.3-fix-complex-type-msvc.patch" - patch_file: "patches/0005-3.3-do-not-install-libraries-to-arch-dependent-directories.patch" - patch_file: "patches/0006-3.3-library-no-version-suffix.patch" - "3.2.1": - - patch_file: "patches/0001-3.2.1-add-support-windows-dll.patch" - - patch_file: "patches/0002-3.2.1-fix-libtool-path.patch" - - patch_file: "patches/0003-3.2.1-fix-win64-assembly.patch" - - patch_file: "patches/0004-3.2.1-fix-complex-type-msvc.patch" - - patch_file: "patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch" - - patch_file: "patches/0006-3.2.1-library-no-version-suffix.patch" diff --git a/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch b/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch deleted file mode 100644 index 91b34fdcb090a..0000000000000 --- a/recipes/libffi/all/patches/0001-3.2.1-add-support-windows-dll.patch +++ /dev/null @@ -1,163 +0,0 @@ ---- include/ffi.h.in -+++ include/ffi.h.in -@@ -66,6 +66,18 @@ - - #include - -+#if defined _MSC_VER -+# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */ -+# define FFI_EXTERN __declspec(dllexport) -+# elif !defined FFI_BUILDING /* Importing libffi.DLL */ -+# define FFI_EXTERN __declspec(dllimport) -+# else -+# define FFI_EXTERN extern -+# endif -+#else -+# define FFI_EXTERN extern -+#endif -+ - #ifndef LIBFFI_ASM - - #if defined(_MSC_VER) && !defined(__clang__) -@@ -166,20 +180,6 @@ - #error "long size not supported" - #endif - --/* Need minimal decorations for DLLs to works on Windows. */ --/* GCC has autoimport and autoexport. Rely on Libtool to */ --/* help MSVC export from a DLL, but always declare data */ --/* to be imported for MSVC clients. This costs an extra */ --/* indirection for MSVC clients using the static version */ --/* of the library, but don't worry about that. Besides, */ --/* as a workaround, they can define FFI_BUILDING if they */ --/* *know* they are going to link with the static library. */ --#if defined _MSC_VER && !defined FFI_BUILDING --#define FFI_EXTERN extern __declspec(dllimport) --#else --#define FFI_EXTERN extern --#endif -- - /* These are defined in types.c */ - FFI_EXTERN ffi_type ffi_type_void; - FFI_EXTERN ffi_type ffi_type_uint8; -@@ -237,7 +237,7 @@ - #endif - - /* Used internally, but overridden by some architectures */ --ffi_status ffi_prep_cif_core(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif_core(ffi_cif *cif, - ffi_abi abi, - unsigned int isvariadic, - unsigned int nfixedargs, -@@ -282,27 +282,27 @@ - #endif - - --void ffi_raw_call (ffi_cif *cif, -+FFI_EXTERN void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - --void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); --void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); --size_t ffi_raw_size (ffi_cif *cif); -+FFI_EXTERN void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); -+FFI_EXTERN void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); -+FFI_EXTERN size_t ffi_raw_size (ffi_cif *cif); - - /* This is analogous to the raw API, except it uses Java parameter */ - /* packing, even on 64-bit machines. I.e. on 64-bit machines */ - /* longs and doubles are followed by an empty 64-bit word. */ - --void ffi_java_raw_call (ffi_cif *cif, -+FFI_EXTERN void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue); - --void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); --void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); --size_t ffi_java_raw_size (ffi_cif *cif); -+FFI_EXTERN void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw); -+FFI_EXTERN void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args); -+FFI_EXTERN size_t ffi_java_raw_size (ffi_cif *cif); - - /* ---- Definitions for closures ----------------------------------------- */ - -@@ -330,16 +330,16 @@ - # endif - #endif - --void *ffi_closure_alloc (size_t size, void **code); --void ffi_closure_free (void *); -+FFI_EXTERN void *ffi_closure_alloc (size_t size, void **code); -+FFI_EXTERN void ffi_closure_free (void *); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), -@@ -400,26 +400,26 @@ - - } ffi_java_raw_closure; - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data); - --ffi_status -+FFI_EXTERN ffi_status - ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), -@@ -430,20 +430,20 @@ - - /* ---- Public interface definition -------------------------------------- */ - --ffi_status ffi_prep_cif(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - --ffi_status ffi_prep_cif_var(ffi_cif *cif, -+FFI_EXTERN ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - --void ffi_call(ffi_cif *cif, -+FFI_EXTERN void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); diff --git a/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch b/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch deleted file mode 100644 index a09551d110a1e..0000000000000 --- a/recipes/libffi/all/patches/0002-3.2.1-fix-libtool-path.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- configure -+++ configure -@@ -8796,7 +8796,7 @@ - LIBTOOL_DEPS="$ltmain" - - # Always use our own libtool. --LIBTOOL='$(SHELL) $(top_builddir)/libtool' -+LIBTOOL='$(SHELL) $(top_builddir)/libtool.sh' - - - -@@ -8889,7 +8889,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, diff --git a/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch b/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch deleted file mode 100644 index 622ab2065a477..0000000000000 --- a/recipes/libffi/all/patches/0003-3.2.1-fix-win64-assembly.patch +++ /dev/null @@ -1,92 +0,0 @@ ---- src/x86/win64.S -+++ src/x86/win64.S -@@ -170,7 +170,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - movzx rax, ax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint16$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16 -@@ -179,7 +179,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - movsx rax, ax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_uint32$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32 -@@ -188,7 +188,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - mov eax, eax - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint32$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32 -@@ -197,7 +197,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - cdqe - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_float$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT -@@ -205,7 +205,7 @@ - - mov rax, QWORD PTR RVALUE[rbp] - movss DWORD PTR [rax], xmm0 -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_double$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE -@@ -213,7 +213,7 @@ - - mov rax, QWORD PTR RVALUE[rbp] - movlpd QWORD PTR [rax], xmm0 -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_uint64$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT64 -@@ -221,7 +221,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_sint64$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64 -@@ -229,7 +229,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_pointer$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_POINTER -@@ -237,7 +237,7 @@ - - mov rcx, QWORD PTR RVALUE[rbp] - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_int$: - cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT -@@ -246,7 +246,7 @@ - mov rcx, QWORD PTR RVALUE[rbp] - cdqe - mov QWORD PTR [rcx], rax -- jmp SHORT ret_void$ -+ jmp ret_void$ - - ret_void$: - xor rax, rax diff --git a/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch b/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch deleted file mode 100644 index 2b35695041bac..0000000000000 --- a/recipes/libffi/all/patches/0004-3.2.1-fix-complex-type-msvc.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- src/types.c -+++ src/types.c -@@ -31,6 +31,8 @@ - #include - #include - -+#include -+ - /* Type definitions */ - - #define FFI_TYPEDEF(name, type, id, maybe_const)\ -@@ -44,16 +46,16 @@ - 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; \ - }; \ - 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 \ -@@ -97,10 +99,20 @@ - 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(float, FLOAT_COMPLEX, const); -+FFI_COMPLEX_TYPEDEF(double, DOUBLE_COMPLEX, const); - #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE --FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST); -+FFI_COMPLEX_TYPEDEF(longdouble, LDOUBLE_COMPLEX, FFI_LDBL_CONST); - #endif - #endif diff --git a/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch b/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch deleted file mode 100644 index 4abeffb876872..0000000000000 --- a/recipes/libffi/all/patches/0005-3.2.1-do-not-install-libraries-to-arch-dependent-directories.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -600,7 +600,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@ - ---- include/Makefile.in -+++ include/Makefile.in -@@ -307,15 +307,15 @@ - 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@ - AUTOMAKE_OPTIONS = foreign - DISTCLEANFILES = ffitarget.h - EXTRA_DIST = ffi.h.in ffi_common.h --includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include -+includesdir = @includedir@ - nodist_includes_HEADERS = ffi.h ffitarget.h - all: all-am - - .SUFFIXES: diff --git a/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch b/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch deleted file mode 100644 index 915977c19a4ff..0000000000000 --- a/recipes/libffi/all/patches/0006-3.2.1-library-no-version-suffix.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in -+++ Makefile.in -@@ -723,7 +723,7 @@ - nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES) - LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS)) - AM_CFLAGS = $(am__append_41) --libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) -+libffi_la_LDFLAGS = -no-undefined -avoid-version $(LTLDFLAGS) $(AM_LTLDFLAGS) - AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src - AM_CCASFLAGS = $(AM_CPPFLAGS) - all: fficonfig.h diff --git a/recipes/libffi/config.yml b/recipes/libffi/config.yml index c1c6e30f4ceee..7f562b85ed6ac 100644 --- a/recipes/libffi/config.yml +++ b/recipes/libffi/config.yml @@ -5,5 +5,3 @@ versions: folder: "all" "3.3": folder: "all" - "3.2.1": - folder: "all" From 9eb26830471cbb4ad81f59251a52194cf4ef2b40 Mon Sep 17 00:00:00 2001 From: Jordan Williams Date: Sun, 23 Oct 2022 21:52:53 -0500 Subject: [PATCH 47/47] Clean up --- recipes/libffi/all/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/libffi/all/conanfile.py b/recipes/libffi/all/conanfile.py index 5e508dad3e9ce..fca2894b5fa7b 100644 --- a/recipes/libffi/all/conanfile.py +++ b/recipes/libffi/all/conanfile.py @@ -1,10 +1,10 @@ from conan import ConanFile from conan.tools.apple import fix_apple_shared_install_name -from conan.tools.env import Environment, VirtualBuildEnv +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.gnu import Autotools, AutotoolsToolchain from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, msvc_runtime_flag, unix_path +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, msvc_runtime_flag, unix_path from conan.tools.scm import Version import glob import os @@ -13,7 +13,7 @@ required_conan_version = ">=1.52.0" -class PackageConan(ConanFile): +class LibffiConan(ConanFile): name = "libffi" description = "A portable, high level programming interface to various calling conventions" license = "MIT" @@ -110,7 +110,7 @@ def generate(self): (self.settings.compiler == "msvc" and Version(self.settings.compiler.version) >= "180"): tc.extra_cflags.append("-FS") - if "MT" in msvc_runtime_flag(self): + if is_msvc_static_runtime(self): tc.extra_defines.append("USE_STATIC_RTL") if "d" in msvc_runtime_flag(self): tc.extra_defines.append("USE_DEBUG_RTL") @@ -122,7 +122,7 @@ def generate(self): elif self.settings.arch == "x86": architecture_flag = "-m32" elif self.settings.compiler == "clang": - architecture_flag = "-clang-cl" + architecture_flag = "-clang-cl" compile_wrapper = unix_path(self, os.path.join(self.source_folder, "msvcc.sh")) if architecture_flag: