macOS: Don't hard-code x86_64 as the architecture when using qmake

The qmake variable QMAKE_APPLE_DEVICE_ARCHS was added for iOS,
to support universal builds, as the QT_ARCH is a single value.

Since the qmake macOS builds are non-universal (at the moment),
we remove the hard-coded value for QMAKE_APPLE_DEVICE_ARCHS on
macOS, and let the normal architecture test resolve the arch,
like on other platforms.

To ensure that the following configuration tests are run with
an -arch argument, we trigger a commit of the preliminary Qt
configuration after running the architecture test. This is not
strictly necessary, but makes it clearer what's going on during
configure.

The device_and_simulator configuration option was used by the
iOS toolchain, and needed to be moved up in the configuration
test order to not break later tests.

The logic in mac/default_post.prf for both Xcode and Makefiles
to add -arch flags was kept as is, based on the existing
variable, to avoid too many changes to this logic.

The logic in toolchain.prf was amended to make it clear and
ensure that it only applies to iOS builds. macOS builds do
not have this issue.

Pick-to: 6.0
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I70db7e4c27f0d3da5d0af33cb491d72c312d3fa8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-12-04 17:29:06 +01:00
parent a201ce7f11
commit 9082cc8e8d
5 changed files with 30 additions and 10 deletions

View File

@ -241,11 +241,18 @@
"testTypeDependencies": { "testTypeDependencies": {
"linkerSupportsFlag": [ "use_bfd_linker", "use_gold_linker", "use_lld_linker" ], "linkerSupportsFlag": [ "use_bfd_linker", "use_gold_linker", "use_lld_linker" ],
"verifySpec": [ "shared", "use_bfd_linker", "use_gold_linker", "use_lld_linker", "compiler-flags", "qmakeargs", "commit" ], "verifySpec": [
"shared",
"use_bfd_linker", "use_gold_linker", "use_lld_linker",
"compiler-flags", "qmakeargs",
"simulator_and_device",
"thread",
"commit" ],
"compile": [ "verifyspec" ], "compile": [ "verifyspec" ],
"detectPkgConfig": [ "cross_compile", "machineTuple" ], "detectPkgConfig": [ "cross_compile", "machineTuple" ],
"library": [ "pkg-config", "compiler-flags" ], "library": [ "pkg-config", "compiler-flags" ],
"getPkgConfigVariable": [ "pkg-config" ] "getPkgConfigVariable": [ "pkg-config" ],
"architecture" : [ "verifyspec" ]
}, },
"testTypeAliases": { "testTypeAliases": {
@ -749,7 +756,7 @@
}, },
"architecture": { "architecture": {
"label": "Architecture", "label": "Architecture",
"output": [ "architecture" ] "output": [ "architecture", "commitConfig" ]
}, },
"pkg-config": { "pkg-config": {
"label": "Using pkg-config", "label": "Using pkg-config",

View File

@ -660,6 +660,13 @@ defineTest(qtConfOutput_commitOptions) {
write_file($$QT_BUILD_TREE/mkspecs/qdevice.pri, $${currentConfig}.output.devicePro)|error() write_file($$QT_BUILD_TREE/mkspecs/qdevice.pri, $${currentConfig}.output.devicePro)|error()
} }
# Output is written after configuring each Qt module,
# but some tests within a module might depend on the
# configuration output of previous tests.
defineTest(qtConfOutput_commitConfig) {
qtConfProcessOutput()
}
# type (empty or 'host'), option name, default value # type (empty or 'host'), option name, default value
defineTest(processQtPath) { defineTest(processQtPath) {
out_var = config.rel_input.$${2} out_var = config.rel_input.$${2}

View File

@ -6,7 +6,6 @@ QMAKE_PLATFORM += macos osx macx
QMAKE_MAC_SDK = macosx QMAKE_MAC_SDK = macosx
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14 QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14
QMAKE_APPLE_DEVICE_ARCHS = x86_64
# Should be 10.15, but as long as the CI builds with # Should be 10.15, but as long as the CI builds with
# older SDKs we have to keep this. # older SDKs we have to keep this.

View File

@ -90,6 +90,11 @@ app_extension_api_only {
QMAKE_LFLAGS += $$QMAKE_CFLAGS_APPLICATION_EXTENSION 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.
isEmpty(QMAKE_APPLE_DEVICE_ARCHS): \
QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCH
macx-xcode { macx-xcode {
qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO
!isEmpty(QMAKE_PKGINFO_TYPEINFO): \ !isEmpty(QMAKE_PKGINFO_TYPEINFO): \
@ -145,9 +150,6 @@ macx-xcode {
simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
isEmpty(VALID_ARCHS): \
error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
single_arch: VALID_ARCHS = $$first(VALID_ARCHS) single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS)) ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))

View File

@ -182,9 +182,14 @@ isEmpty($${target_prefix}.INCDIRS) {
# UIKit simulator platforms will see the device SDK's sysroot in # UIKit simulator platforms will see the device SDK's sysroot in
# QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass. # QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass.
darwin { darwin {
# Clang doesn't pick up the architecture from the sysroot, and will uikit {
# default to the host architecture, so we need to manually set it. # Clang doesn't automatically pick up the architecture, just because
cxx_flags += -arch $$QMAKE_APPLE_DEVICE_ARCHS # we're passing the iOS sysroot below, and we will end up building the
# test for the host architecture, resulting in linker errors when
# linking against the iOS libraries. We work around this by passing
# the architecture explicitly.
cxx_flags += -arch $$first(QMAKE_APPLE_DEVICE_ARCHS)
}
uikit:macx-xcode: \ uikit:macx-xcode: \
cxx_flags += -isysroot $$sdk_path_device.value cxx_flags += -isysroot $$sdk_path_device.value