Skip to content

qtbase: Fix build for aarch64-darwin#180327

Merged
vcunat merged 1 commit intoNixOS:stagingfrom
tanshihaj:master
Jul 29, 2022
Merged

qtbase: Fix build for aarch64-darwin#180327
vcunat merged 1 commit intoNixOS:stagingfrom
tanshihaj:master

Conversation

@tanshihaj
Copy link
Contributor

Description of changes

Trying to fix qtbase build on aarch64-darwin platform. There is 2 issues:

  • cc <file> -o /dev/null fails on aarch64-darwin #154203 - issue with codesign on aarch64-darwin. I don't think that changes I suggest is a good solution, it is more workaround.
  • Issue with aarch64 build on macos mentioned here:
    # Qt5 is broken on aarch64-darwin
    # the build ends up with the following error:
    # error: unknown target CPU 'armv8.3-a+crypto+sha2+aes+crc+fp16+lse+simd+ras+rdm+rcpc'
    # note: valid target CPU values are: nocona, core2, penryn, ..., znver1, znver2, x86-64
    # it seems the qmake/cmake passes x86_64 as preferred architecture somewhere
    . This issue can be fixed with 0002-qtbase-mac-arm64.patch.
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@tanshihaj tanshihaj requested a review from ttuegel as a code owner July 6, 2022 08:39
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jul 6, 2022
@github-actions github-actions bot added the 6.topic: qt/kde Object-oriented framework for GUI creation label Jul 6, 2022
@tanshihaj
Copy link
Contributor Author

Some part of the solution was discussed here: #174008

@ofborg ofborg bot requested review from bkchr, periklis and qknight July 6, 2022 08:48
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jul 6, 2022
@periklis periklis removed their request for review July 7, 2022 12:06
@jiegec jiegec mentioned this pull request Jul 13, 2022
13 tasks
@tanshihaj tanshihaj closed this Jul 19, 2022
@github-actions github-actions bot removed the 6.topic: qt/kde Object-oriented framework for GUI creation label Jul 19, 2022
@tanshihaj tanshihaj reopened this Jul 19, 2022
@github-actions github-actions bot added the 6.topic: qt/kde Object-oriented framework for GUI creation label Jul 19, 2022
@tanshihaj
Copy link
Contributor Author

I've found in GitHub original commit used in homebrew and after applying it and removing -platform macx-clang configure option qtbase v5.15 builds on aarch64-darwin.

@ofborg ofborg bot requested a review from periklis July 19, 2022 21:59
@jiegec
Copy link
Member

jiegec commented Jul 25, 2022

I have a patch to avoid rebuilding the stdenv:

diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix
index 63350cde271..fede4647080 100644
--- a/pkgs/development/libraries/qt-5/modules/qtbase.nix
+++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix
@@ -129,9 +129,11 @@ stdenv.mkDerivation {
             -e 's|/usr/bin/xcodebuild|xcodebuild|' \
             -e 's|QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`|QMAKE_CXX="clang++"\nQMAKE_CONF_COMPILER="clang++"|' \
             ./configure
-            substituteInPlace ./mkspecs/common/mac.conf \
-                --replace "/System/Library/Frameworks/OpenGL.framework/" "${OpenGL}/Library/Frameworks/OpenGL.framework/" \
-                --replace "/System/Library/Frameworks/AGL.framework/" "${AGL}/Library/Frameworks/AGL.framework/"
+        substituteInPlace ./mkspecs/common/mac.conf \
+            --replace "/System/Library/Frameworks/OpenGL.framework/" "${OpenGL}/Library/Frameworks/OpenGL.framework/" \
+            --replace "/System/Library/Frameworks/AGL.framework/" "${AGL}/Library/Frameworks/AGL.framework/"
+        substituteInPlace ./mkspecs/features/toolchain.prf \
+            --replace "/dev/null" "\$\$(TMP)/qtbase_toolchain_link_test"
     '' else lib.optionalString libGLSupported ''
       sed -i mkspecs/common/linux.conf \
           -e "/^QMAKE_INCDIR_OPENGL/ s|$|${libGL.dev or libGL}/include|" \
diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix
index 2e93c672fd9..47dd47aedea 100644
--- a/pkgs/top-level/darwin-packages.nix
+++ b/pkgs/top-level/darwin-packages.nix
@@ -120,10 +120,8 @@ impure-cmds // appleSourcePackages // chooseLibs // {
     executable = true;
 
     text = ''
-      if [ "$linkerOutput" != "/dev/null" ]; then
-        CODESIGN_ALLOCATE=${targetPrefix}codesign_allocate \
-          ${self.sigtool}/bin/codesign -f -s - "$linkerOutput"
-      fi
+      CODESIGN_ALLOCATE=${targetPrefix}codesign_allocate \
+        ${self.sigtool}/bin/codesign -f -s - "$linkerOutput"
     '';
   };

@tanshihaj
Copy link
Contributor Author

@jiegec I will check this patch and update PR. But AFAIK if [ "$linkerOutput" != "/dev/null" ]; then not only for qt but also for some qt dependencies.

@jiegec
Copy link
Member

jiegec commented Jul 25, 2022

@jiegec I will check this patch and update PR. But AFAIK if [ "$linkerOutput" != "/dev/null" ]; then not only for qt but also for some qt dependencies.

Yes, but that rebuilds the toolchain, and this pr should be moved to target staging branch for that.

@vcunat vcunat changed the base branch from master to staging July 25, 2022 09:01
@tanshihaj
Copy link
Contributor Author

So maybe we will move if [ "$linkerOutput" != "/dev/null" ]; then to the staging branch in separate PR?

@vcunat
Copy link
Member

vcunat commented Jul 25, 2022

FYI, the staging cycles recently take around 10 days, so you can expect delay 10--20 days between merging and appearing in master (depending when you merge to staging).

@ofborg ofborg bot added 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. and removed 10.rebuild-darwin: 501-1000 This PR causes many rebuilds on Darwin and should normally target the staging branches. labels Jul 25, 2022
@jiegec
Copy link
Member

jiegec commented Jul 25, 2022

So maybe we will move if [ "$linkerOutput" != "/dev/null" ]; then to the staging branch in separate PR?

Have you encountered issues other than qt regarding this change?

@SuperSandro2000
Copy link
Member

I have a patch to avoid rebuilding the stdenv:

Please do the changes in a clean way even if it triggers a stdenv rebuild. Trying to avoid rebuilds with some hacks is not necessary.

@vcunat vcunat merged commit 9cfb24a into NixOS:staging Jul 29, 2022
@tanshihaj
Copy link
Contributor Author

Have you encountered issues other than qt regarding this change?

PR is merged, but for the history - it seems your diff was enough to build qt. I didn't faced with no other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: qt/kde Object-oriented framework for GUI creation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments