From af397f4a337dcdea43583ab12ef31c0fcdbdcb31 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Tue, 31 Dec 2024 20:11:07 +0800 Subject: [PATCH 1/2] qt6.qtwebengine: make the `AppleClang` substitution unconditional So we won't break darwin build if the package is updated --- .../libraries/qt-6/modules/qtwebengine/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix b/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix index 1a7da3ed6c674..7fee7eb7866de 100644 --- a/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix +++ b/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix @@ -148,6 +148,9 @@ qtModule { --replace "QLibraryInfo::path(QLibraryInfo::DataPath)" "\"$out\"" \ --replace "QLibraryInfo::path(QLibraryInfo::TranslationsPath)" "\"$out/translations\"" \ --replace "QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)" "\"$out/libexec\"" + + substituteInPlace configure.cmake src/gn/CMakeLists.txt \ + --replace "AppleClang" "Clang" '' + lib.optionalString stdenv.hostPlatform.isLinux '' sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \ @@ -157,8 +160,6 @@ qtModule { src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc '' + lib.optionalString stdenv.hostPlatform.isDarwin '' - substituteInPlace configure.cmake src/gn/CMakeLists.txt \ - --replace "AppleClang" "Clang" substituteInPlace cmake/Functions.cmake \ --replace "/usr/bin/xcrun" "${xcbuild}/bin/xcrun" ''; From 85c1c3ca3f214ee465a63bd6a5a41a7a9ebe191b Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Tue, 31 Dec 2024 20:26:40 +0800 Subject: [PATCH 2/2] qt6.qtwebengine: fix build on darwin - Disable metal shader compilation - Apply upstream zutil.h patch that fixes clang 18 and later - Apply upstream libpng patch that fixes clang 18 and later - Drop `autoSignDarwinBinariesHook` on aarch64-darwin, no longer necessary --- pkgs/development/libraries/qt-6/default.nix | 2 +- .../qt-6/modules/qtwebengine/default.nix | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/qt-6/default.nix b/pkgs/development/libraries/qt-6/default.nix index a8bf9eb6a3d15..26c79f489f6fa 100644 --- a/pkgs/development/libraries/qt-6/default.nix +++ b/pkgs/development/libraries/qt-6/default.nix @@ -163,7 +163,7 @@ let qtwayland = callPackage ./modules/qtwayland.nix { }; qtwebchannel = callPackage ./modules/qtwebchannel.nix { }; qtwebengine = callPackage ./modules/qtwebengine { - inherit (darwin) autoSignDarwinBinariesHook bootstrap_cmds; + inherit (darwin) bootstrap_cmds; }; qtwebsockets = callPackage ./modules/qtwebsockets.nix { }; qtwebview = callPackage ./modules/qtwebview.nix { }; diff --git a/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix b/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix index 7fee7eb7866de..d58cb993f9127 100644 --- a/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix +++ b/pkgs/development/libraries/qt-6/modules/qtwebengine/default.nix @@ -62,7 +62,6 @@ libgbm, enableProprietaryCodecs ? true, # darwin - autoSignDarwinBinariesHook, bootstrap_cmds, cctools, xcbuild, @@ -85,9 +84,6 @@ qtModule { gn nodejs ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ - autoSignDarwinBinariesHook - ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ bootstrap_cmds cctools @@ -124,6 +120,24 @@ qtModule { extraPrefix = "src/3rdparty/chromium/third_party/xnnpack/src/"; hash = "sha256-GUESVNR88I1K2V5xr0e09ec4j2eselMhNN06+PCcINM="; }) + + # The latest version of Clang changed what macros it predefines on Apple + # targets, causing errors about predefined macros in zlib. + (fetchpatch { + url = "https://github.com/chromium/chromium/commit/2f39ac8d0a414dd65c0e1d5aae38c8f97aa06ae9.patch"; + stripLen = 1; + extraPrefix = "src/3rdparty/chromium/"; + hash = "sha256-07hWANY9JGFmqvjdOD6SFmVI6sQRRyvW+7wxGZF5GVo="; + }) + + # The latest version of Clang changed what macros it predefines on Apple + # targets, causing errors about predefined macros in libpng. + (fetchpatch { + url = "https://github.com/chromium/chromium/commit/66defc14abe47c0494da9faebebfa0a5b6efcf38.patch"; + stripLen = 1; + extraPrefix = "src/3rdparty/chromium/"; + hash = "sha256-FWIi1VsBZFqOoPIkPxPkcfexPkx1458rB5ldtA7T2uE="; + }) ]; postPatch = @@ -151,6 +165,10 @@ qtModule { substituteInPlace configure.cmake src/gn/CMakeLists.txt \ --replace "AppleClang" "Clang" + + # Disable metal shader compilation, Xcode only + substituteInPlace src/3rdparty/chromium/third_party/angle/src/libANGLE/renderer/metal/metal_backend.gni \ + --replace-fail 'angle_has_build && !is_ios && target_os == host_os' "false" '' + lib.optionalString stdenv.hostPlatform.isLinux '' sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \