Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt5 PortGroup: support arm64 #9686

Merged
merged 2 commits into from Jan 14, 2021
Merged

qt5 PortGroup: support arm64 #9686

merged 2 commits into from Jan 14, 2021

Conversation

kencu
Copy link
Contributor

@kencu kencu commented Jan 12, 2021

at present only on qt5.15.x and above
universal builds not tested as yet

closes: https://trac.macports.org/ticket/60944

at present only on qt5.15.x and above
universal builds not tested as yet

closes: https://trac.macports.org/ticket/60944
@macportsbot macportsbot added the by: member Created by a member with commit rights label Jan 12, 2021
@kencu kencu requested a review from michaelld January 12, 2021 06:39
@kencu
Copy link
Contributor Author

kencu commented Jan 12, 2021

Michael -- there was one more edit I made manually in the config files installed on the arm64 Mac by qt5-base:

% diff -ur /opt/local/libexec/qt5/mkspecs ~/ken/mkspecs
diff -ur /opt/local/libexec/qt5/mkspecs/common/macx.conf /Users/kencu/ken/mkspecs/common/macx.conf
--- /opt/local/libexec/qt5/mkspecs/common/macx.conf	2020-10-27 04:02:11.000000000 -0400
+++ /Users/kencu/ken/mkspecs/common/macx.conf	2021-01-12 02:34:57.000000000 -0500
@@ -5,8 +5,8 @@
 QMAKE_PLATFORM         += macos osx macx
 QMAKE_MAC_SDK           = macosx
 
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.13
-QMAKE_APPLE_DEVICE_ARCHS = x86_64
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
+QMAKE_APPLE_DEVICE_ARCHS = arm64
 
 # Should be 10.15, but as long as the CI builds with
 # older SDKs we have to keep this.

before we build qt5-qtbase for arm64, I/we should find some way to make sure that fix is incorporated into the build of qt5-qtbase, otherwise we'll just have to fix it soon afterwards.

Copy link
Contributor

@michaelld michaelld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me; thanks!

@michaelld
Copy link
Contributor

Michael -- there was one more edit I made manually in the config files installed on the arm64 Mac by qt5-base:

% diff -ur /opt/local/libexec/qt5/mkspecs ~/ken/mkspecs
diff -ur /opt/local/libexec/qt5/mkspecs/common/macx.conf /Users/kencu/ken/mkspecs/common/macx.conf
--- /opt/local/libexec/qt5/mkspecs/common/macx.conf	2020-10-27 04:02:11.000000000 -0400
+++ /Users/kencu/ken/mkspecs/common/macx.conf	2021-01-12 02:34:57.000000000 -0500
@@ -5,8 +5,8 @@
 QMAKE_PLATFORM         += macos osx macx
 QMAKE_MAC_SDK           = macosx
 
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.13
-QMAKE_APPLE_DEVICE_ARCHS = x86_64
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
+QMAKE_APPLE_DEVICE_ARCHS = arm64
 
 # Should be 10.15, but as long as the CI builds with
 # older SDKs we have to keep this.

before we build qt5-qtbase for arm64, I/we should find some way to make sure that fix is incorporated into the build of qt5-qtbase, otherwise we'll just have to fix it soon afterwards.

Yup I remember having to do that too. Can you add on a commit to fix this in Qt5 for ARM64 to this PR? Best to keep them together IMHO & it's a simple -- but critical -- fix!

@kencu
Copy link
Contributor Author

kencu commented Jan 12, 2021

So I was just looking at that issue this morning. In the build of qt5-qtbase, Marcus makes a bunch of modifications to the mkspecs to allow things to build properly, but then -- it appears -- he undoes them all and restores the original qt5 mkspecs, in the hope of keeping qt5 "stock" for building projects unrelated to MacPorts, it seems. His notes indicate that he intends to override those stock mkspecs during Macports builds with environment variables instead (and I think that is what happens in the qmake5 portgroup).

SO -- I'm just at the point of deciding whether this particular mkspec has to be installed modified in this particular case on an arm64 machine -- which is what I did above -- or whether we should look at adding some more variables to the qmake5 PG to overcome this issue on arm (assuming they are not already there).

@kencu
Copy link
Contributor Author

kencu commented Jan 13, 2021

On the arm Mac, these are the changes that are made in the mkspecs for the build (that are later reverted and restored at the end of the build):

% diff -ur mkspecs-save mkspecs
diff -ur mkspecs-save/common/clang.conf mkspecs/common/clang.conf
--- mkspecs-save/common/clang.conf	2020-10-27 04:02:11.000000000 -0400
+++ mkspecs/common/clang.conf	2021-01-13 13:27:06.000000000 -0500
@@ -4,8 +4,8 @@
 
 QMAKE_COMPILER          = gcc clang llvm   # clang pretends to be gcc
 
-QMAKE_CC                = $${CROSS_COMPILE}clang
-QMAKE_CXX               = $${CROSS_COMPILE}clang++
+QMAKE_CC                = clang
+QMAKE_CXX               = clang++
 
 QMAKE_LINK_C            = $$QMAKE_CC
 QMAKE_LINK_C_SHLIB      = $$QMAKE_CC
diff -ur mkspecs-save/common/mac.conf mkspecs/common/mac.conf
--- mkspecs-save/common/mac.conf	2020-10-27 04:02:11.000000000 -0400
+++ mkspecs/common/mac.conf	2021-01-13 13:27:06.000000000 -0500
@@ -12,7 +12,7 @@
 
 include(unix.conf)
 
