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

qt{5,6}: update for the new Darwin SDK #347216

Merged
merged 8 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions pkgs/development/libraries/qt-5/5.15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,15 @@ let
inherit bison cups harfbuzz libGL;
withGtk3 = !stdenv.hostPlatform.isDarwin; inherit dconf gtk3;
inherit developerBuild decryptSslTraffic;
inherit (darwin.apple_sdk_11_0.frameworks) AGL AppKit ApplicationServices AVFoundation Carbon Cocoa CoreAudio CoreBluetooth
CoreLocation CoreServices DiskArbitration Foundation OpenGL MetalKit IOKit;
libobjc = darwin.apple_sdk_11_0.objc4;
xcbuild = darwin.apple_sdk_11_0.xcodebuild;
};

qt3d = callPackage ../modules/qt3d.nix {};
qtcharts = callPackage ../modules/qtcharts.nix {};
qtconnectivity = callPackage ../modules/qtconnectivity.nix {
inherit (darwin.apple_sdk_11_0.frameworks) IOBluetooth;
};
qtconnectivity = callPackage ../modules/qtconnectivity.nix { };
qtdatavis3d = callPackage ../modules/qtdatavis3d.nix {};
qtdeclarative = callPackage ../modules/qtdeclarative.nix {};
qtdoc = callPackage ../modules/qtdoc.nix {};
qtgamepad = callPackage ../modules/qtgamepad.nix {
inherit (darwin.apple_sdk_11_0.frameworks) GameController;
};
qtgamepad = callPackage ../modules/qtgamepad.nix { };
qtgraphicaleffects = callPackage ../modules/qtgraphicaleffects.nix {};
qtimageformats = callPackage ../modules/qtimageformats.nix {};
qtlocation = callPackage ../modules/qtlocation.nix {};
Expand All @@ -278,9 +270,7 @@ let
qtnetworkauth = callPackage ../modules/qtnetworkauth.nix {};
qtpim = callPackage ../modules/qtpim.nix {};
qtpositioning = callPackage ../modules/qtpositioning.nix {};
qtpurchasing = callPackage ../modules/qtpurchasing.nix {
inherit (darwin.apple_sdk_11_0.frameworks) Foundation StoreKit;
};
qtpurchasing = callPackage ../modules/qtpurchasing.nix { };
qtquick1 = null;
qtquick3d = callPackage ../modules/qtquick3d.nix { };
qtquickcontrols = callPackage ../modules/qtquickcontrols.nix {};
Expand Down Expand Up @@ -309,28 +299,15 @@ let
# starting with clang 16. Patches are available upstream that can be backported.
# Because the first error is non-trivial to fix and suppressing it risks future breakage,
# clang is pinned to clang 15. That also makes fixing the second set of errors unnecessary.
stdenv =
let stdenv' = if stdenv.cc.isClang then overrideLibcxx llvmPackages_15.stdenv else stdenv;
in if stdenv'.hostPlatform.isDarwin then overrideSDK stdenv' "11.0" else stdenv';
stdenv = if stdenv.cc.isClang then overrideLibcxx llvmPackages_15.stdenv else stdenv;
inherit (srcs.qtwebengine) version;
inherit (darwin) bootstrap_cmds;
python = python3;
inherit (darwin) xnu;
inherit (darwin.apple_sdk_11_0) libpm libunwind;
inherit (darwin.apple_sdk_11_0.libs) sandbox;
inherit (darwin.apple_sdk_11_0.frameworks) ApplicationServices AVFoundation Foundation ForceFeedback GameController AppKit
ImageCaptureCore CoreBluetooth IOBluetooth CoreWLAN Quartz Cocoa LocalAuthentication
MediaPlayer MediaAccessibility SecurityInterface Vision CoreML OpenDirectory Accelerate;
libobjc = darwin.apple_sdk_11_0.objc4;
};
qtwebglplugin = callPackage ../modules/qtwebglplugin.nix {};
qtwebkit = callPackage ../modules/qtwebkit.nix {
inherit (darwin) ICU;
inherit (darwin.apple_sdk_11_0.frameworks) OpenGL;
};
qtwebkit = callPackage ../modules/qtwebkit.nix { };
qtwebsockets = callPackage ../modules/qtwebsockets.nix {};
qtwebview = callPackage ../modules/qtwebview.nix {
inherit (darwin.apple_sdk_11_0.frameworks) CoreFoundation WebKit;
};
qtwebview = callPackage ../modules/qtwebview.nix { };
qtx11extras = callPackage ../modules/qtx11extras.nix {};
qtxmlpatterns = callPackage ../modules/qtxmlpatterns.nix {};

