From e4644bd15436d406bba71928d086c809e5c9ca45 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Mon, 16 Dec 2024 23:19:34 +0700 Subject: [PATCH] [libxml2] Fix compilation on iOS (#42695) --- ports/libxml2/fix_ios_compilation.patch | 87 +++++++++++++++++++++++++ ports/libxml2/portfile.cmake | 1 + ports/libxml2/vcpkg.json | 1 + versions/baseline.json | 2 +- versions/l-/libxml2.json | 5 ++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 ports/libxml2/fix_ios_compilation.patch diff --git a/ports/libxml2/fix_ios_compilation.patch b/ports/libxml2/fix_ios_compilation.patch new file mode 100644 index 0000000000..16a2423f5f --- /dev/null +++ b/ports/libxml2/fix_ios_compilation.patch @@ -0,0 +1,87 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0a279c8..8e771ee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -136,7 +136,7 @@ if (NOT MSVC) + check_include_files(fcntl.h HAVE_FCNTL_H) + check_function_exists(fpclass HAVE_FPCLASS) + check_function_exists(ftime HAVE_FTIME) +- check_function_exists(getentropy HAVE_GETENTROPY) ++ check_symbol_exists(getentropy "sys/random.h" HAVE_GETENTROPY) + check_function_exists(gettimeofday HAVE_GETTIMEOFDAY) + check_library_exists(history append_history "" HAVE_LIBHISTORY) + check_library_exists(readline readline "" HAVE_LIBREADLINE) +@@ -149,7 +149,6 @@ if (NOT MSVC) + check_function_exists(stat HAVE_STAT) + check_include_files(stdint.h HAVE_STDINT_H) + check_include_files(sys/mman.h HAVE_SYS_MMAN_H) +- check_include_files(sys/random.h HAVE_SYS_RANDOM_H) + check_include_files(sys/select.h HAVE_SYS_SELECT_H) + check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) + check_include_files(sys/stat.h HAVE_SYS_STAT_H) +diff --git a/config.h.cmake.in b/config.h.cmake.in +index 2f4aeba..79f1cdb 100644 +--- a/config.h.cmake.in ++++ b/config.h.cmake.in +@@ -69,9 +69,6 @@ + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_SYS_MMAN_H 1 + +-/* Define to 1 if you have the header file. */ +-#cmakedefine HAVE_SYS_RANDOM_H 1 +- + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_SYS_SELECT_H 1 + +diff --git a/configure.ac b/configure.ac +index 48cd2f0..0f09c61 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -304,7 +304,6 @@ AC_CHECK_HEADERS([stdint.h]) + AC_CHECK_HEADERS([fcntl.h unistd.h sys/stat.h]) + AC_CHECK_HEADERS([sys/mman.h]) + AC_CHECK_HEADERS([sys/time.h sys/timeb.h]) +-AC_CHECK_HEADERS([sys/random.h]) + AC_CHECK_HEADERS([dl.h dlfcn.h]) + AC_CHECK_HEADERS([glob.h]) + AM_CONDITIONAL(WITH_GLOB, test "$ac_cv_header_glob_h" = "yes") +@@ -317,9 +316,7 @@ AH_VERBATIM([HAVE_MUNMAP_AFTER],[/* mmap() is no good without munmap() */ + # undef /**/ HAVE_MMAP + #endif]) + +-AC_CHECK_DECL([getentropy], +- [AC_DEFINE([HAVE_GETENTROPY], [1], [getentropy])], [], +- [#include ]) ++AC_CHECK_DECLS([getentropy], [], [], [#include ]) + + dnl + dnl Checks for inet libraries +diff --git a/dict.c b/dict.c +index 49e1c6b..46bb4d4 100644 +--- a/dict.c ++++ b/dict.c +@@ -928,13 +928,11 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) { + #define WIN32_LEAN_AND_MEAN + #include + #include +-#elif defined(HAVE_GETENTROPY) ++#elif HAVE_GETENTROPY + #ifdef HAVE_UNISTD_H + #include + #endif +- #ifdef HAVE_SYS_RANDOM_H +- #include +- #endif ++ #include + #else + #include + #endif +@@ -965,7 +963,7 @@ xmlInitRandom(void) { + "error code %lu\n", GetLastError()); + abort(); + } +-#elif defined(HAVE_GETENTROPY) ++#elif HAVE_GETENTROPY + while (1) { + if (getentropy(globalRngState, sizeof(globalRngState)) == 0) + break; diff --git a/ports/libxml2/portfile.cmake b/ports/libxml2/portfile.cmake index 0ee0da9b3e..e62bc9d2a4 100644 --- a/ports/libxml2/portfile.cmake +++ b/ports/libxml2/portfile.cmake @@ -19,6 +19,7 @@ vcpkg_from_github( PATCHES disable-docs.patch fix_cmakelist.patch + fix_ios_compilation.patch ${FIX_COMPATIBILITY_PATCH} ${ADD_MISSING_BCRYPT_PATCH} ) diff --git a/ports/libxml2/vcpkg.json b/ports/libxml2/vcpkg.json index 2e8ba05ad4..dc1d093835 100644 --- a/ports/libxml2/vcpkg.json +++ b/ports/libxml2/vcpkg.json @@ -1,6 +1,7 @@ { "name": "libxml2", "version": "2.13.5", + "port-version": 1, "description": "Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform).", "homepage": "https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home", "license": "MIT", diff --git a/versions/baseline.json b/versions/baseline.json index 46ad336858..5c675f343d 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5438,7 +5438,7 @@ }, "libxml2": { "baseline": "2.13.5", - "port-version": 0 + "port-version": 1 }, "libxmlmm": { "baseline": "0.6.0", diff --git a/versions/l-/libxml2.json b/versions/l-/libxml2.json index 00c9166a2d..96cfbf8d8c 100644 --- a/versions/l-/libxml2.json +++ b/versions/l-/libxml2.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "42ed1437607b934471807d0a2830d23d43f22bb1", + "version": "2.13.5", + "port-version": 1 + }, { "git-tree": "f61ea0a7f998b892dc7eb51f6366867bef1d5353", "version": "2.13.5",