diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-05-21 12:01:26 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-11-11 00:21:00 +0100 |
commit | e01f4642746cb5eb53ae4ce53e0c8e71ad654ff2 (patch) | |
tree | 37edf5dd71eade42f7ded2c2370f5dc338c8bbcf | |
parent | 8bb90ab760310c9bc82b6ecbe068532fcb4e7822 (diff) |
qmake: Pick default architecture on macOS based on uname
When dealing with a universal build of Qt, we would end up
using the QT_ARCH as the architecture for user projects,
but this architecture is always the primary one that Qt
was configured with.
Instead of relying on QT_ARCH, we start writing QT_ARCHS
(plural) to qconfig.pri, based on whether the user passed
QMAKE_APPLE_DEVICE_ARCHS to configure, and then use that
to initialize QMAKE_APPLE_DEVICE_ARCHS again for user
projects.
We then resolve the active arch using uname -m, matching
what CMake does.
We still feed all the available architectures to the
Makefile or Xcode project, so that the user can build
for any of the available architectures without needing
a reconfigure.
Fixes: QTBUG-93760
Change-Id: I0d338241ba4d944ca36d85371e9c4df7dbc4f269
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit f9c850cc42a5591c096e1b0d547efb93ad18f1f1)
-rw-r--r-- | configure.pri | 16 | ||||
-rw-r--r-- | mkspecs/features/mac/default_post.prf | 18 |
2 files changed, 28 insertions, 6 deletions
diff --git a/configure.pri b/configure.pri index 8be9b10d7d..c8e7741059 100644 --- a/configure.pri +++ b/configure.pri @@ -992,6 +992,12 @@ defineTest(qtConfOutput_architecture) { subarch = $$qtConfEvaluate('tests.architecture.subarch') buildabi = $$qtConfEvaluate("tests.architecture.buildabi") + macos { + eval($$config.input.qmakeArgs) + apple_archs = $$QMAKE_APPLE_DEVICE_ARCHS + isEmpty(apple_archs): apple_archs = "\$\$ARCH" + } + $$qtConfEvaluate("features.cross_compile") { host_arch = $$qtConfEvaluate("tests.host_architecture.arch") host_buildabi = $$qtConfEvaluate("tests.host_architecture.buildabi") @@ -1013,12 +1019,22 @@ defineTest(qtConfOutput_architecture) { " QT_BUILDABI = $$buildabi" \ "}" + macos { + publicPro += \ + "host_build {" \ + " QT_ARCHS = \$\$QT_ARCH" \ + "} else {" \ + " QT_ARCHS = $$apple_archs" \ + "}" + } } else { privatePro = \ "QT_CPU_FEATURES.$$arch = $$subarch" publicPro = \ "QT_ARCH = $$arch" \ "QT_BUILDABI = $$buildabi" + + macos: publicPro += "QT_ARCHS = $$apple_archs" } $${currentConfig}.output.publicPro += $$publicPro diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index ff37b743c9..83151604d7 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -95,10 +95,11 @@ app_extension_api_only { QMAKE_LFLAGS += $$QMAKE_CFLAGS_APPLICATION_EXTENSION } -# Non-universal builds do not set QMAKE_APPLE_DEVICE_ARCHS, -# so we pick it up from what the arch test resolved instead. +# Pick up available architectures from what Qt was built with, +# so that our Makefile or Xcode project is set up to build for +# any of the available architectures. isEmpty(QMAKE_APPLE_DEVICE_ARCHS): \ - QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCH + QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCHS macx-xcode { qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO @@ -157,10 +158,15 @@ macx-xcode { single_arch: VALID_ARCHS = $$first(VALID_ARCHS) - ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS)) - ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ACTIVE_ARCHS), $(EXPORT_ACTIVE_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch)) + macos: ACTIVE_ARCH = $$system("uname -m") - QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCHS ARCH_ARGS + ARCHS = $(filter $(EXPORT_VALID_ARCHS), \ + $(if $(ARCHS), $(ARCHS), \ + $(if $(EXPORT_ACTIVE_ARCH), $(EXPORT_ACTIVE_ARCH), \ + $(EXPORT_VALID_ARCHS)))) + ARCH_ARGS = $(foreach arch, $(if $(EXPORT_ARCHS), $(EXPORT_ARCHS), $(EXPORT_VALID_ARCHS)), -arch $(arch)) + + QMAKE_EXTRA_VARIABLES += VALID_ARCHS ACTIVE_ARCH ARCHS ARCH_ARGS arch_flags = $(EXPORT_ARCH_ARGS) |