Expand Down
33 changes: 18 additions & 15 deletions pkgs/development/libraries/qt-5/modules/qtbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
, coreutils, bison, flex, gdb, gperf, lndir, perl, pkg-config, python3
, which
# darwin support
, libiconv, libobjc, xcbuild, AGL, AppKit, ApplicationServices, AVFoundation, Carbon, Cocoa, CoreAudio, CoreBluetooth
, CoreLocation, CoreServices, DiskArbitration, Foundation, OpenGL, MetalKit, IOKit
, darwinMinVersionHook, apple-sdk, apple-sdk_10_14, apple-sdk_14, xcbuild

, dbus, fontconfig, freetype, glib, harfbuzz, icu, libdrm, libX11, libXcomposite
, libXcursor, libXext, libXi, libXrender, libinput, libjpeg, libpng , libxcb
Expand Down Expand Up @@ -38,6 +37,13 @@ let
if isLinux
then "linux-generic-g++"
else throw "Please add a qtPlatformCross entry for ${plat.config}";

# Per https://doc.qt.io/qt-5/macos.html#supported-versions: deployment target = 10.13, build SDK = 14.x.
# Note that Qt propagates the 10.14 SDK instead of the 10.13 SDK to make sure that applications linked to Qt
# support automatic dark mode on x86_64-darwin (see: https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app).
propagatedAppleSDK = if lib.versionOlder (lib.getVersion apple-sdk) "10.14" then apple-sdk_10_14 else apple-sdk;
propagatedMinVersionHook = darwinMinVersionHook "10.13";
buildAppleSDK = apple-sdk_14;
in

