summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-03-24 16:03:35 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-04-01 18:14:59 +0200
commit659817e287c0948829b8d3c4239cc7fa6fcf70a2 (patch)
tree2ce7819d6f080dc8b113dbfd1a79ee9443538229 /src
parent6fd8748f882fad4968f7da1edc65165a78377447 (diff)
CMake: Fix building multi-arch universal macOS Qt
Use the same approach we use for iOS, which is to set multiple CMAKE_OSX_ARCHITECTURES values and let the clang front end deal with lipo-ing the final libraries. For now, Qt can be configured to build universal macOS libraries by passing 2 architectures to CMake, either via: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" or -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" Currently we recommend specifying the intel x86_64 arch as the first one, to get an intel slice configuration that is comparable to a non-universal intel build. Specifying the arm64 slice first could pessimize optimizations and reduce the feature set for the intel slice due to the limitation that we run configure tests only once. The first specified architecture is the one used to do all the configure tests. It 'mostly' defines the common feature set of both architecture slices, with the excepion of some special handling for sse2 and neon instructions. In the future we might want to run at least the Qt architecture config test for all specified architectures, so that we can extract all the supported sub-arches and instruction sets in a reliable way. For now, we use the same sse2 hack as for iOS simulator_and_device builds, otherwise QtGui fails to link due to missing qt_memfill32_sse2 and other symbols. The hack is somewhat augmented to ensure that reconfiguration still succeeds (same issue happened with iOS). Previously the sse2 feature condition was broken due to force setting the feature to be ON. Now the condition also checks for a special QT_FORCE_FEATURE_sse2 variable which we set internally. Note that we shouldn't build for arm64e, because the binaries get killed when running on AS with the following message: kernel: exec_mach_imgact: not running binary built against preview arm64e ABI. Aslo, by default, we disable the arm64 slice for qt sql plugins, mostly because the CI provisioned sql libraries that we depend on only contain x86_64 slices, and trying to build the sql plugins for both slices will fail with linker errors. This behavior can be disabled for all targets marked by qt_internal_force_macos_intel_arch, by setting the QT_FORCE_MACOS_ALL_ARCHES CMake option to ON. To disble it per-target one can set QT_FORCE_MACOS_ALL_ARCHES_${target} to ON. Task-number: QTBUG-85447 Change-Id: Iccb5dfcc1a21a8a8292bd3817df0ea46c3445f75 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qfloat16_f16c.c11
-rw-r--r--src/gui/CMakeLists.txt13
-rw-r--r--src/plugins/sqldrivers/db2/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/ibase/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/mysql/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/oci/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/odbc/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/psql/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/sqlite/CMakeLists.txt4
9 files changed, 27 insertions, 13 deletions
diff --git a/src/corelib/global/qfloat16_f16c.c b/src/corelib/global/qfloat16_f16c.c
index ba1e16f481..d60a021bdb 100644
--- a/src/corelib/global/qfloat16_f16c.c
+++ b/src/corelib/global/qfloat16_f16c.c
@@ -40,13 +40,8 @@
#include "private/qsimd_p.h"
// The x86 F16C instructions operate on AVX registers, so AVX support is
-// required. We don't need to check for __F16C__ because we this file wouldn't
-// have been compiled if the support was missing in the first place, and not
-// all compilers define it. Technically, we didn't need to check for __AVX__
-// either.
-#if !QT_COMPILER_SUPPORTS_HERE(AVX)
-# error "AVX support required"
-#endif
+// required.
+#if QT_COMPILER_SUPPORTS_HERE(AVX)
#ifdef __cplusplus
QT_BEGIN_NAMESPACE
@@ -89,3 +84,5 @@ void qFloatFromFloat16_fast(float *out, const quint16 *in, qsizetype len) Q_DECL
} // extern "C"
QT_END_NAMESPACE
#endif
+
+#endif // QT_COMPILER_SUPPORTS_HERE(AVX)
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 89cefdc818..31e727189b 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -615,6 +615,8 @@ if(NOT ANDROID)
qt_internal_add_simd_part(Gui SIMD arch_haswell
SOURCES
painting/qdrawhelper_avx2.cpp
+ EXCLUDE_OSX_ARCHITECTURES
+ arm64
)
endif()
@@ -767,12 +769,11 @@ qt_internal_extend_target(Gui CONDITION MINGW AND WIN32
uuid
)
-qt_internal_extend_target(Gui CONDITION UNIX AND NOT ANDROID AND NOT INTEGRITY AND NOT (TEST_architecture_arch STREQUAL "arm64") AND NOT UIKIT
- DEFINES
- ENABLE_PIXMAN_DRAWHELPERS
-)
-
-if(UNIX AND NOT ANDROID AND NOT INTEGRITY AND NOT (TEST_architecture_arch STREQUAL "arm64") AND NOT UIKIT)
+# Only enable the Pixman draw-helpers on platforms that support the GAS syntax of their asm files
+# Note: These helpers are only used for 16-bit surfaces, so excluding them does not generally
+# exclude neon-drawhelpers on these platforms.
+if(UNIX AND NOT ANDROID AND NOT INTEGRITY AND NOT (TEST_architecture_arch STREQUAL "arm64") AND NOT UIKIT AND NOT QT_IS_MACOS_UNIVERSAL)
+ qt_internal_extend_target(Gui DEFINES ENABLE_PIXMAN_DRAWHELPERS)
qt_internal_add_simd_part(Gui SIMD neon
SOURCES
../3rdparty/pixman/pixman-arm-neon-asm.S
diff --git a/src/plugins/sqldrivers/db2/CMakeLists.txt b/src/plugins/sqldrivers/db2/CMakeLists.txt
index 6d662434ae..de90d92581 100644
--- a/src/plugins/sqldrivers/db2/CMakeLists.txt
+++ b/src/plugins/sqldrivers/db2/CMakeLists.txt
@@ -30,3 +30,5 @@ qt_internal_extend_target(QDB2DriverPlugin CONDITION (TEST_architecture_arch STR
DEFINES
ODBC64
)
+
+qt_internal_force_macos_intel_arch(QDB2DriverPlugin)
diff --git a/src/plugins/sqldrivers/ibase/CMakeLists.txt b/src/plugins/sqldrivers/ibase/CMakeLists.txt
index 5f200597f5..4b914401ed 100644
--- a/src/plugins/sqldrivers/ibase/CMakeLists.txt
+++ b/src/plugins/sqldrivers/ibase/CMakeLists.txt
@@ -12,3 +12,5 @@ qt_internal_add_plugin(QIBaseDriverPlugin
Qt::Core
Qt::CorePrivate
Qt::SqlPrivate)
+
+qt_internal_force_macos_intel_arch(QIBaseDriverPlugin)
diff --git a/src/plugins/sqldrivers/mysql/CMakeLists.txt b/src/plugins/sqldrivers/mysql/CMakeLists.txt
index 8e8244acb3..0679bcb698 100644
--- a/src/plugins/sqldrivers/mysql/CMakeLists.txt
+++ b/src/plugins/sqldrivers/mysql/CMakeLists.txt
@@ -22,3 +22,5 @@ qt_internal_add_plugin(QMYSQLDriverPlugin
#### Keys ignored in scope 1:.:.:mysql.pro:<TRUE>:
# OTHER_FILES = "mysql.json"
+
+qt_internal_force_macos_intel_arch(QMYSQLDriverPlugin)
diff --git a/src/plugins/sqldrivers/oci/CMakeLists.txt b/src/plugins/sqldrivers/oci/CMakeLists.txt
index c6e38f4cdf..4830586064 100644
--- a/src/plugins/sqldrivers/oci/CMakeLists.txt
+++ b/src/plugins/sqldrivers/oci/CMakeLists.txt
@@ -30,3 +30,5 @@ qt_internal_extend_target(QOCIDriverPlugin CONDITION APPLE
LINK_OPTIONS
"-Wl,-flat_namespace,-U,_environ"
)
+
+qt_internal_force_macos_intel_arch(QOCIDriverPlugin)
diff --git a/src/plugins/sqldrivers/odbc/CMakeLists.txt b/src/plugins/sqldrivers/odbc/CMakeLists.txt
index 99a6b9104d..032d89a244 100644
--- a/src/plugins/sqldrivers/odbc/CMakeLists.txt
+++ b/src/plugins/sqldrivers/odbc/CMakeLists.txt
@@ -32,3 +32,5 @@ qt_internal_extend_target(QODBCDriverPlugin CONDITION UNIX
DEFINES
UNICODE
)
+
+qt_internal_force_macos_intel_arch(QODBCDriverPlugin)
diff --git a/src/plugins/sqldrivers/psql/CMakeLists.txt b/src/plugins/sqldrivers/psql/CMakeLists.txt
index b151932da7..648d29f582 100644
--- a/src/plugins/sqldrivers/psql/CMakeLists.txt
+++ b/src/plugins/sqldrivers/psql/CMakeLists.txt
@@ -35,3 +35,5 @@ if(MINGW)
DISABLE_PRECOMPILE_HEADERS ON
)
endif()
+
+qt_internal_force_macos_intel_arch(QPSQLDriverPlugin)
diff --git a/src/plugins/sqldrivers/sqlite/CMakeLists.txt b/src/plugins/sqldrivers/sqlite/CMakeLists.txt
index ad39f1547b..bbd03e451f 100644
--- a/src/plugins/sqldrivers/sqlite/CMakeLists.txt
+++ b/src/plugins/sqldrivers/sqlite/CMakeLists.txt
@@ -36,6 +36,10 @@ if (NOT QT_FEATURE_system_sqlite)
# On newer compilers compiling sqlite.c produces warnings
qt_disable_warnings(QSQLiteDriverPlugin)
endif()
+
+if(QT_FEATURE_system_sqlite)
+ qt_internal_force_macos_intel_arch(QSQLiteDriverPlugin)
+endif()
# special case end
qt_internal_extend_target(QSQLiteDriverPlugin CONDITION NOT QT_FEATURE_system_sqlite