summarylogtreecommitdiffstats
path: root/0016-Workaround-linker-error-about-missing-symbol-__sync_.patch
blob: 9965e1b8a826703052236dfc0a853e5fdfde1cf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 7816d48f125a244ad9d0646a45df4689358127b1 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sat, 17 Feb 2024 23:11:18 +0100
Subject: [PATCH 16/18] Workaround linker error about missing symbol
 `__sync_bool_compare_and_swap_16`

This error only happens when compiling for the x86_64-w64-mingw32 target
with the `cpp_winrt` feature enabled. Adding the `-mcx16c` flag helps to
avoid it. This means the `CMPXCHG16B` instruction is required but this
code will only run on newer systems anyway (considering Qt requires Windows
10).

Change-Id: I1b96a6dc44c5f7d527dbed9db58b4f030f175721
---
 src/corelib/CMakeLists.txt                                   | 5 +++++
 .../networkinformation/networklistmanager/CMakeLists.txt     | 5 +++++
 src/plugins/platforms/direct2d/CMakeLists.txt                | 5 +++++
 src/plugins/platforms/windows/CMakeLists.txt                 | 5 +++++
 4 files changed, 20 insertions(+)

diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 80d939dbfff..245419bc45d 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -850,6 +850,11 @@ qt_internal_extend_target(Core CONDITION WASM
         text/qlocale_wasm.cpp
 )
 
+# workaround undefined reference to `__sync_bool_compare_and_swap_16'
+if (QT_FEATURE_cpp_winrt AND MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86.*)|(X86.*)|(amd64)|(AMD64)")
+    set_property(SOURCE text/qlocale_win.cpp APPEND PROPERTY COMPILE_FLAGS "-mcx16")
+endif ()
+
 qt_internal_extend_target(Core CONDITION WIN32
     LIBRARIES
         runtimeobject
diff --git a/src/plugins/networkinformation/networklistmanager/CMakeLists.txt b/src/plugins/networkinformation/networklistmanager/CMakeLists.txt
index acd3754f4e5..0557c60afd1 100644
--- a/src/plugins/networkinformation/networklistmanager/CMakeLists.txt
+++ b/src/plugins/networkinformation/networklistmanager/CMakeLists.txt
@@ -20,6 +20,11 @@ qt_internal_extend_target(QNLMNIPlugin CONDITION WIN32
         oleaut32
 )
 
+# workaround undefined reference to `__sync_bool_compare_and_swap_16'
+if (QT_FEATURE_cpp_winrt AND MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86.*)|(X86.*)|(amd64)|(AMD64)")
+    target_compile_options(QNLMNIPlugin PRIVATE -mcx16)
+endif ()
+
 # Don't repeat the target name in AUTOGEN_BUILD_DIR to work around issues with overlong paths.
 set_property(TARGET QNLMNIPlugin PROPERTY
     AUTOGEN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/autogen")
diff --git a/src/plugins/platforms/direct2d/CMakeLists.txt b/src/plugins/platforms/direct2d/CMakeLists.txt
index 062dc301433..8a189c52b44 100644
--- a/src/plugins/platforms/direct2d/CMakeLists.txt
+++ b/src/plugins/platforms/direct2d/CMakeLists.txt
@@ -81,6 +81,11 @@ qt_internal_add_plugin(QWindowsDirect2DIntegrationPlugin
         runtimeobject
 )
 
+# workaround undefined reference to `__sync_bool_compare_and_swap_16'
+if (QT_FEATURE_cpp_winrt AND MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86.*)|(X86.*)|(amd64)|(AMD64)")
+    target_compile_options(QWindowsDirect2DIntegrationPlugin PRIVATE -mcx16)
+endif ()
+
 # Resources:
 set_source_files_properties("../windows/openglblacklists/default.json"
     PROPERTIES QT_RESOURCE_ALIAS "default.json"
diff --git a/src/plugins/platforms/windows/CMakeLists.txt b/src/plugins/platforms/windows/CMakeLists.txt
index 8ad72dad080..9064100e912 100644
--- a/src/plugins/platforms/windows/CMakeLists.txt
+++ b/src/plugins/platforms/windows/CMakeLists.txt
@@ -69,6 +69,11 @@ qt_internal_add_plugin(QWindowsIntegrationPlugin
         runtimeobject
 )
 
+# workaround undefined reference to `__sync_bool_compare_and_swap_16'
+if (QT_FEATURE_cpp_winrt AND MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86.*)|(X86.*)|(amd64)|(AMD64)")
+    target_compile_options(QWindowsIntegrationPlugin PRIVATE -mcx16)
+endif ()
+
 # Resources:
 set_source_files_properties("openglblacklists/default.json"
     PROPERTIES QT_RESOURCE_ALIAS "default.json"
-- 
2.47.0