[glib] arm/arm64 windows support (#6116)

* glib port update for arm/arm64 windows

* bump glib version to 2.52.3-14
This commit is contained in:
driver1998 2019-05-04 07:21:44 +08:00 committed by Griffin Downs
parent 5b2759be83
commit 5ea9105f15
5 changed files with 137 additions and 4 deletions

View File

@ -4,6 +4,9 @@ project(glib C)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
if(MSVC)
add_compile_options(/utf-8)
endif()
set(GLIB_DLL_SUFFIX 2)
set(GLIB_LIB_SUFFIX 2.0)
@ -131,7 +134,7 @@ target_compile_definitions(glib PRIVATE GLIB_COMPILATION G_LOG_DOMAIN="GLib" LIB
target_link_libraries(glib PRIVATE ${PCRE_LIBRARY} unofficial::iconv::libiconv unofficial::iconv::libcharset ${LIBINTL_LIBRARY})
if(WIN32)
target_compile_definitions(glib PRIVATE USE_SYSTEM_PCRE)
target_link_libraries(glib PRIVATE ws2_32 winmm)
target_link_libraries(glib PRIVATE ws2_32 winmm advapi32 ole32 shell32)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
@ -246,7 +249,7 @@ target_compile_definitions(gio PRIVATE GIO_COMPILATION G_LOG_DOMAIN="GLib-GIO")
target_link_libraries(gio PRIVATE glib gmodule gobject ZLIB::ZLIB ${LIBRESOLV_LIBRARY} ${LIBINTL_LIBRARY})
target_include_directories(gio PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gio> $<INSTALL_INTERFACE:include/gio>)
if(WIN32)
target_link_libraries(gio PRIVATE ws2_32 shlwapi dnsapi iphlpapi)
target_link_libraries(gio PRIVATE ws2_32 shlwapi dnsapi iphlpapi advapi32 shell32)
elseif(APPLE)
target_link_libraries(gio PRIVATE xdgmime kqueue)
else()
@ -262,7 +265,11 @@ endforeach()
macro(add_glib_tool TOOL_NAME)
add_executable(${TOOL_NAME} ${ARGN})
target_link_libraries(${TOOL_NAME} glib ${LIBINTL_LIBRARY})
if(WIN32)
target_link_libraries(${TOOL_NAME} glib ${LIBINTL_LIBRARY} shell32)
else()
target_link_libraries(${TOOL_NAME} glib ${LIBINTL_LIBRARY})
endif()
target_compile_definitions(${TOOL_NAME} PRIVATE GLIB_COMPILATION)
list(APPEND GLIB_TOOLS ${TOOL_NAME})
endmacro()

View File

@ -1,4 +1,4 @@
Source: glib
Version: 2.52.3-13-1
Version: 2.52.3-14-1
Description: Portable, general-purpose utility library.
Build-Depends: zlib, pcre, libffi, gettext, libiconv

View File

@ -0,0 +1,78 @@
diff --git a/config.h.win32 b/config.h.win32
index 999641d65..531843e0e 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -728,7 +728,7 @@
/* The size of `void *', as computed by sizeof. */
#ifdef _MSC_VER
-#if (defined(_M_X64) || defined(_M_AMD64))
+#if (defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64))
#define SIZEOF_VOID_P 8
#elif (defined(_M_IX86))
#define SIZEOF_VOID_P 4
diff --git a/config.h.win32.in b/config.h.win32.in
index eaf7e2818..049c5e9f4 100644
--- a/config.h.win32.in
+++ b/config.h.win32.in
@@ -728,7 +728,7 @@
/* The size of `void *', as computed by sizeof. */
#ifdef _MSC_VER
-#if (defined(_M_X64) || defined(_M_AMD64))
+#if (defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64))
#define SIZEOF_VOID_P 8
#elif (defined(_M_IX86))
#define SIZEOF_VOID_P 4
diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c
index 9b3619cb1..6400572a2 100644
--- a/gio/gdbusaddress.c
+++ b/gio/gdbusaddress.c
@@ -1469,7 +1469,7 @@ get_session_address_dbus_launch (GError **error)
wcscat (args, rundll_path);
wcscat (args, L"\" ");
wcscat (args, gio_path_short);
-#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64)
+#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64)
wcscat (args, L",g_win32_run_session_bus");
#elif defined (_MSC_VER)
wcscat (args, L",_g_win32_run_session_bus@16");
diff --git a/glib/gatomic.c b/glib/gatomic.c
index e3e49fab4..e257e4377 100644
--- a/glib/gatomic.c
+++ b/glib/gatomic.c
@@ -474,7 +474,7 @@ gsize
#elif defined (G_PLATFORM_WIN32)
#include <windows.h>
-#if !defined(_M_AMD64) && !defined (_M_IA64) && !defined(_M_X64) && !(defined _MSC_VER && _MSC_VER <= 1200)
+#if !defined(_M_ARM64) && !defined(_M_AMD64) && !defined (_M_IA64) && !defined(_M_X64) && !(defined _MSC_VER && _MSC_VER <= 1200)
#define InterlockedAnd _InterlockedAnd
#define InterlockedOr _InterlockedOr
#define InterlockedXor _InterlockedXor
diff --git a/glib/glibconfig.h.win32 b/glib/glibconfig.h.win32
index d9f893a15..b75a86f10 100644
--- a/glib/glibconfig.h.win32
+++ b/glib/glibconfig.h.win32
@@ -68,7 +68,7 @@ typedef unsigned __int64 guint64;
#define G_GINT64_FORMAT "I64i"
#define G_GUINT64_FORMAT "I64u"
-#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64)
+#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64)
#define GLIB_SIZEOF_VOID_P 8
#define GLIB_SIZEOF_LONG 4
diff --git a/glib/glibconfig.h.win32.in b/glib/glibconfig.h.win32.in
index 9a91c5e96..f0b88c976 100644
--- a/glib/glibconfig.h.win32.in
+++ b/glib/glibconfig.h.win32.in
@@ -68,7 +68,7 @@ typedef unsigned __int64 guint64;
#define G_GINT64_FORMAT "I64i"
#define G_GUINT64_FORMAT "I64u"
-#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64)
+#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_ARM64)
#define GLIB_SIZEOF_VOID_P 8
#define GLIB_SIZEOF_LONG 4

View File

@ -0,0 +1,46 @@
diff --git a/gio/tests/plugin_resources.c b/gio/tests/plugin_resources.c
index 4c1b0214b..bbfc7ae07 100644
--- a/gio/tests/plugin_resources.c
+++ b/gio/tests/plugin_resources.c
@@ -80,13 +80,13 @@ GResource *_g_plugin_get_resource (void)
*/
/* We need to account for differences between the mangling of symbols
- * for Win32 (x86) and x64 programs, as symbols on Win32 are prefixed
- * with an underscore but symbols on x64 are not.
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
*/
-#ifdef _WIN64
-#define G_MSVC_SYMBOL_PREFIX ""
-#else
+#ifdef _M_IX86
#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
#endif
#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)
diff --git a/glib/gconstructor.h b/glib/gconstructor.h
index dccb0314c..fa1139302 100644
--- a/glib/gconstructor.h
+++ b/glib/gconstructor.h
@@ -40,13 +40,13 @@
*/
/* We need to account for differences between the mangling of symbols
- * for Win32 (x86) and x64 programs, as symbols on Win32 are prefixed
- * with an underscore but symbols on x64 are not.
+ * for x86 and x64/ARM/ARM64 programs, as symbols on x86 are prefixed
+ * with an underscore but symbols on x64/ARM/ARM64 are not.
*/
-#ifdef _WIN64
-#define G_MSVC_SYMBOL_PREFIX ""
-#else
+#ifdef _M_IX86
#define G_MSVC_SYMBOL_PREFIX "_"
+#else
+#define G_MSVC_SYMBOL_PREFIX ""
#endif
#define G_DEFINE_CONSTRUCTOR(_func) G_MSVC_CTOR (_func, G_MSVC_SYMBOL_PREFIX)

View File

@ -22,6 +22,8 @@ vcpkg_extract_source_archive_ex(
REF ${GLIB_VERSION}
PATCHES
use-libiconv-on-windows.patch
arm64-defines.patch
fix-arm-builds.patch
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})