stdenv.mkDerivation (finalAttrs: ({
Expand All @@ -56,10 +62,8 @@ stdenv.mkDerivation (finalAttrs: ({
pcre2
] ++ (
if stdenv.hostPlatform.isDarwin then [
# TODO: move to buildInputs, this should not be propagated.
AGL AppKit ApplicationServices AVFoundation Carbon Cocoa CoreAudio CoreBluetooth
CoreLocation CoreServices DiskArbitration Foundation OpenGL
libobjc libiconv MetalKit IOKit
propagatedAppleSDK
propagatedMinVersionHook
] else [
dbus glib udev

Expand All @@ -80,6 +84,7 @@ stdenv.mkDerivation (finalAttrs: ({
[ libinput ]
++ lib.optional withGtk3 gtk3
)
++ lib.optional stdenv.isDarwin buildAppleSDK
++ lib.optional developerBuild gdb
++ lib.optional (cups != null) cups
++ lib.optional (mysqlSupport) libmysqlclient
Expand Down Expand Up @@ -141,15 +146,13 @@ stdenv.mkDerivation (finalAttrs: ({
patchShebangs ./bin
'' + (
if stdenv.hostPlatform.isDarwin then ''
sed -i \
-e 's|/usr/bin/xcode-select|xcode-select|' \
-e 's|/usr/bin/xcrun|xcrun|' \
-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 configure \
--replace-fail '/usr/bin/xcode-select' '${lib.getBin xcbuild}/bin/xcode-select' \
Copy link
Member

Choose a reason for hiding this comment

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

We could also use lib.getExe'

--replace-fail '/usr/bin/xcrun' '${lib.getBin xcbuild}/bin/xcrun' \
--replace-fail '/System/Library/Frameworks/Cocoa.framework' "$SDKROOT/System/Library/Frameworks/Cocoa.framework"
substituteInPlace ./mkspecs/common/mac.conf \
--replace-fail "/System/Library/Frameworks/OpenGL.framework/" "$SDKROOT/System/Library/Frameworks/OpenGL.framework/" \
--replace-fail "/System/Library/Frameworks/AGL.framework/" "$SDKROOT/System/Library/Frameworks/AGL.framework/"
'' else lib.optionalString libGLSupported ''
sed -i mkspecs/common/linux.conf \
-e "/^QMAKE_INCDIR_OPENGL/ s|$|${lib.getDev libGL}/include|" \
Expand Down
4 changes: 1 addition & 3 deletions pkgs/development/libraries/qt-5/modules/qtconnectivity.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{ qtModule, lib, stdenv, qtbase, qtdeclarative, bluez, IOBluetooth }:
{ qtModule, lib, stdenv, qtbase, qtdeclarative, bluez }:

qtModule {
pname = "qtconnectivity";
buildInputs = lib.optional stdenv.hostPlatform.isLinux bluez;
propagatedBuildInputs = [
qtbase
qtdeclarative
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
IOBluetooth
];
outputs = [ "out" "dev" "bin" ];
}
5 changes: 2 additions & 3 deletions pkgs/development/libraries/qt-5/modules/qtgamepad.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{ lib, stdenv, qtModule, qtbase, qtdeclarative, GameController, pkg-config }:
{ qtModule, qtbase, qtdeclarative, pkg-config }:

qtModule {
pname = "qtgamepad";
propagatedBuildInputs = [ qtbase qtdeclarative ]
++ lib.optional stdenv.hostPlatform.isDarwin GameController;
propagatedBuildInputs = [ qtbase qtdeclarative ];
nativeBuildInputs = [ pkg-config ];
outputs = [ "out" "dev" "bin" ];
}
10 changes: 1 addition & 9 deletions pkgs/development/libraries/qt-5/modules/qtpurchasing.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
{ stdenv
, lib
, qtModule
, qtbase
, qtdeclarative
, StoreKit
, Foundation
}:
{ qtModule, qtbase, qtdeclarative }:

qtModule {
pname = "qtpurchasing";
propagatedBuildInputs = [ qtbase qtdeclarative ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ Foundation StoreKit ];
}
59 changes: 5 additions & 54 deletions pkgs/development/libraries/qt-5/modules/qtwebengine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
, systemd
, enableProprietaryCodecs ? true
, gn
, cctools, libobjc, libpm, libunwind, sandbox, xnu
, ApplicationServices, AVFoundation, Foundation, ForceFeedback, GameController, AppKit
, ImageCaptureCore, CoreBluetooth, IOBluetooth, CoreWLAN, Quartz, Cocoa, LocalAuthentication
, MediaPlayer, MediaAccessibility, SecurityInterface, Vision, CoreML, OpenDirectory, Accelerate
, cups, openbsm, xcbuild, writeScriptBin
, apple-sdk_13, cctools, cups, bootstrap_cmds, xcbuild, writeScriptBin
, ffmpeg ? null
, lib, stdenv
, version ? null
Expand Down Expand Up @@ -55,7 +51,8 @@ let

in

qtModule ({
# Override the SDK because Qt WebEngine doesn’t seem to build using the 14.4 SDK.
(qtModule.override { apple-sdk_for_qt = apple-sdk_13; }) ({
pname = "qtwebengine";
nativeBuildInputs = [
bison flex git gperf ninja pkg-config (python.withPackages(ps: [ ps.html5lib ])) which gn nodejs
Expand All @@ -65,7 +62,7 @@ qtModule ({
pkgsBuildBuild.pkg-config
(lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols)
pkg-config-wrapped-without-prefix
] ++ lib.optional stdenv.hostPlatform.isDarwin xcbuild;
] ++ lib.optional stdenv.hostPlatform.isDarwin [ bootstrap_cmds xcbuild ];
doCheck = true;
outputs = [ "bin" "dev" "out" ];

Expand Down Expand Up @@ -158,22 +155,6 @@ qtModule ({
substituteInPlace src/buildtools/config/mac_osx.pri \
--replace 'QMAKE_CLANG_DIR = "/usr"' 'QMAKE_CLANG_DIR = "${stdenv.cc}"'

# Following is required to prevent a build error:
# ninja: error: '/nix/store/z8z04p0ph48w22rqzx7ql67gy8cyvidi-SDKs/MacOSX10.12.sdk/usr/include/mach/exc.defs', needed by 'gen/third_party/crashpad/crashpad/util/mach/excUser.c', missing and no known rule to make it
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/BUILD.gn \
--replace '$sysroot/usr' "${xnu}"

# Apple has some secret stuff they don't share with OpenBSM
substituteInPlace src/3rdparty/chromium/base/mac/mach_port_rendezvous.cc \
--replace "audit_token_to_pid(request.trailer.msgh_audit)" "request.trailer.msgh_audit.val[5]"
substituteInPlace src/3rdparty/chromium/third_party/crashpad/crashpad/util/mach/mach_message.cc \
--replace "audit_token_to_pid(audit_trailer->msgh_audit)" "audit_trailer->msgh_audit.val[5]"

# ld: warning: directory not found for option '-L/nix/store/...-xcodebuild-0.1.2-pre/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib'
# ld: fatal warning(s) induced error (-fatal_warnings)
substituteInPlace src/3rdparty/chromium/build/config/compiler/BUILD.gn \
--replace "-Wl,-fatal_warnings" ""

# Use system ffmpeg
echo "gn_args += use_system_ffmpeg=true" >> src/core/config/mac_osx.pri
echo "LIBS += -lavformat -lavcodec -lavutil" >> src/core/core_common.pri
Expand Down Expand Up @@ -257,40 +238,10 @@ qtModule ({

# FIXME These dependencies shouldn't be needed but can't find a way
# around it. Chromium pulls this in while bootstrapping GN.
++ lib.optionals stdenv.hostPlatform.isDarwin [
libobjc
cctools

# frameworks
ApplicationServices
AVFoundation
Foundation
ForceFeedback
GameController
AppKit
ImageCaptureCore
CoreBluetooth
IOBluetooth
CoreWLAN
Quartz
Cocoa
LocalAuthentication
MediaPlayer
MediaAccessibility
SecurityInterface
Vision
CoreML
OpenDirectory
Accelerate

openbsm
libunwind
];
++ lib.optionals stdenv.hostPlatform.isDarwin [ cctools.libtool ];
Comment on lines 239 to +241
Copy link
Member

Choose a reason for hiding this comment

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

This comment seems probably inaccurate now? Though I don’t really know what it meant to begin with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m seeing if I can drop it now that xcbuild includes xcrun. I also tried dropping the patches as suggested above.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I meant this comment that I don’t really understand:

  # FIXME These dependencies shouldn't be needed but can't find a way
  # around it. Chromium pulls this in while bootstrapping GN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m seeing if I can go one step further and delete the whole thing. If not, I’ll drop or change the comment.

Copy link
Contributor Author

@reckenrode reckenrode Oct 8, 2024

Choose a reason for hiding this comment

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

Nope. Deleting those would be non-trivial. It requires replacing the qtbase mkspecs patches with different patches to use xcbuild. If someone wants to do that later, that’s fine; but it’s beyond the scope of what I want to do with this PR (which is clean things up and use the new SDK).


buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
cups
Copy link
Member

Choose a reason for hiding this comment

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

(I wonder if it just needs the headers?)

Copy link
Contributor Author

@reckenrode reckenrode Oct 8, 2024

Choose a reason for hiding this comment

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

For CUPS? CUPS headers are propagated by the SDK now. I wonder if Chromium is detecting CUPS support due to that.

libpm
sandbox

# `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py`
# to get some information about the host platform.
Expand Down
4 changes: 1 addition & 3 deletions pkgs/development/libraries/qt-5/modules/qtwebkit.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
, fontconfig, libwebp, libxml2, libxslt
, sqlite, systemd, glib, gst_all_1, cmake
, bison, flex, gdb, gperf, perl, pkg-config, python3, ruby
, ICU, OpenGL
}:

let
Expand All @@ -24,8 +23,7 @@ qtModule {
pname = "qtwebkit";
propagatedBuildInputs = [ qtbase qtdeclarative qtlocation qtsensors qtwebchannel ]
++ lib.optional stdenv.hostPlatform.isDarwin qtmultimedia;
buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ ICU OpenGL ];
buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen ];
nativeBuildInputs = [ bison flex gdb gperf perl pkg-config python3 ruby cmake ];

cmakeFlags = [ "-DPORT=Qt" ]
Expand Down
6 changes: 1 addition & 5 deletions pkgs/development/libraries/qt-5/modules/qtwebview.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{ lib, stdenv, qtModule, qtdeclarative, qtwebengine, CoreFoundation, WebKit }:
{ lib, stdenv, qtModule, qtdeclarative, qtwebengine }:

qtModule {
pname = "qtwebview";
propagatedBuildInputs = [ qtdeclarative qtwebengine ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
CoreFoundation
WebKit
];
outputs = [ "out" "dev" "bin" ];
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework CoreFoundation -framework WebKit";
}
7 changes: 7 additions & 0 deletions pkgs/development/libraries/qt-5/qtModule.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
, stdenv
, buildPackages
, mkDerivation
, apple-sdk_14
, apple-sdk_for_qt ? apple-sdk_14
, perl
, qmake
, patches
Expand All @@ -23,6 +25,11 @@ mkDerivation (args // {
inherit pname version src;
patches = (args.patches or []) ++ (patches.${pname} or []);

buildInputs =
args.buildInputs or [ ]
# Per https://doc.qt.io/qt-5/macos.html#supported-versions
++ lib.optionals stdenv.isDarwin [ apple-sdk_for_qt ];

nativeBuildInputs =
(args.nativeBuildInputs or []) ++ [
perl qmake
Expand Down
Loading