Skip to content

Commit 0d7ecd5

Browse files
committed
Merge bitcoin/bitcoin#23583: build, qt, macOS: Don't hard-code x86_64 as the arch when using qmake
d020419 Revert "doc: Install Rosetta on M1-macOS for qt in depends" (Hennadii Stepanov) f6e2781 build, qt, macOS: Don't pass -device-option when building natively (Hennadii Stepanov) 667f068 build, qt, macOS: Don't hard-code x86_64 as the arch when using qmake (Hennadii Stepanov) Pull request description: On master (4018e23) the Qt build system hard-coded the x86_64 as the architecture when using qmake. This means that compiling the `qt` package on M1 Apple Silicon for the same system, i.e., without providing the `HOST` variable,—that is supposed to be compiled natively—is a cross-compiling actually: ``` % make -C depends qt_configured ... Configure summary: Building on: macx-clang (x86_64, CPU features: cx16 mmx sse sse2 sse3 ssse3 sse4.1) Building for: macx-clang (arm64, CPU features: neon crc32) Target compiler: clang (Apple) 13.0.0 Configuration: cross_compile largefile neon precompile_header silent release c++11 c++14 c++1z reduce_exports static stl ... ``` Also this bug caused another [issue](bitcoin/bitcoin#22402) which currently is worked around by installing Rosetta. With this PR it is no longer needed to have Rosetta installed on M1-based macOS, and: ``` % make -C depends qt_configured ... Configure summary: Build type: macx-clang (arm64, CPU features: neon crc32) Compiler: clang (Apple) 13.0.0 Configuration: largefile neon precompile_header silent release c++11 c++14 c++1z reduce_exports static stl ... ``` ACKs for top commit: promag: Tested ACK d020419 fanquake: ACK d020419 Tree-SHA512: 2fcd88d172286b7d22ec7ea7ce0939b012211c0160df56de2f4cb69e99743c71df6b6ff4777c1722ec22b974f48a77cc22e7c14d7d64d02c4f82ac22bafe4087
2 parents 76392b0 + d020419 commit 0d7ecd5

File tree

4 files changed

+128
-11
lines changed

4 files changed

+128
-11
lines changed

depends/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,6 @@ For linux S390X cross compilation:
8787

8888
sudo apt-get install g++-s390x-linux-gnu binutils-s390x-linux-gnu
8989

90-
### Install the required dependencies: M1-based macOS
91-
92-
To be able to build the `qt` package, ensure that Rosetta 2 is installed:
93-
94-
```
95-
softwareupdate --install-rosetta
96-
```
97-
9890
### Dependency Options
9991

10092
The following can be set when running make: `make FOO=bar`

depends/packages/qt.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(package)_linguist_tools = lrelease lupdate lconvert
1010
$(package)_patches = qt.pro qttools_src.pro
1111
$(package)_patches += fix_qt_pkgconfig.patch mac-qmake.conf fix_no_printer.patch no-xlib.patch
1212
$(package)_patches += support_new_android_ndks.patch fix_android_jni_static.patch dont_hardcode_pwd.patch
13-
$(package)_patches+= no_sdk_version_check.patch
13+
$(package)_patches += dont_hardcode_x86_64.patch no_sdk_version_check.patch
1414
$(package)_patches+= fix_lib_paths.patch fix_android_pch.patch
1515
$(package)_patches+= qtbase-moc-ignore-gcc-macro.patch fix_limits_header.patch
1616
$(package)_patches+= fix_montery_include.patch
@@ -128,8 +128,10 @@ $(package)_config_opts_darwin += -device-option MAC_TARGET=$(host)
128128
$(package)_config_opts_darwin += -device-option XCODE_VERSION=$(XCODE_VERSION)
129129
endif
130130

131-
# for macOS on Apple Silicon (ARM) see https://bugreports.qt.io/browse/QTBUG-85279
131+
ifneq ($(build_arch),$(host_arch))
132132
$(package)_config_opts_aarch64_darwin += -device-option QMAKE_APPLE_DEVICE_ARCHS=arm64
133+
$(package)_config_opts_x86_64_darwin += -device-option QMAKE_APPLE_DEVICE_ARCHS=x86_64
134+
endif
133135

134136
$(package)_config_opts_linux = -qt-xcb
135137
$(package)_config_opts_linux += -no-xcb-xlib
@@ -229,6 +231,7 @@ define $(package)_preprocess_cmds
229231
patch -p1 -i $($(package)_patch_dir)/fix_android_jni_static.patch && \
230232
patch -p1 -i $($(package)_patch_dir)/fix_android_pch.patch && \
231233
patch -p1 -i $($(package)_patch_dir)/no-xlib.patch && \
234+
patch -p1 -i $($(package)_patch_dir)/dont_hardcode_x86_64.patch && \
232235
patch -p1 -i $($(package)_patch_dir)/no_sdk_version_check.patch && \
233236
patch -p1 -i $($(package)_patch_dir)/fix_lib_paths.patch && \
234237
patch -p1 -i $($(package)_patch_dir)/qtbase-moc-ignore-gcc-macro.patch && \
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
macOS: Don't hard-code x86_64 as the architecture when using qmake
2+
3+
Upstream commit:
4+
- Qt 6.1: 9082cc8e8d5a6441dabe5e7a95bc0cd9085b95fe
5+
6+
For other Qt branches see
7+
https://codereview.qt-project.org/q/I70db7e4c27f0d3da5d0af33cb491d72c312d3fa8
8+
9+
10+
--- old/qtbase/configure.json
11+
+++ new/qtbase/configure.json
12+
@@ -208,11 +208,18 @@
13+
14+
"testTypeDependencies": {
15+
"linkerSupportsFlag": [ "use_gold_linker" ],
16+
- "verifySpec": [ "shared", "use_gold_linker", "compiler-flags", "qmakeargs", "commit" ],
17+
+ "verifySpec": [
18+
+ "shared",
19+
+ "use_gold_linker",
20+
+ "compiler-flags", "qmakeargs",
21+
+ "simulator_and_device",
22+
+ "thread",
23+
+ "commit" ],
24+
"compile": [ "verifyspec" ],
25+
"detectPkgConfig": [ "cross_compile", "machineTuple" ],
26+
"library": [ "pkg-config", "compiler-flags" ],
27+
- "getPkgConfigVariable": [ "pkg-config" ]
28+
+ "getPkgConfigVariable": [ "pkg-config" ],
29+
+ "architecture" : [ "verifyspec" ]
30+
},
31+
32+
"testTypeAliases": {
33+
@@ -653,7 +660,7 @@
34+
},
35+
"architecture": {
36+
"label": "Architecture",
37+
- "output": [ "architecture" ]
38+
+ "output": [ "architecture", "commitConfig" ]
39+
},
40+
"pkg-config": {
41+
"label": "Using pkg-config",
42+
diff --git a/configure.pri b/configure.pri
43+
index 33c90a8c2f..71767e29d6 100644
44+
45+
--- old/qtbase/configure.pri
46+
+++ new/qtbase/configure.pri
47+
@@ -642,6 +642,13 @@ defineTest(qtConfOutput_commitOptions) {
48+
write_file($$QT_BUILD_TREE/mkspecs/qdevice.pri, $${currentConfig}.output.devicePro)|error()
49+
}
50+
51+
+# Output is written after configuring each Qt module,
52+
+# but some tests within a module might depend on the
53+
+# configuration output of previous tests.
54+
+defineTest(qtConfOutput_commitConfig) {
55+
+ qtConfProcessOutput()
56+
+}
57+
+
58+
# type (empty or 'host'), option name, default value
59+
defineTest(processQtPath) {
60+
out_var = config.rel_input.$${2}
61+
diff --git a/mkspecs/common/macx.conf b/mkspecs/common/macx.conf
62+
index 7d4a406134..de96c12fc9 100644
63+
64+
--- old/qtbase/mkspecs/common/macx.conf
65+
+++ new/qtbase/mkspecs/common/macx.conf
66+
@@ -6,7 +6,6 @@ QMAKE_PLATFORM += macos osx macx
67+
QMAKE_MAC_SDK = macosx
68+
69+
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12
70+
-QMAKE_APPLE_DEVICE_ARCHS = x86_64
71+
72+
QT_MAC_SDK_VERSION_MIN = 10.13
73+
QT_MAC_SDK_VERSION_MAX = 11.0
74+
diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf
75+
index d052808c14..0a89effe87 100644
76+
77+
--- old/qtbase/mkspecs/features/mac/default_post.prf
78+
+++ new/qtbase/mkspecs/features/mac/default_post.prf
79+
@@ -89,6 +89,11 @@ app_extension_api_only {
80+
QMAKE_LFLAGS += $$QMAKE_CFLAGS_APPLICATION_EXTENSION
81+
}
82+
83+
+# Non-universal builds do not set QMAKE_APPLE_DEVICE_ARCHS,
84+
+# so we pick it up from what the arch test resolved instead.
85+
+isEmpty(QMAKE_APPLE_DEVICE_ARCHS): \
86+
+ QMAKE_APPLE_DEVICE_ARCHS = $$QT_ARCH
87+
+
88+
macx-xcode {
89+
qmake_pkginfo_typeinfo.name = QMAKE_PKGINFO_TYPEINFO
90+
!isEmpty(QMAKE_PKGINFO_TYPEINFO): \
91+
@@ -144,9 +149,6 @@ macx-xcode {
92+
simulator: VALID_SIMULATOR_ARCHS = $$QMAKE_APPLE_SIMULATOR_ARCHS
93+
VALID_ARCHS = $$VALID_DEVICE_ARCHS $$VALID_SIMULATOR_ARCHS
94+
95+
- isEmpty(VALID_ARCHS): \
96+
- error("QMAKE_APPLE_DEVICE_ARCHS or QMAKE_APPLE_SIMULATOR_ARCHS must contain at least one architecture")
97+
-
98+
single_arch: VALID_ARCHS = $$first(VALID_ARCHS)
99+
100+
ACTIVE_ARCHS = $(filter $(EXPORT_VALID_ARCHS), $(ARCHS))
101+
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
102+
index 5003679bd0..c7c080cb07 100644
103+
104+
--- old/qtbase/mkspecs/features/toolchain.prf
105+
+++ new/qtbase/mkspecs/features/toolchain.prf
106+
@@ -182,9 +182,14 @@ isEmpty($${target_prefix}.INCDIRS) {
107+
# UIKit simulator platforms will see the device SDK's sysroot in
108+
# QMAKE_DEFAULT_*DIRS, because they're handled in a single build pass.
109+
darwin {
110+
- # Clang doesn't pick up the architecture from the sysroot, and will
111+
- # default to the host architecture, so we need to manually set it.
112+
- cxx_flags += -arch $$QMAKE_APPLE_DEVICE_ARCHS
113+
+ uikit {
114+
+ # Clang doesn't automatically pick up the architecture, just because
115+
+ # we're passing the iOS sysroot below, and we will end up building the
116+
+ # test for the host architecture, resulting in linker errors when
117+
+ # linking against the iOS libraries. We work around this by passing
118+
+ # the architecture explicitly.
119+
+ cxx_flags += -arch $$first(QMAKE_APPLE_DEVICE_ARCHS)
120+
+ }
121+
122+
uikit:macx-xcode: \
123+
cxx_flags += -isysroot $$sdk_path_device.value

depends/patches/qt/mac-qmake.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH}
1313
QMAKE_MAC_SDK.macosx.platform_name = macosx
1414
QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION}
1515
QMAKE_MAC_SDK.macosx.PlatformPath = /phony
16-
QMAKE_APPLE_DEVICE_ARCHS=x86_64
1716
!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET}
1817
!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS
1918
!host_build: QMAKE_CXXFLAGS += $$QMAKE_CFLAGS

0 commit comments

Comments
 (0)