-QMAKE_RESOURCE          = /Developer/Tools/Rez
+QMAKE_RESOURCE          = /Library/Developer/CommandLineTools/usr/bin/Rez
 QMAKE_EXTENSION_SHLIB   = dylib
 QMAKE_LIBDIR            =
 
diff -ur mkspecs-save/common/macx.conf mkspecs/common/macx.conf
--- mkspecs-save/common/macx.conf	2020-10-27 04:02:11.000000000 -0400
+++ mkspecs/common/macx.conf	2021-01-13 13:27:07.000000000 -0500
@@ -5,8 +5,8 @@
 QMAKE_PLATFORM         += macos osx macx
 QMAKE_MAC_SDK           = macosx
 
-QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.13
-QMAKE_APPLE_DEVICE_ARCHS = x86_64
+QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
+QMAKE_APPLE_DEVICE_ARCHS = arm64
 
 # Should be 10.15, but as long as the CI builds with
 # older SDKs we have to keep this.
diff -ur mkspecs-save/features/mac/rez.prf mkspecs/features/mac/rez.prf
--- mkspecs-save/features/mac/rez.prf	2020-10-27 04:02:11.000000000 -0400
+++ mkspecs/features/mac/rez.prf	2021-01-13 13:27:06.000000000 -0500
@@ -1,7 +1,7 @@
 
 #global defaults
 isEmpty(QMAKE_REZ) {
-    QMAKE_REZ = /Developer/Tools/Rez
+    QMAKE_REZ = /Library/Developer/CommandLineTools/usr/bin/Rez
 }
 isEmpty(REZ_DIR):REZ_DIR = .
 isEmpty(QMAKE_EXT_REZ):QMAKE_EXT_REZ = .rsrc
diff -ur mkspecs-save/macx-clang/qmake.conf mkspecs/macx-clang/qmake.conf
--- mkspecs-save/macx-clang/qmake.conf	2020-10-27 04:02:11.000000000 -0400
+++ mkspecs/macx-clang/qmake.conf	2021-01-13 13:27:07.000000000 -0500
@@ -21,8 +21,8 @@
 # and X11, OpenGL is currently not supported.
 
 QMAKE_LIBS_X11 = -lX11 -lXext -lm
-QMAKE_LIBDIR_X11 = /opt/X11/lib
-QMAKE_INCDIR_X11 = /opt/X11/include
+QMAKE_LIBDIR_X11 = /opt/local/lib
+QMAKE_INCDIR_X11 = /opt/local/include
 
 include(../common/macx.conf)
 include(../common/gcc-base-mac.conf)

Of these changes, only the ones in mkspecs/common/macx.conf would seem to be problematic for the qt5 arm mac installation. The arch and the deployment target just don't work out properly for the arm install.

So I think we should install the modified mkspecs/common/macx.conf instead of restoring the saved mkspecs/common/macx.conf and installing that.

It's a trivial enough fix in the qt5-qttools part of the qt5 Portfile. I had to do something similar in the qt53-qttools installation to accommodate our 10.6.8 using libc++. Just a conditional in the qt5-qttools logic to keep that particular configuration file if we're installing on an arm mac should do it.

@kencu
Copy link
Contributor Author

kencu commented Jan 13, 2021

Noted that this will make it probably impossible to build a universal version of qt5-qttools, however, as the x86_64 and arm64 versions of mkspecs/common/macx.conf will then be different...

@kencu
Copy link
Contributor Author

kencu commented Jan 13, 2021

What would happen, I wonder, if we just removed those two envvars from that conf file on BigSur and above?

Intel:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.13
QMAKE_APPLE_DEVICE_ARCHS = x86_64

Arm:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 11.0
QMAKE_APPLE_DEVICE_ARCHS = arm64

Perhaps qt5 would then just let the compiler set the MACOSX_DEPLOYMENT_TARGET and ARCHS, and if so, that might work out just nicely, perhaps...for a universal build of qt5...

@kencu
Copy link
Contributor Author

kencu commented Jan 13, 2021

Removing the force seems to be exactly what upstream decided to do:

qt/qtbase@9082cc8

@kencu
Copy link
Contributor Author

kencu commented Jan 13, 2021

and we have this https://codereview.qt-project.org/c/qt/qtbase/+/327649 and this https://raw.githubusercontent.com/Homebrew/formula-patches/9dc732/qt/qt-split-arch.patch as well to consider. This is what homebrew went with.

this patch uses the current upstream
changes to allow alternative archs to
x86_64 for builds.

qt/qtbase@9082cc8

there could be further upstream changes and patches -- and
indeed almost certainly there will be -- but for now this
meets the needs of allowing an arm64 build of qt5 that functions
@kencu
Copy link
Contributor Author

kencu commented Jan 14, 2021

the upstream commit seems to work just fine. All the qt5 apps build and run, including the gui apps. There are a few qt5 apps that I can't build arm64 just yet -- qt5-qtcreator needs llvm10, and sigil and others need qt5-qtwebengine. So I'll have to work on those for arm. But the others I have tried are building and running as expected.

I'm just running WireShark 3 now as an arm64 GUI application on the Apple Silicon system, and it loks great adn seems to work normally.

@kencu kencu merged commit 3fd3d02 into macports:master Jan 14, 2021
@kencu kencu deleted the qt5_support_arm branch January 14, 2021 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
by: member Created by a member with commit rights
3 participants