From 6d53085a0c97159fc33afdb87c4575ebe2177c78 Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:25 +0000 Subject: [PATCH 01/21] distccMasquerade: add ar --- pkgs/development/tools/misc/distcc/masq.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/development/tools/misc/distcc/masq.nix b/pkgs/development/tools/misc/distcc/masq.nix index 27840481a1091..8753d9c8b800d 100644 --- a/pkgs/development/tools/misc/distcc/masq.nix +++ b/pkgs/development/tools/misc/distcc/masq.nix @@ -37,6 +37,14 @@ stdenv.mkDerivation { ln -sf $bbin/*-as $out/bin/as done fi + + if [ -f $bbin/ar ]; then + ln -s $bbin/ar $out/bin + else + for a in $bbin/*-ar; do + ln -sf $bbin/*-ar $out/bin/ar + done + fi ''; meta = { From 964550b8013ceb5cf50d05c3c4065703bdcd9be4 Mon Sep 17 00:00:00 2001 From: eryngion Date: Wed, 10 Jan 2024 03:38:14 +0300 Subject: [PATCH 02/21] Revert "nixos/no-x-libs: build qtbase without qt translation" Not sure what was the problem here, but as of next commit qtbase successfully builds with `environment.noXlibs = true` and qttranslations. This reverts commit 2e14d8ba72b07047d1dda0ed8161956fba34ee0a. --- nixos/modules/config/no-x-libs.nix | 2 +- pkgs/development/libraries/qt-5/modules/qtbase.nix | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/nixos/modules/config/no-x-libs.nix b/nixos/modules/config/no-x-libs.nix index 87b6fea92ba4a..9e5b5c86dcb8b 100644 --- a/nixos/modules/config/no-x-libs.nix +++ b/nixos/modules/config/no-x-libs.nix @@ -83,7 +83,7 @@ with lib; qemu = super.qemu.override { gtkSupport = false; spiceSupport = false; sdlSupport = false; }; qrencode = super.qrencode.overrideAttrs (_: { doCheck = false; }); qt5 = super.qt5.overrideScope (const (super': { - qtbase = super'.qtbase.override { withGtk3 = false; withQttranslation = false; }; + qtbase = super'.qtbase.override { withGtk3 = false; }; })); stoken = super.stoken.override { withGTK3 = false; }; # translateManpages -> perlPackages.po4a -> texlive-combined-basic -> texlive-core-big -> libX11 diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 594489a0d7505..67e9bd5440d11 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -15,7 +15,7 @@ # optional dependencies , cups ? null, postgresql ? null , withGtk3 ? false, dconf, gtk3 -, withQttranslation ? true, qttranslations ? null +, qttranslations ? null # options , libGLSupported ? !stdenv.isDarwin @@ -351,8 +351,7 @@ stdenv.mkDerivation (finalAttrs: ({ ] ++ lib.optionals (mysqlSupport) [ "-L" "${libmysqlclient}/lib" "-I" "${libmysqlclient}/include" - ] ++ lib.optional (withQttranslation && (qttranslations != null)) [ - # depends on x11 + ] ++ lib.optional (qttranslations != null) [ "-translationdir" "${qttranslations}/translations" ] ); From d81dd55022b67db25462a742297b85034ded0c96 Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 7 Dec 2023 03:23:02 +0300 Subject: [PATCH 03/21] qt5: rework bootstrapping Add to qtbase support for building a small bootstrap package. Move qmake and other tools from qtbase.dev to qtbase.qmake to avoid pulling in a second version of qtbase.dev in cross builds. Use hidden bootstrap packages for qtbase and qttools instead of overrideScope-based staging process to solve some spurious builds and infinite recursions. This commit by itself will allow to cross compile only qttranslations and qtbase. --- .../libraries/qt-5/5.15/default.nix | 29 ++- .../libraries/qt-5/modules/qtbase.nix | 167 ++++++++++++------ .../libraries/qt-5/modules/qttools.nix | 3 + .../libraries/qt-5/modules/qttranslations.nix | 15 +- pkgs/development/libraries/qt-5/qtModule.nix | 7 +- pkgs/top-level/all-packages.nix | 2 +- 6 files changed, 138 insertions(+), 85 deletions(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index a8885fc5647bc..c9817b4d26d26 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -13,6 +13,7 @@ Check for any minor version changes. , gstreamer, gst-plugins-base, gtk3, dconf , llvmPackages_15, overrideSDK, overrideLibcxx , darwin +, buildPackages # options , developerBuild ? false @@ -241,7 +242,12 @@ let (callPackage ../mkDerivation.nix { wrapQtAppsHook = null; }) stdenv.mkDerivation; }; - callPackage = self.newScope { inherit qtCompatVersion qtModule srcs stdenv; }; + qtbase-bootstrap = buildPackages.qt5.qtbase.override { bootstrapBuild = true; }; + # qtbase won't be spliced here, but that's fine as it's only a buildInput + qttools-bootstrap = buildPackages.qt5.qttools.override { qtbase=qtbase-bootstrap; qtdeclarative = null; }; + + # ↓Things available only to packages in the scope↓ + callPackage = self.newScope { inherit qtbase-bootstrap qttools-bootstrap stdenv; }; in { inherit callPackage qtCompatVersion qtModule srcs; @@ -357,11 +363,9 @@ let ] ++ lib.optional (!stdenv.isDarwin) qtwayland ++ lib.optional (stdenv.isDarwin) qtmacextras); - qmake = callPackage ({ qtbase }: makeSetupHook { + qmake = callPackage ({ qtbase-bootstrap }: makeSetupHook { name = "qmake-hook"; - ${if stdenv.buildPlatform == stdenv.hostPlatform - then "propagatedBuildInputs" - else "depsTargetTargetPropagated"} = [ qtbase.dev ]; + propagatedBuildInputs = [ qtbase-bootstrap.qmake ]; substitutions = { inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; @@ -375,22 +379,9 @@ let } ../hooks/wrap-qt-apps-hook.sh) { }; }; - baseScope = makeScopeWithSplicing' { + finalScope = makeScopeWithSplicing' { otherSplices = generateSplicesForMkScope "qt5"; f = addPackages; }; - bootstrapScope = baseScope.overrideScope(final: prev: { - qtbase = prev.qtbase.override { qttranslations = null; }; - qtdeclarative = null; - }); - - finalScope = baseScope.overrideScope(final: prev: { - # qttranslations causes eval-time infinite recursion when - # cross-compiling; disabled for now. - qttranslations = - if stdenv.buildPlatform == stdenv.hostPlatform - then bootstrapScope.qttranslations - else null; - }); in finalScope diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 67e9bd5440d11..635e586e0d4dc 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -27,6 +27,7 @@ , buildTests ? false , debug ? false , developerBuild ? false +, bootstrapBuild ? false , decryptSslTraffic ? false , testers , buildPackages @@ -105,7 +106,7 @@ stdenv.mkDerivation (finalAttrs: ({ enableParallelBuilding = true; - outputs = [ "bin" "dev" "out" ]; + outputs = [ "bin" "dev" "out" "qmake" ]; inherit patches; @@ -135,6 +136,10 @@ stdenv.mkDerivation (finalAttrs: ({ sed -i 's/NO_DEFAULT_PATH//' src/gui/Qt5GuiConfigExtras.cmake.in sed -i '/PATHS.*NO_DEFAULT_PATH/ d' mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in + #Always build uic and qvkgen for qtbase-bootstrap + sed -i '/^TOOLS =/ s/$/ src_tools_qvkgen src_tools_uic/' src/src.pro + sed -i '/^SUBDIRS += src_corelib/ s/$/ src_tools_qvkgen src_tools_uic/' src/src.pro + # https://bugs.gentoo.org/803470 sed -i 's/-lpthread/-pthread/' mkspecs/common/linux.conf src/corelib/configure.json @@ -246,58 +251,73 @@ stdenv.mkDerivation (finalAttrs: ({ } // { # TODO Remove obsolete and useless flags once the build will be totally mastered configureFlags = [ - "-plugindir $(out)/$(qtPluginPrefix)" - "-qmldir $(out)/$(qtQmlPrefix)" - "-docdir $(out)/$(qtDocPrefix)" - + # common options for all types of builds "-verbose" "-confirm-license" "-opensource" "-release" "-shared" - "-accessibility" - "-optimized-qmake" # for separateDebugInfo "-no-strip" - "-system-proxies" "-pkg-config" - "-gui" - "-widgets" - "-opengl desktop" + "-make tools" + ''-${lib.optionalString (!buildExamples || bootstrapBuild) "no"}make examples'' + ''-${lib.optionalString (!buildTests) "no"}make tests'' + "-icu" "-L" "${icu.out}/lib" "-I" "${icu.dev}/include" "-pch" - ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ - "-device ${qtPlatformCross stdenv.hostPlatform}" - "-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}" - ] - ++ lib.optional debugSymbols "-debug" - ++ lib.optionals developerBuild [ - "-developer-build" - "-no-warnings-are-errors" - ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - "-no-warnings-are-errors" - ] ++ (if (!stdenv.hostPlatform.isx86_64) then [ - "-no-sse2" - ] else [ - "-sse2" - "${lib.optionalString (!stdenv.hostPlatform.sse3Support) "-no"}-sse3" - "${lib.optionalString (!stdenv.hostPlatform.ssse3Support) "-no"}-ssse3" - "${lib.optionalString (!stdenv.hostPlatform.sse4_1Support) "-no"}-sse4.1" - "${lib.optionalString (!stdenv.hostPlatform.sse4_2Support) "-no"}-sse4.2" - "${lib.optionalString (!stdenv.hostPlatform.avxSupport) "-no"}-avx" - "${lib.optionalString (!stdenv.hostPlatform.avx2Support) "-no"}-avx2" - ] - ) ++ [ - "-no-mips_dsp" - "-no-mips_dspr2" - ] ++ [ "-system-zlib" "-L" "${zlib.out}/lib" "-I" "${zlib.dev}/include" + + ] ++ (if stdenv.isDarwin then [ + "-no-fontconfig" + "-no-framework" + ] else [ + "-rpath" + + # a bare bones build only to get build tools and mkspecs + ]) ++ (if bootstrapBuild then [ + # We probably can go slimmer than this with some patching and/or selective run of Makefiles + # but this is already good enough. + "-no-gui" + "-no-widgets" + "-no-feature-sqlmodel" + "-no-sql-sqlite" + "-no-feature-bearermanagement" + "-no-feature-netlistmgr" + "-no-feature-networkdiskcache" + "-no-feature-networkinterface" + "-no-feature-networkproxy" + "-no-feature-concurrent" + "-no-feature-dnslookup" + "-no-feature-dtls" + "-no-feature-ftp" + "-no-feature-http" + "-no-feature-gssapi" + "-no-feature-localserver" + "-no-feature-ocsp" + "-no-feature-socks5" + "-no-feature-sspi" + "-no-feature-udpsocket" + + # regular build, platform-independent options + ] else ([ + "-gui" + "-widgets" + "-opengl desktop" + "-accessibility" + "-system-proxies" + "-make libs" + + "-plugindir $(out)/$(qtPluginPrefix)" + "-qmldir $(out)/$(qtQmlPrefix)" + "-docdir $(out)/$(qtDocPrefix)" + "-system-libjpeg" "-L" "${libjpeg.out}/lib" "-I" "${libjpeg.dev}/include" @@ -312,20 +332,13 @@ stdenv.mkDerivation (finalAttrs: ({ ''-${if mysqlSupport then "plugin" else "no"}-sql-mysql'' ''-${if postgresql != null then "plugin" else "no"}-sql-psql'' - "-make libs" - "-make tools" - ''-${lib.optionalString (!buildExamples) "no"}make examples'' - ''-${lib.optionalString (!buildTests) "no"}make tests'' - ] - ++ ( - if stdenv.isDarwin then [ - "-no-fontconfig" + # regular build, Darwin options + ] ++ (if stdenv.isDarwin then [ "-qt-freetype" "-qt-libpng" - "-no-framework" + + # regular build, other Unixes options ] else [ - "-rpath" - ] ++ [ "-xcb" "-qpa xcb" "-L" "${libX11.out}/lib" @@ -340,25 +353,71 @@ stdenv.mkDerivation (finalAttrs: ({ ''-${lib.optionalString (cups == null) "no-"}cups'' "-dbus-linked" "-glib" - ] ++ [ + "-system-libpng" + "-inotify" + ] ++ lib.optional withGtk3 "-gtk" - ++ [ - "-inotify" - ] ++ lib.optionals (cups != null) [ + ++ lib.optionals (cups != null) [ "-L" "${cups.lib}/lib" "-I" "${cups.dev}/include" + ] ++ lib.optionals (mysqlSupport) [ "-L" "${libmysqlclient}/lib" "-I" "${libmysqlclient}/include" + ] ++ lib.optional (qttranslations != null) [ "-translationdir" "${qttranslations}/translations" ] - ); + + # cross compilation options + ))) ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "-device ${qtPlatformCross stdenv.hostPlatform}" + "-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}" + ] + + # debugging options + ++ lib.optional debugSymbols "-debug" + ++ lib.optionals developerBuild [ + "-developer-build" + "-no-warnings-are-errors" + + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-no-warnings-are-errors" + + # CPU features support + ] ++ (if (!stdenv.hostPlatform.isx86_64) then [ + "-no-sse2" + ] else [ + "-sse2" + "${lib.optionalString (!stdenv.hostPlatform.sse3Support) "-no"}-sse3" + "${lib.optionalString (!stdenv.hostPlatform.ssse3Support) "-no"}-ssse3" + "${lib.optionalString (!stdenv.hostPlatform.sse4_1Support) "-no"}-sse4.1" + "${lib.optionalString (!stdenv.hostPlatform.sse4_2Support) "-no"}-sse4.2" + "${lib.optionalString (!stdenv.hostPlatform.avxSupport) "-no"}-avx" + "${lib.optionalString (!stdenv.hostPlatform.avx2Support) "-no"}-avx2" + ] + ) ++ [ + "-no-mips_dsp" + "-no-mips_dspr2" + ]; # Move selected outputs. + # I don't want to patch moveQtDevTools to support qmake output, so here's a bit of moving binaries around postInstall = '' moveToOutput "mkspecs" "$dev" + + # Move development tools to $dev and update paths to them in mkspecs + moveQtDevTools + + # Move all binaries to $qmake + mkdir -p "$qmake/bin" + mv "$dev"/bin/* "$qmake/bin/" + moveToOutput "bin" "$qmake" + + # Symlinks from $dev to $qmake for backward compatibility + mkdir -p "$dev/bin" + lndir "$qmake/bin" "$dev/bin" ''; devTools = [ @@ -379,10 +438,6 @@ stdenv.mkDerivation (finalAttrs: ({ fixQtModulePaths "''${!outputDev}/mkspecs/modules" fixQtBuiltinPaths "''${!outputDev}" '*.pr?' - # Move development tools to $dev - moveQtDevTools - moveToOutput bin "$dev" - # fixup .pc file (where to find 'moc' etc.) sed -i "$dev/lib/pkgconfig/Qt5Core.pc" \ -e "/^host_bins=/ c host_bins=$dev/bin" diff --git a/pkgs/development/libraries/qt-5/modules/qttools.nix b/pkgs/development/libraries/qt-5/modules/qttools.nix index 37e4348ed2c23..0885dfeefa353 100644 --- a/pkgs/development/libraries/qt-5/modules/qttools.nix +++ b/pkgs/development/libraries/qt-5/modules/qttools.nix @@ -13,6 +13,9 @@ qtModule { -e '/^cmake_qattributionsscanner_config_version_file.input =/ s|$$\[QT_HOST_DATA.*\]|${lib.getDev qtbase}|' ''; + # Bootstrap build produces no out, and that makes nix unhappy and results in an unannotated failure for remote builds. + postFixup = ''[ -e $out ] || mkdir $out''; + devTools = [ "bin/qcollectiongenerator" "bin/linguist" diff --git a/pkgs/development/libraries/qt-5/modules/qttranslations.nix b/pkgs/development/libraries/qt-5/modules/qttranslations.nix index bcd52cdc4a8f6..70a2520e290f5 100644 --- a/pkgs/development/libraries/qt-5/modules/qttranslations.nix +++ b/pkgs/development/libraries/qt-5/modules/qttranslations.nix @@ -1,7 +1,16 @@ -{ qtModule, qttools }: +{ qtModule, stdenv, qtbase-bootstrap, qttools-bootstrap, buildPackages }: -qtModule { +# I don't want to bother with cross compilation support for qttranslations +# as the outputs are identical with a native-built one. It will require a small +# fiddling with a native-built qtbase-bootstrap in buildInputs (it is there only +# for a few configs in mkspecs) or an additional individual build of qtbase/mkspecs +# just for the sake of this package. There's really just no point in it. +if stdenv.hostPlatform != stdenv.buildPlatform +then buildPackages.qt5.qttranslations + +else qtModule { pname = "qttranslations"; - nativeBuildInputs = [ qttools ]; + buildInputs = [ qtbase-bootstrap.dev ]; + nativeBuildInputs = [ qttools-bootstrap ]; outputs = [ "out" ]; } diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 54d24e46092f2..5fe895f85549e 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -23,12 +23,7 @@ mkDerivation (args // { inherit pname version src; patches = (args.patches or []) ++ (patches.${pname} or []); - nativeBuildInputs = - (args.nativeBuildInputs or []) ++ [ - perl qmake - ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - pkgsHostTarget.qt5.qtbase.dev - ]; + nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ perl qmake ]; propagatedBuildInputs = (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or []) ++ (args.propagatedBuildInputs or []); diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f798e32202bd4..f56bbb4bfd7f5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23945,7 +23945,7 @@ with pkgs; makeScopeWithSplicing' generateSplicesForMkScope lib fetchurl fetchpatch fetchgit fetchFromGitHub makeSetupHook makeWrapper bison cups dconf harfbuzz libGL perl gtk3 python3 llvmPackages_15 overrideSDK overrideLibcxx - darwin; + darwin buildPackages; inherit (__splicedPackages.gst_all_1) gstreamer gst-plugins-base; inherit config; stdenv = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv; From f7a55764ff3877855e4611a97ef3599ca48070c8 Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 7 Dec 2023 03:44:43 +0300 Subject: [PATCH 04/21] qt5.qtbase: always build all packaged binaries for the hostPlatform Also teach the setup hook, qmake and cmake scripts to search various build tools in PATH and use them for cross compilation. This will allow to cross compile packages that require only qtbase and qmake. --- .../libraries/qt-5/5.15/default.nix | 1 + .../0015-qtbase-cross-build.patch | 197 ++++++++++++++++++ .../libraries/qt-5/hooks/qtbase-setup-hook.sh | 15 +- .../libraries/qt-5/modules/qtbase.nix | 78 ++++--- pkgs/development/libraries/qt-5/qtModule.nix | 5 - 5 files changed, 260 insertions(+), 36 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0015-qtbase-cross-build.patch diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index c9817b4d26d26..f13a056de0bda 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -47,6 +47,7 @@ let ./qtbase.patch.d/0009-qtbase-qtpluginpath.patch ./qtbase.patch.d/0010-qtbase-assert.patch ./qtbase.patch.d/0011-fix-header_module.patch + ./qtbase.patch.d/0015-qtbase-cross-build.patch ]; qtdeclarative = [ ./qtdeclarative.patch diff --git a/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0015-qtbase-cross-build.patch b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0015-qtbase-cross-build.patch new file mode 100644 index 0000000000000..644ddc6d9ea1c --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0015-qtbase-cross-build.patch @@ -0,0 +1,197 @@ +diff --git a/mkspecs/features/device_config.prf b/mkspecs/features/device_config.prf +index c15559e174..023a4bcb35 100644 +--- a/mkspecs/features/device_config.prf ++++ b/mkspecs/features/device_config.prf +@@ -1,9 +1,5 @@ + # This file is loaded by some qmakespecs to get early configuration data. + +-# Some of these qmakespecs can be used also in host mode, but they are not +-# supposed to be influenced by -device-option then. +-host_build: return() +- + DEVICE_PRI = $$[QT_HOST_DATA/get]/mkspecs/qdevice.pri + exists($$DEVICE_PRI):include($$DEVICE_PRI) + unset(DEVICE_PRI) +diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf +index 511b158b91..70d1e10611 100644 +--- a/mkspecs/features/qt_build_config.prf ++++ b/mkspecs/features/qt_build_config.prf +@@ -15,6 +15,13 @@ + debug(1, "Cannot load qmodule.pri!") + } else { + debug(1, "Loaded qmodule.pri from ($$QMAKE_QT_MODULE)") ++ ++ # Yeah, there are multiple pkg-config related varialbes and functions ++ # that are used throughout QT modules somewhat interchangeably. ++ # As we're now trying to build all packaged binaries for the hostPlatform ++ # only, let's not create even more confusion and just follow a simple rule: ++ # always get pkg-config from the PKG_CONFIG env variable. ++ PKG_CONFIG_EXECUTABLE = $$(PKG_CONFIG) + } + } else { + debug(1, "Not loading qmodule.pri twice") +diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf +index 6537d98c5d..19ed05db61 100644 +--- a/mkspecs/features/qt_configure.prf ++++ b/mkspecs/features/qt_configure.prf +@@ -423,16 +423,7 @@ defineReplace(qtConfPkgConfigEnv) { + } + + defineReplace(qtConfPkgConfig) { +- host = $$1 +- isEmpty(host): host = false +- +- $$host { +- pkg_config = $$qtConfFindInPath("pkg-config") +- } else { +- pkg_config = "$$qtConfPkgConfigEnv()$$PKG_CONFIG_EXECUTABLE" +- } +- +- return($$pkg_config) ++ return($$getenv("PKG_CONFIG")) + } + + defineTest(qtConfPkgConfigPackageExists) { +diff --git a/mkspecs/features/qt_tool.prf b/mkspecs/features/qt_tool.prf +index a8d589f0fa..3d0f832a6b 100644 +--- a/mkspecs/features/qt_tool.prf ++++ b/mkspecs/features/qt_tool.prf +@@ -18,7 +18,7 @@ DEFINES *= QT_USE_QSTRINGBUILDER + # If we are doing a prefix build, create a "module" pri which enables + # qtPrepareTool() to work with the non-installed build. + # Non-bootstrapped tools always need this because of the environment setup. +-!build_pass:if(!host_build|!force_bootstrap|force_independent|!isEmpty(HOST_QT_TOOLS)) { ++!build_pass:if(!host_build|!force_bootstrap|force_independent|cross_compile) { + isEmpty(MODULE):MODULE = $$TARGET + + load(qt_build_paths) +@@ -27,7 +27,7 @@ DEFINES *= QT_USE_QSTRINGBUILDER + + vars = binary depends + +- !host_build|isEmpty(HOST_QT_TOOLS) { ++ !host_build|!cross_compile { + load(resolve_target) + + !host_build|!force_bootstrap: MODULE_DEPENDS = $$replace(QT, -private$, _private) +@@ -55,6 +55,10 @@ DEFINES *= QT_USE_QSTRINGBUILDER + bin = $${HOST_QT_TOOLS}/$${TARGET} + equals(QMAKE_HOST.os, Windows): bin = $${bin}.exe + bin = $$system_path($$bin) ++ !exists($$bin) { ++ # search in PATH as a fallback ++ bin = $$system("command -v $${TARGET}") ++ } + } + + TOOL_PRI_CONT = \ +diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in +index be07a2e1e8..0b9c425ec8 100644 +--- a/src/corelib/Qt5CoreConfigExtras.cmake.in ++++ b/src/corelib/Qt5CoreConfigExtras.cmake.in +@@ -5,30 +5,20 @@ endif() + if (NOT TARGET Qt5::qmake) + add_executable(Qt5::qmake IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}qmake$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Core_check_file_exists(${imported_location}) ++ find_program(qmake_imported_location \"qmake$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qmake PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qmake_imported_location} + ) + endif() + + if (NOT TARGET Qt5::moc) + add_executable(Qt5::moc IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}moc$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Core_check_file_exists(${imported_location}) ++ find_program(moc_imported_location \"moc$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::moc PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${moc_imported_location} + ) + # For CMake automoc feature + get_target_property(QT_MOC_EXECUTABLE Qt5::moc LOCATION) +@@ -37,15 +27,10 @@ endif() + if (NOT TARGET Qt5::rcc) + add_executable(Qt5::rcc IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}rcc$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Core_check_file_exists(${imported_location}) ++ find_program(rcc_imported_location \"rcc$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::rcc PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${rcc_imported_location} + ) + endif() + +diff --git a/src/dbus/Qt5DBusConfigExtras.cmake.in b/src/dbus/Qt5DBusConfigExtras.cmake.in +index b13b964ec8..f4b7109037 100644 +--- a/src/dbus/Qt5DBusConfigExtras.cmake.in ++++ b/src/dbus/Qt5DBusConfigExtras.cmake.in +@@ -2,22 +2,20 @@ + if (NOT TARGET Qt5::qdbuscpp2xml) + add_executable(Qt5::qdbuscpp2xml IMPORTED) + +- set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbuscpp2xml$$CMAKE_BIN_SUFFIX\") +- _qt5_DBus_check_file_exists(${imported_location}) ++ find_program(qdbuscpp2xml_imported_location \"qdbuscpp2xml$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qdbuscpp2xml PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qdbuscpp2xml_imported_location} + ) + endif() + + if (NOT TARGET Qt5::qdbusxml2cpp) + add_executable(Qt5::qdbusxml2cpp IMPORTED) + +- set(imported_location \"$$NIX_OUTPUT_DEV/bin/qdbusxml2cpp$$CMAKE_BIN_SUFFIX\") +- _qt5_DBus_check_file_exists(${imported_location}) ++ find_program(qdbusxml2cpp_imported_location \"qdbusxml2cpp$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qdbusxml2cpp PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qdbusxml2cpp_imported_location} + ) + endif() + +diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in +index ca0b8e4bfb..f49f09fed2 100644 +--- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in ++++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in +@@ -2,15 +2,10 @@ + if (NOT TARGET Qt5::uic) + add_executable(Qt5::uic IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"$$NIX_OUTPUT_DEV/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Widgets_check_file_exists(${imported_location}) ++ find_program(uic_imported_location \"uic$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::uic PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${uic_imported_location} + ) + endif() + diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 1b57d676e1fc5..76407ba6f5679 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -30,12 +30,25 @@ else cmakeBuildType="Release" fi +if [[ -n "@qtPlatformCross@" ]]; then + # When cross compiling we're using a native-built qmake binary and + # it will need a little help finding the target of cross compilation. + + # Enable cross-compilation in qmake + export "XQMAKESPEC=devices/@qtPlatformCross@" + # Use the same config for tools marked with host_build + export "QMAKESPEC=$XQMAKESPEC" +fi + providesQtRuntime() { [ -d "$1/$qtPluginPrefix" ] || [ -d "$1/$qtQmlPrefix" ] } +if ! QMAKE="$(PATH="$_PATH" command -v qmake)"; then + echo "FYI: can't find a runnable qmake in PATH. If nothing breaks than it's perfectly fine." + echo "Otherwise you should add qmake or qtbase.qmake to nativeBuildInputs." +fi # Build tools are often confused if QMAKE is unset. -QMAKE=@dev@/bin/qmake export QMAKE QMAKEPATH= diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 635e586e0d4dc..3a6ab3d475200 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -2,7 +2,7 @@ , src, patches, version, qtCompatVersion , coreutils, bison, flex, gdb, gperf, lndir, perl, pkg-config, python3 -, which +, which, distccMasquerade, qtbase-bootstrap # darwin support , libiconv, libobjc, xcbuild, AGL, AppKit, ApplicationServices, AVFoundation, Carbon, Cocoa, CoreAudio, CoreBluetooth , CoreLocation, CoreServices, DiskArbitration, Foundation, OpenGL, MetalKit, IOKit @@ -30,11 +30,11 @@ , bootstrapBuild ? false , decryptSslTraffic ? false , testers -, buildPackages }: let debugSymbols = debug || developerBuild; + isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; qtPlatformCross = plat: with plat; if isLinux then "linux-generic-g++" @@ -75,7 +75,14 @@ stdenv.mkDerivation (finalAttrs: ({ ] ++ lib.optional libGLSupported libGL ); - buildInputs = [ python3 at-spi2-core ] + buildInputs = [ + # We need python3 for hostPlatform to properly patch the shebang of the + # mkspecs/features/uikit/devices.py script that we're publishing. + python3 + # We need perl for hostPlatform to properly patch shebangs of the + # fixqt4headers.pl and syncqt.pl scripts that we're publishing. + perl + at-spi2-core ] ++ lib.optionals (!stdenv.isDarwin) ( [ libinput ] @@ -86,17 +93,22 @@ stdenv.mkDerivation (finalAttrs: ({ ++ lib.optional (mysqlSupport) libmysqlclient ++ lib.optional (postgresql != null) postgresql; - nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which ] - ++ lib.optionals stdenv.isDarwin [ xcbuild ]; - - } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - # `qtbase` expects to find `cc` (with no prefix) in the - # `$PATH`, so the following is needed even if - # `stdenv.buildPlatform.canExecute stdenv.hostPlatform` - depsBuildBuild = [ buildPackages.stdenv.cc ]; - } // { + nativeBuildInputs = [ bison flex gperf perl pkg-config which ] + ++ lib.optionals stdenv.isDarwin [ xcbuild ] + ++ lib.optionals isCrossBuild [ + # `qtbase` expects to find `cc` (with no prefix) in the `$PATH` for qmake and host_build marked projects. + # And we need those to be built for the hostPlatform. So instead of patching configure and mkspeks even + # more I'm just masqurading the prefixed tools. + # I probably should be using the distccMasquerade._spliced.buildHost here, but it works as it is. It's magic! + # Pure wall-of-bash-code-directly-in-derivation-attribute magic! + (distccMasquerade.override {gccRaw=stdenv.cc; binutils=stdenv.cc.bintools;}) + ]; - propagatedNativeBuildInputs = [ lndir ]; + # qtbase needs a runnable qmake and the accompanying tools to build itself, and there are also packages + # out there that use cmake as their main configurator (i.e. don't depend on qmake-the-package) but + # still need qmake&co to be available at build time. In fact, cmake scripts provided by qtbase.dev + # itself look for those tools. + propagatedNativeBuildInputs = [ lndir ] ++ lib.optional isCrossBuild qtbase-bootstrap.qmake; # libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked # against it will crash during build unless they can access `/usr/share/icu/icudtXXl.dat`. @@ -168,6 +180,7 @@ stdenv.mkDerivation (finalAttrs: ({ qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins"; qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml"; qtDocPrefix = "share/doc/qt-${qtCompatVersion}"; + qtPlatformCross = lib.optionalString isCrossBuild (qtPlatformCross stdenv.hostPlatform); setOutputFlags = false; preConfigure = '' @@ -179,13 +192,20 @@ stdenv.mkDerivation (finalAttrs: ({ export MAKEFLAGS+=" -j$NIX_BUILD_CORES" ./bin/syncqt.pl -version $version - '' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - # QT's configure script will refuse to use pkg-config unless these two environment variables are set - export PKG_CONFIG_SYSROOT_DIR=/ - export PKG_CONFIG_LIBDIR=${lib.getLib pkg-config}/lib + + # generate a cross compilation config unconditionally so we can pass a natively-built qtbase + # as a build dependency for a cross build and to avoid specifying CROSS_COMPILE prefix for qmake later + sed -i '1 i CROSS_COMPILE=${stdenv.hostPlatform.config + "-"}' mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf + echo 'QMAKE_PKG_CONFIG=''$''$(PKG_CONFIG)' >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf + + # does this flag propagation really do anything? echo "QMAKE_LFLAGS=''${LDFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf echo "QMAKE_CFLAGS=''${CFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf echo "QMAKE_CXXFLAGS=''${CXXFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf + '' + lib.optionalString isCrossBuild '' + # QT's configure script will refuse to use pkg-config unless these two environment variables are set + export PKG_CONFIG_SYSROOT_DIR=/ + export PKG_CONFIG_LIBDIR=${lib.getLib pkg-config}/lib ''; postConfigure = '' @@ -213,7 +233,6 @@ stdenv.mkDerivation (finalAttrs: ({ env = { NIX_CFLAGS_COMPILE = toString ([ "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields - ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "-Wno-warn=free-nonheap-object" "-Wno-free-nonheap-object" "-w" @@ -231,12 +250,6 @@ stdenv.mkDerivation (finalAttrs: ({ ''-DNIXPKGS_QGTK3_XDG_DATA_DIRS="${gtk3}/share/gsettings-schemas/${gtk3.name}"'' ''-DNIXPKGS_QGTK3_GIO_EXTRA_MODULES="${dconf.lib}/lib/gio/modules"'' ] ++ lib.optional decryptSslTraffic "-DQT_DECRYPT_SSL_TRAFFIC"); - } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - NIX_CFLAGS_COMPILE_FOR_BUILD = toString ([ - "-Wno-warn=free-nonheap-object" - "-Wno-free-nonheap-object" - "-w" - ]); }; prefixKey = "-prefix "; @@ -246,7 +259,7 @@ stdenv.mkDerivation (finalAttrs: ({ # To prevent these failures, we need to override PostgreSQL detection. PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq"; - } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { + } // lib.optionalAttrs isCrossBuild { configurePlatforms = [ ]; } // { # TODO Remove obsolete and useless flags once the build will be totally mastered @@ -371,9 +384,9 @@ stdenv.mkDerivation (finalAttrs: ({ ] # cross compilation options - ))) ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + ))) ++ lib.optionals isCrossBuild [ "-device ${qtPlatformCross stdenv.hostPlatform}" - "-device-option CROSS_COMPILE=${stdenv.cc.targetPrefix}" + "-external-hostbindir ${qtbase-bootstrap.qmake}/bin" ] # debugging options @@ -382,9 +395,6 @@ stdenv.mkDerivation (finalAttrs: ({ "-developer-build" "-no-warnings-are-errors" - ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - "-no-warnings-are-errors" - # CPU features support ] ++ (if (!stdenv.hostPlatform.isx86_64) then [ "-no-sse2" @@ -414,6 +424,9 @@ stdenv.mkDerivation (finalAttrs: ({ mkdir -p "$qmake/bin" mv "$dev"/bin/* "$qmake/bin/" moveToOutput "bin" "$qmake" + patchShebangs --host --update "$qmake" + + patchShebangs --host --update "$dev" # Symlinks from $dev to $qmake for backward compatibility mkdir -p "$dev/bin" @@ -435,6 +448,11 @@ stdenv.mkDerivation (finalAttrs: ({ postFixup = '' # Don't retain build-time dependencies like gdb. sed '/QMAKE_DEFAULT_.*DIRS/ d' -i $dev/mkspecs/qconfig.pri + + # Don't propagate nativeBuildInputs + sed '/HOST_QT_TOOLS/ d' -i $dev/mkspecs/qmodule.pri + sed '/PKG_CONFIG_LIBDIR/ d' -i $dev/mkspecs/qconfig.pri + fixQtModulePaths "''${!outputDev}/mkspecs/modules" fixQtBuiltinPaths "''${!outputDev}" '*.pr?' diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 5fe895f85549e..9e943a5f3aa0e 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -1,12 +1,10 @@ { lib , stdenv -, buildPackages , mkDerivation , perl , qmake , patches , srcs -, pkgsHostTarget }: let inherit (lib) licenses maintainers platforms; in @@ -27,9 +25,6 @@ mkDerivation (args // { propagatedBuildInputs = (lib.warnIf (args ? qtInputs) "qt5.qtModule's qtInputs argument is deprecated" args.qtInputs or []) ++ (args.propagatedBuildInputs or []); -} // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - depsBuildBuild = [ buildPackages.stdenv.cc ] ++ (args.depsBuildBuild or []); -} // { outputs = args.outputs or [ "out" "dev" ]; setOutputFlags = args.setOutputFlags or false; From 3d23b67077a5df1b906cf511821d1cad6bdca25a Mon Sep 17 00:00:00 2001 From: eryngion Date: Wed, 10 Jan 2024 09:49:25 +0300 Subject: [PATCH 05/21] qt5.qtbase: support substituting a cross-built qtbase dependency with a native-built one For this we need to dynamically detect cross compilation in qtbase-setup-hook.sh and in mkspecs, and stop unconditionally using binary lndir in propagatedNativeBuildInputs. For now qtbase substitution will work only in one (most used) direction, and in many cases will additionally require to manually add a buildHost version of qtbase.qmake to nativeBuildInputs of the package that depends on qtbase. --- .../0016-qtbase-cross-build-postFixup.patch | 40 +++++++++++++++++++ .../qt-5/hooks/fix-qt-module-paths.sh | 11 ++++- .../libraries/qt-5/hooks/qtbase-setup-hook.sh | 16 +++++++- .../libraries/qt-5/modules/qtbase.nix | 9 +++-- 4 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch diff --git a/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch new file mode 100644 index 0000000000000..465abaeaff3b7 --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch @@ -0,0 +1,40 @@ +diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf +index 70d1e10611..ce8b9383eb 100644 +--- a/mkspecs/features/qt_build_config.prf ++++ b/mkspecs/features/qt_build_config.prf +@@ -16,6 +16,12 @@ + } else { + debug(1, "Loaded qmodule.pri from ($$QMAKE_QT_MODULE)") + ++ # detect cross compilation status dynamically for the case of ++ # switching cross and natively built qtbase ++ _crossComp = $$(XQMAKESPEC) ++ isEmpty(_crossComp): CONFIG -= cross_compile ++ else: CONFIG += cross_compile ++ + # Yeah, there are multiple pkg-config related varialbes and functions + # that are used throughout QT modules somewhat interchangeably. + # As we're now trying to build all packaged binaries for the hostPlatform +diff --git a/mkspecs/features/qt_config.prf b/mkspecs/features/qt_config.prf +index 93c54e3010..65552276ac 100644 +--- a/mkspecs/features/qt_config.prf ++++ b/mkspecs/features/qt_config.prf +@@ -5,6 +5,18 @@ QMAKE_QT_CONFIG = $$[QT_HOST_DATA/get]/mkspecs/qconfig.pri + debug(1, "Cannot load qconfig.pri!") + } else { + debug(1, "Loaded .qconfig.pri from ($$QMAKE_QT_CONFIG)") ++ ++ # detect cross compilation status dynamically for the case of ++ # switching cross and natively built qtbase ++ _crossComp = $$(XQMAKESPEC) ++ isEmpty(_crossComp) { ++ QT.global.enabled_features -= cross_compile ++ CONFIG -= cross_compile ++ } else { ++ QT.global.enabled_features += cross_compile ++ CONFIG += cross_compile ++ } ++ + dirs = $$(QMAKEMODULES) + QMAKE_MODULE_PATH = $$split(dirs, $$DIRLIST_SEPARATOR) + QMAKE_MODULE_PATH += $$QMAKEMODULES diff --git a/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh b/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh index 33682f6f3c695..f7e3f97865a35 100644 --- a/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh +++ b/pkgs/development/libraries/qt-5/hooks/fix-qt-module-paths.sh @@ -4,6 +4,15 @@ # # Find Qt module definitions in directory _dir_ and patch the module paths. # + +lndir() { + local link_to_dir=$(realpath "$1") + local link_from_dir=$(realpath "$2") + for f in $(ls "$link_to_dir"); do + ln -s "$link_to_dir/$f" "$link_from_dir/$f" + done +} + fixQtModulePaths () { local dir="$1" local bin="${!outputBin}" @@ -30,7 +39,7 @@ fixQtModulePaths () { if [ "z$bin" != "z$dev" ]; then if [ -d "$bin/bin" ]; then mkdir -p "$dev/bin" - lndir -silent "$bin/bin" "$dev/bin" + lndir "$bin/bin" "$dev/bin" fi fi } diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 76407ba6f5679..1aaa810c41e75 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -30,12 +30,24 @@ else cmakeBuildType="Release" fi -if [[ -n "@qtPlatformCross@" ]]; then +isCrossBuild() { + # Check if the tool is prefixed. Will probably break on Windows. + # Maybe we should have a standard variable for this? + [[ -v AS ]] && [[ "${#AS}" -gt 2 ]] +} + +if isCrossBuild; then # When cross compiling we're using a native-built qmake binary and # it will need a little help finding the target of cross compilation. + if [[ "$(uname)" == 'Linux' ]]; then + qtPlatformCross="linux-generic-g++" + else + echo "Please add a qtPlatformCross entry for $(uname)" >&2 + exit 1 + fi # Enable cross-compilation in qmake - export "XQMAKESPEC=devices/@qtPlatformCross@" + export "XQMAKESPEC=devices/$qtPlatformCross" # Use the same config for tools marked with host_build export "QMAKESPEC=$XQMAKESPEC" fi diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 3a6ab3d475200..61bebb155826f 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -1,7 +1,7 @@ { stdenv, lib , src, patches, version, qtCompatVersion -, coreutils, bison, flex, gdb, gperf, lndir, perl, pkg-config, python3 +, coreutils, bison, flex, gdb, gperf, perl, pkg-config, python3 , which, distccMasquerade, qtbase-bootstrap # darwin support , libiconv, libobjc, xcbuild, AGL, AppKit, ApplicationServices, AVFoundation, Carbon, Cocoa, CoreAudio, CoreBluetooth @@ -39,6 +39,7 @@ let if isLinux then "linux-generic-g++" else throw "Please add a qtPlatformCross entry for ${plat.config}"; + postFixupPatch = ../${lib.versions.majorMinor version}/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch; in stdenv.mkDerivation (finalAttrs: ({ @@ -108,7 +109,7 @@ stdenv.mkDerivation (finalAttrs: ({ # out there that use cmake as their main configurator (i.e. don't depend on qmake-the-package) but # still need qmake&co to be available at build time. In fact, cmake scripts provided by qtbase.dev # itself look for those tools. - propagatedNativeBuildInputs = [ lndir ] ++ lib.optional isCrossBuild qtbase-bootstrap.qmake; + propagatedNativeBuildInputs = lib.optional isCrossBuild qtbase-bootstrap.qmake; # libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked # against it will crash during build unless they can access `/usr/share/icu/icudtXXl.dat`. @@ -180,7 +181,6 @@ stdenv.mkDerivation (finalAttrs: ({ qtPluginPrefix = "lib/qt-${qtCompatVersion}/plugins"; qtQmlPrefix = "lib/qt-${qtCompatVersion}/qml"; qtDocPrefix = "share/doc/qt-${qtCompatVersion}"; - qtPlatformCross = lib.optionalString isCrossBuild (qtPlatformCross stdenv.hostPlatform); setOutputFlags = false; preConfigure = '' @@ -453,6 +453,9 @@ stdenv.mkDerivation (finalAttrs: ({ sed '/HOST_QT_TOOLS/ d' -i $dev/mkspecs/qmodule.pri sed '/PKG_CONFIG_LIBDIR/ d' -i $dev/mkspecs/qconfig.pri + # Dynamically detect cross-compilation. This patch breaks the build of qtbase itself, so we need to appy it late. + patch -p1 -d $dev < ${postFixupPatch} + fixQtModulePaths "''${!outputDev}/mkspecs/modules" fixQtBuiltinPaths "''${!outputDev}" '*.pr?' From e26f0de0ecd4ba73b7b0b7c68797f60fa3225e4c Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:26 +0000 Subject: [PATCH 06/21] qt5.full: add disallowedReferences for qmake from buildHost --- pkgs/development/libraries/qt-5/qtModule.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/libraries/qt-5/qtModule.nix b/pkgs/development/libraries/qt-5/qtModule.nix index 9e943a5f3aa0e..c3dd7d696ce03 100644 --- a/pkgs/development/libraries/qt-5/qtModule.nix +++ b/pkgs/development/libraries/qt-5/qtModule.nix @@ -5,6 +5,7 @@ , qmake , patches , srcs +, qtbase-bootstrap }: let inherit (lib) licenses maintainers platforms; in @@ -38,6 +39,7 @@ mkDerivation (args // { ${args.preConfigure or ""} fixQtBuiltinPaths . '*.pr?' + fixQtBuiltinPaths . '*.cmake.in' '' + lib.optionalString (builtins.compareVersions "5.15.0" version <= 0) # Note: We use ${version%%-*} to remove any tag from the end of the version # string. Version tags are added by Nixpkgs maintainers and not reflected in @@ -74,6 +76,8 @@ mkDerivation (args // { ${args.postFixup or ""} ''; + disallowedReferences = (args.disallowedReferences or []) ++ [ qtbase-bootstrap.qmake ]; + meta = { homepage = "https://www.qt.io"; description = "A cross-platform application framework for C++"; From 85a7eed6869adc9b6d294e6ba1984a7a2f907827 Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:26 +0000 Subject: [PATCH 07/21] qt5: fix discovery of QT modules in cross builds Without it qtwebchannel will fail to find some library includes, qtquickcontrols will refuse to build without properly failing the build: ``` Some of the required modules (qtHaveModule(quick)) are not available. Skipped. ``` And there are probably more problems, not always obvious. --- pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 1aaa810c41e75..83a06c63b4b28 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -81,7 +81,7 @@ qmakePathHook() { QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1" fi } -envBuildHostHooks+=(qmakePathHook) +envHostTargetHooks+=(qmakePathHook) # Propagate any runtime dependency of the building package. # Each dependency is propagated to the user environment and as a build From 3a0a27b57dcc59d8de9cfff931db6f61367ce8e7 Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:27 +0000 Subject: [PATCH 08/21] qt5.qtwayland: fix cross compilation and dependencies It needs only qtdeclarative to build, not qtquickcontrols. --- .../libraries/qt-5/modules/qtwayland.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwayland.nix b/pkgs/development/libraries/qt-5/modules/qtwayland.nix index 347a5cf643428..b7c2415bc5f60 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwayland.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwayland.nix @@ -1,10 +1,15 @@ -{ qtModule, qtbase, qtquickcontrols, wayland, wayland-scanner, pkg-config }: +{ qtModule, lib, stdenv, qtbase, qtdeclarative, wayland, wayland-scanner, pkg-config, qtwayland, buildPackages }: + +let + isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; +in qtModule { pname = "qtwayland"; - propagatedBuildInputs = [ qtbase qtquickcontrols ]; - buildInputs = [ wayland ]; - nativeBuildInputs = [ pkg-config wayland-scanner ]; + propagatedBuildInputs = [ qtbase ]; + buildInputs = [ wayland qtdeclarative ]; + nativeBuildInputs = [ pkg-config wayland-scanner ] + ++ lib.optional isCrossBuild qtwayland.bin; outputs = [ "out" "dev" "bin" ]; patches = [ # NixOS-specific, ensure that app_id is correctly determined for @@ -12,4 +17,5 @@ qtModule { # context). ./qtwayland-app_id.patch ]; + disallowedReferences = lib.optional isCrossBuild buildPackages.qt5.qtwayland.bin; } From bef05f68569bf81982f99b6ec227f6d1b0432fc7 Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:27 +0000 Subject: [PATCH 09/21] qt5.qtdeclarative: fix cross for qtdeclarative and some of it's users If you're a nativeBuildInput somewhere, you probably shouldn't propagate qtbase. --- .../libraries/qt-5/5.15/default.nix | 1 + .../qt-5/5.15/qtdeclarative-cross-build.patch | 38 +++++++++++++++++++ .../libraries/qt-5/modules/qtdeclarative.nix | 12 +++++- .../libraries/qt-5/modules/qtdoc.nix | 4 +- .../qt-5/modules/qtgraphicaleffects.nix | 4 +- .../qt-5/modules/qtquickcontrols.nix | 4 +- .../qt-5/modules/qtquickcontrols2.nix | 4 +- .../libraries/qt-5/modules/qtsvg.nix | 2 +- 8 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.15/qtdeclarative-cross-build.patch diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index f13a056de0bda..5a33b226d0a7d 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -55,6 +55,7 @@ let ./qtdeclarative-default-disable-qmlcache.patch # add version specific QML import path ./qtdeclarative-qml-paths.patch + ./qtdeclarative-cross-build.patch ]; qtlocation = lib.optionals stdenv.cc.isClang [ # Fix build with Clang 16 diff --git a/pkgs/development/libraries/qt-5/5.15/qtdeclarative-cross-build.patch b/pkgs/development/libraries/qt-5/5.15/qtdeclarative-cross-build.patch new file mode 100644 index 0000000000000..ca41a9320f02a --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.15/qtdeclarative-cross-build.patch @@ -0,0 +1,38 @@ +diff --git a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in +index 8a91fb8b87..b0f7cac849 100644 +--- a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in ++++ b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake.in +@@ -18,11 +18,8 @@ function(QTQUICK_COMPILER_ADD_RESOURCES outfiles) + + find_package(Qt5 COMPONENTS Qml Core) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(compiler_path \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmlcachegen$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(compiler_path \"$${CMAKE_BIN_DIR}qmlcachegen$$CMAKE_BIN_SUFFIX\") +-!!ENDIF ++ find_program(compiler_path \"qmlcachegen$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) ++ + if(NOT EXISTS \"${compiler_path}\" ) + message(FATAL_ERROR \"The package \\\"Qt5QuickCompilerConfig\\\" references the file + \\\"${compiler_path}\\\" +diff --git a/tools/qmlimportscanner/Qt5QmlImportScannerConfig.cmake.in b/tools/qmlimportscanner/Qt5QmlImportScannerConfig.cmake.in +index f92b8d295d..c85ec4d206 100644 +--- a/tools/qmlimportscanner/Qt5QmlImportScannerConfig.cmake.in ++++ b/tools/qmlimportscanner/Qt5QmlImportScannerConfig.cmake.in +@@ -13,12 +13,9 @@ function(QT5_IMPORT_QML_PLUGINS target) + + # Find location of qmlimportscanner. + find_package(Qt5 COMPONENTS Core) +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(tool_path +- \"${_qt5Core_install_prefix}/$${CMAKE_BIN_DIR}qmlimportscanner$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(tool_path \"$${CMAKE_BIN_DIR}qmlimportscanner$$CMAKE_BIN_SUFFIX\") +-!!ENDIF ++ ++ find_program(tool_path \"qmlimportscanner$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) ++ + if(NOT EXISTS \"${tool_path}\" ) + message(FATAL_ERROR \"The package \\\"Qt5QmlImportScannerConfig\\\" references the file + \\\"${tool_path}\\\" diff --git a/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix index f4249b7f9505a..091abef202704 100644 --- a/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix +++ b/pkgs/development/libraries/qt-5/modules/qtdeclarative.nix @@ -1,11 +1,19 @@ { lib , stdenv -, qtModule, python3, qtbase, qtsvg }: +, qtModule, python3, qtbase, qtsvg, qtdeclarative }: + +let + isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; +in qtModule { pname = "qtdeclarative"; - propagatedBuildInputs = [ qtbase qtsvg ]; + buildInputs = [ qtbase ]; + propagatedBuildInputs = [ qtsvg ]; # Ugh, really? nativeBuildInputs = [ python3 ]; + # We need a runnable qmlcachegen to build qtdeclarative itself, and some dependers + # of this package also expect to get runnable tools with it. + propagatedNativeBuildInputs = lib.optional isCrossBuild qtdeclarative; outputs = [ "out" "dev" "bin" ]; preConfigure = '' NIX_CFLAGS_COMPILE+=" -DNIXPKGS_QML2_IMPORT_PREFIX=\"$qtQmlPrefix\"" diff --git a/pkgs/development/libraries/qt-5/modules/qtdoc.nix b/pkgs/development/libraries/qt-5/modules/qtdoc.nix index 93620e42667e0..763f7956b32df 100644 --- a/pkgs/development/libraries/qt-5/modules/qtdoc.nix +++ b/pkgs/development/libraries/qt-5/modules/qtdoc.nix @@ -1,7 +1,7 @@ -{ qtModule, qtdeclarative }: +{ qtModule, qtbase, qtdeclarative }: qtModule { pname = "qtdoc"; - propagatedBuildInputs = [ qtdeclarative ]; + propagatedBuildInputs = [ qtbase qtdeclarative ]; outputs = [ "out" ]; } diff --git a/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix b/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix index 2fe865492e369..96717b9392e3f 100644 --- a/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix +++ b/pkgs/development/libraries/qt-5/modules/qtgraphicaleffects.nix @@ -1,7 +1,7 @@ -{ qtModule, qtdeclarative }: +{ qtModule, qtbase, qtdeclarative }: qtModule { pname = "qtgraphicaleffects"; - propagatedBuildInputs = [ qtdeclarative ]; + propagatedBuildInputs = [ qtbase qtdeclarative ]; outputs = [ "out" "dev" ]; } diff --git a/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix b/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix index 3b78a2a6c87ed..1558859ba4aa1 100644 --- a/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix +++ b/pkgs/development/libraries/qt-5/modules/qtquickcontrols.nix @@ -1,6 +1,6 @@ -{ qtModule, qtdeclarative }: +{ qtModule, qtbase, qtdeclarative }: qtModule { pname = "qtquickcontrols"; - propagatedBuildInputs = [ qtdeclarative ]; + propagatedBuildInputs = [ qtbase qtdeclarative ]; } diff --git a/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix b/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix index 59070629ddc75..98d57bd6be7fe 100644 --- a/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix +++ b/pkgs/development/libraries/qt-5/modules/qtquickcontrols2.nix @@ -1,7 +1,7 @@ -{ qtModule, qtdeclarative }: +{ qtModule, qtbase, qtdeclarative }: qtModule { pname = "qtquickcontrols2"; - propagatedBuildInputs = [ qtdeclarative ]; + propagatedBuildInputs = [ qtbase qtdeclarative ]; outputs = [ "out" "dev" "bin" ]; } diff --git a/pkgs/development/libraries/qt-5/modules/qtsvg.nix b/pkgs/development/libraries/qt-5/modules/qtsvg.nix index 418c69fb2ebf6..083fa6d6d9df5 100644 --- a/pkgs/development/libraries/qt-5/modules/qtsvg.nix +++ b/pkgs/development/libraries/qt-5/modules/qtsvg.nix @@ -2,6 +2,6 @@ qtModule { pname = "qtsvg"; - propagatedBuildInputs = [ qtbase ]; + buildInputs = [ qtbase ]; outputs = [ "out" "dev" "bin" ]; } From d37157c5ecceb566e95b00c4c6b92091da936bd9 Mon Sep 17 00:00:00 2001 From: eryngion Date: Mon, 13 Nov 2023 20:10:27 +0000 Subject: [PATCH 10/21] qt5.qttools: fix detection of lrelease and other tools in cross builds with qttools as a buildInput And don't propagate qtbase to avoid pulling in a second qtbase.dev in cross builds. --- .../libraries/qt-5/5.15/default.nix | 2 +- .../qt-5/5.15/qttools-cross-build.patch | 139 ++++++++++++++++++ .../qt-5/hooks/qttools-setup-hook.sh | 16 +- .../libraries/qt-5/modules/qttools.nix | 11 +- 4 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.15/qttools-cross-build.patch diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 5a33b226d0a7d..34caef77cf2e0 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -231,7 +231,7 @@ let ./qtwebkit-darwin-no-readline.patch ./qtwebkit-darwin-no-qos-classes.patch ]; - qttools = [ ./qttools.patch ]; + qttools = [ ./qttools.patch ./qttools-cross-build.patch ]; }; addPackages = self: diff --git a/pkgs/development/libraries/qt-5/5.15/qttools-cross-build.patch b/pkgs/development/libraries/qt-5/5.15/qttools-cross-build.patch new file mode 100644 index 0000000000000..e97105d0c2cf8 --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.15/qttools-cross-build.patch @@ -0,0 +1,139 @@ +diff --git a/src/assistant/help/Qt5HelpConfigExtras.cmake.in b/src/assistant/help/Qt5HelpConfigExtras.cmake.in +index 1f7544b62..bd18710f9 100644 +--- a/src/assistant/help/Qt5HelpConfigExtras.cmake.in ++++ b/src/assistant/help/Qt5HelpConfigExtras.cmake.in +@@ -2,30 +2,20 @@ + if (NOT TARGET Qt5::qcollectiongenerator) + add_executable(Qt5::qcollectiongenerator IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}qcollectiongenerator$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Help_check_file_exists(${imported_location}) ++ find_program(qcollectiongenerator_imported_location \"qcollectiongenerator$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qcollectiongenerator PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qcollectiongenerator_imported_location} + ) + endif() + + if (NOT TARGET Qt5::qhelpgenerator) + add_executable(Qt5::qhelpgenerator IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5Help_install_prefix}/$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}qhelpgenerator$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_Help_check_file_exists(${imported_location}) ++ find_program(qhelpgenerator_imported_location \"qhelpgenerator$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qhelpgenerator PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qhelpgenerator_imported_location} + ) + endif() + +diff --git a/src/linguist/Qt5LinguistToolsConfig.cmake.in b/src/linguist/Qt5LinguistToolsConfig.cmake.in +index 2e99bc762..36af1a596 100644 +--- a/src/linguist/Qt5LinguistToolsConfig.cmake.in ++++ b/src/linguist/Qt5LinguistToolsConfig.cmake.in +@@ -44,45 +44,30 @@ endmacro() + if (NOT TARGET Qt5::lrelease) + add_executable(Qt5::lrelease IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}lrelease$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_LinguistTools_check_file_exists(${imported_location}) ++ find_program(lrelease_imported_location \"lrelease$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::lrelease PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${lrelease_imported_location} + ) + endif() + + if (NOT TARGET Qt5::lupdate) + add_executable(Qt5::lupdate IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}lupdate$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_LinguistTools_check_file_exists(${imported_location}) ++ find_program(lupdate_imported_location \"lupdate$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::lupdate PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${lupdate_imported_location} + ) + endif() + + if (NOT TARGET Qt5::lconvert) + add_executable(Qt5::lconvert IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5_linguisttools_install_prefix}/$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}lconvert$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_LinguistTools_check_file_exists(${imported_location}) ++ find_program(lconvert_imported_location \"lconvert$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::lconvert PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${lconvert_imported_location} + ) + endif() + +diff --git a/src/qdoc/Qt5DocToolsConfig.cmake.in b/src/qdoc/Qt5DocToolsConfig.cmake.in +index 2a252bb31..6b2555c4d 100644 +--- a/src/qdoc/Qt5DocToolsConfig.cmake.in ++++ b/src/qdoc/Qt5DocToolsConfig.cmake.in +@@ -43,15 +43,10 @@ endmacro() + if (NOT TARGET Qt5::qdoc) + add_executable(Qt5::qdoc IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5_qdoctools_install_prefix}/$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}qdoc$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_DocTools_check_file_exists(${imported_location}) ++ find_program(qdoc_imported_location \"qdoc$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qdoc PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qdoc_imported_location} + ) + endif() + +diff --git a/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in b/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in +index e99540bfa..85171c76b 100644 +--- a/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in ++++ b/src/qtattributionsscanner/Qt5AttributionsScannerTools.cmake.in +@@ -43,15 +43,10 @@ endmacro() + if (NOT TARGET Qt5::qtattributionsscanner) + add_executable(Qt5::qtattributionsscanner IMPORTED) + +-!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +- set(imported_location \"${_qt5_qattributionsscannertools_install_prefix}/$${CMAKE_BIN_DIR}qtattributionsscanner$$CMAKE_BIN_SUFFIX\") +-!!ELSE +- set(imported_location \"$${CMAKE_BIN_DIR}qtattributionsscanner$$CMAKE_BIN_SUFFIX\") +-!!ENDIF +- _qt5_AttributionsScannerTools_check_file_exists(${imported_location}) ++ find_program(qtattributionsscanner_imported_location \"qtattributionsscanner$$CMAKE_BIN_SUFFIX\" PATHS ENV PATH NO_DEFAULT_PATH) + + set_target_properties(Qt5::qtattributionsscanner PROPERTIES +- IMPORTED_LOCATION ${imported_location} ++ IMPORTED_LOCATION ${qtattributionsscanner_imported_location} + ) + endif() + diff --git a/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh index c320a79744711..fe0eb9adfa5d4 100644 --- a/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qttools-setup-hook.sh @@ -1 +1,15 @@ -qmakeFlags+=( "QMAKE_LRELEASE=@dev@/bin/lrelease" ) +# Nowadays lrelease feature in mkspecs of qtbase can automatically find the tool in PATH with qtPrepareTool +# and process TRANSLATIONS if the pro file has CONFIG+=lrelease in it. +# But for some reason QMAKE_LRELEASE from qtPrepareTool does not propagate to the pro file itself, and some +# packages still use QMAKE_LRELEASE directly, so we'll need to pass it explicitly until there's a better +# mkspecs based solution. +# NB: this could be non-overridable via qmakeFlags attribute in a package due to hook ordering. + +if [[ -z "${__nix_qttoolsHook-}" ]]; then + __nix_qttoolsHook=1 # Don't run this hook more than once. + + if ! qmakeFlags+=( "QMAKE_LRELEASE=$(PATH="$_PATH" command -v lrelease)" ); then + echo "FYI: can't find a runnable lrelease in PATH. If this package doesn't use it than it's perfectly fine." + echo "Otherwise you should add qttools to nativeBuildInputs." + fi +fi diff --git a/pkgs/development/libraries/qt-5/modules/qttools.nix b/pkgs/development/libraries/qt-5/modules/qttools.nix index 0885dfeefa353..46090bbcb07f6 100644 --- a/pkgs/development/libraries/qt-5/modules/qttools.nix +++ b/pkgs/development/libraries/qt-5/modules/qttools.nix @@ -1,8 +1,15 @@ -{ qtModule, stdenv, lib, qtbase, qtdeclarative }: +{ qtModule, stdenv, lib, qtbase, qtdeclarative, qttools }: + +let + isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; +in qtModule { pname = "qttools"; - propagatedBuildInputs = [ qtbase qtdeclarative ]; + buildInputs = [ qtbase qtdeclarative ]; + # We don't need this to build qttools itself, only for the packages that include qttools + # in their buildInputs and expect to get not only libs but also runnable tools. + propagatedNativeBuildInputs = lib.optional isCrossBuild qttools; outputs = [ "out" "dev" "bin" ]; # fixQtBuiltinPaths overwrites a builtin path we should keep From e3eaf7e98efdcfbc9de29b750326cd58df7d8cbf Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 25 Oct 2023 03:21:44 +0300 Subject: [PATCH 11/21] qt5.wrapQtAppsHook: move libs to depsTargetTargetPropagated https://github.com/NixOS/nixpkgs/blob/master/doc/builders/special/makesetuphook.section.md --- pkgs/development/libraries/qt-5/5.15/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 34caef77cf2e0..710c80079a334 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -376,7 +376,8 @@ let wrapQtAppsHook = callPackage ({ makeBinaryWrapper, qtbase, qtwayland }: makeSetupHook { name = "wrap-qt5-apps-hook"; - propagatedBuildInputs = [ qtbase.dev makeBinaryWrapper ] + propagatedBuildInputs = [ makeBinaryWrapper ]; + depsTargetTargetPropagated = [ qtbase.dev ] ++ lib.optional stdenv.isLinux qtwayland.dev; } ../hooks/wrap-qt-apps-hook.sh) { }; }; From 041620b8ac441ee2f8571258bbe5a335d47e10c0 Mon Sep 17 00:00:00 2001 From: eryngion Date: Tue, 14 Nov 2023 21:58:14 +0300 Subject: [PATCH 12/21] qt5.qtwebkit: use hyphen from pkgs The sources in tarbals are identical, and hyphen from pkgs properly supports cross compilation. --- .../libraries/qt-5/modules/qtwebkit.nix | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix index bd05954ddb35d..023928cc30f83 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix @@ -3,23 +3,9 @@ , fontconfig, libwebp, libxml2, libxslt , sqlite, systemd, glib, gst_all_1, cmake , bison, flex, gdb, gperf, perl, pkg-config, python3, ruby -, ICU, OpenGL +, ICU, OpenGL, hyphen }: -let - hyphen = stdenv.mkDerivation rec { - pname = "hyphen"; - version = "2.8.8"; - src = fetchurl { - url = "http://dev-www.libreoffice.org/src/5ade6ae2a99bc1e9e57031ca88d36dad-hyphen-${version}.tar.gz"; - sha256 = "304636d4eccd81a14b6914d07b84c79ebb815288c76fe027b9ebff6ff24d5705"; - }; - postPatch = '' - patchShebangs tests - ''; - buildInputs = [ perl ]; - }; -in qtModule { pname = "qtwebkit"; propagatedBuildInputs = [ qtbase qtdeclarative qtlocation qtsensors qtwebchannel ] From f3ae8f631927e3d9eeb44d87d2cccc35d7caf1aa Mon Sep 17 00:00:00 2001 From: eryngion Date: Tue, 21 Nov 2023 21:04:01 +0300 Subject: [PATCH 13/21] qt5.qtwebkit: add missing optional deps It will use the bundled woff2 lib if we don't provide a system one. And "DWARF optimization and duplicate removal tool" is just nice to have, I guess. --- pkgs/development/libraries/qt-5/modules/qtwebkit.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix index 023928cc30f83..3aea29004c1c8 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebkit.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebkit.nix @@ -3,16 +3,16 @@ , fontconfig, libwebp, libxml2, libxslt , sqlite, systemd, glib, gst_all_1, cmake , bison, flex, gdb, gperf, perl, pkg-config, python3, ruby -, ICU, OpenGL, hyphen +, ICU, OpenGL, hyphen, woff2, dwz }: qtModule { pname = "qtwebkit"; propagatedBuildInputs = [ qtbase qtdeclarative qtlocation qtsensors qtwebchannel ] ++ lib.optional stdenv.isDarwin qtmultimedia; - buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen ] + buildInputs = [ fontconfig libwebp libxml2 libxslt sqlite glib gst_all_1.gstreamer gst_all_1.gst-plugins-base hyphen woff2 ] ++ lib.optionals stdenv.isDarwin [ ICU OpenGL ]; - nativeBuildInputs = [ bison flex gdb gperf perl pkg-config python3 ruby cmake ]; + nativeBuildInputs = [ bison flex gdb gperf perl pkg-config python3 ruby cmake dwz ]; cmakeFlags = [ "-DPORT=Qt" ] ++ lib.optionals stdenv.isDarwin [ From 7b40a46eb8c8db4e3c4ff35b091fb7004b546f5b Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 16 Nov 2023 18:02:35 +0300 Subject: [PATCH 14/21] Revert "qt5.qtwebchannel: omit "bin" output when cross compiling" Not sure why it was done. This reverts commit 49e8d9db2f83003c0c5ac6c2df25104390f60519. --- pkgs/development/libraries/qt-5/modules/qtwebchannel.nix | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix index e7d6be534409e..118a5d4f96f69 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebchannel.nix @@ -1,12 +1,7 @@ -{ lib -, stdenv -, qtModule -, qtbase -, qtdeclarative -}: +{ qtModule, qtbase, qtdeclarative }: qtModule { pname = "qtwebchannel"; propagatedBuildInputs = [ qtbase qtdeclarative ]; - outputs = [ "out" "dev" ] ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "bin" ]; + outputs = [ "out" "dev" "bin" ]; } From 0f6bb017f7e793ccdfb4926dc329d3686aa5941d Mon Sep 17 00:00:00 2001 From: eryngion Date: Tue, 21 Nov 2023 20:53:43 +0300 Subject: [PATCH 15/21] pyqt5: update cross --- pkgs/development/python-modules/pyqt/5.x.nix | 35 ++++---------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/pkgs/development/python-modules/pyqt/5.x.nix b/pkgs/development/python-modules/pyqt/5.x.nix index ed0264c816dd6..356323e4afce7 100644 --- a/pkgs/development/python-modules/pyqt/5.x.nix +++ b/pkgs/development/python-modules/pyqt/5.x.nix @@ -7,7 +7,6 @@ fetchPypi, pkg-config, dbus, - lndir, dbus-python, sip, pyqt5-sip, @@ -21,8 +20,6 @@ withLocation ? false, withSerialPort ? false, withTools ? false, - pkgsBuildTarget, - buildPackages, dbusSupport ? !stdenv.isDarwin, }: @@ -119,42 +116,22 @@ buildPythonPackage rec { dontWrapQtApps = true; nativeBuildInputs = - [ pkg-config ] - ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ libsForQt5.qmake ] - ++ [ + [ pkg-config + libsForQt5.qmake setuptools - lndir sip - ] - ++ ( - with pkgsBuildTarget.targetPackages.libsForQt5; - [ ] - ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ qmake ] - ++ [ - qtbase - qtsvg - qtdeclarative - qtwebchannel - ] - ++ lib.optional withConnectivity qtconnectivity - ++ lib.optional withMultimedia qtmultimedia - ++ lib.optional withWebKit qtwebkit - ++ lib.optional withWebSockets qtwebsockets - ++ lib.optional withLocation qtlocation - ++ lib.optional withSerialPort qtserialport - ++ lib.optional withTools qttools - ); + ]; buildInputs = with libsForQt5; - [ dbus ] - ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ qtbase ] - ++ [ + [ dbus + qtbase qtsvg qtdeclarative pyqt-builder ] ++ lib.optional withConnectivity qtconnectivity + ++ lib.optional withMultimedia qtmultimedia ++ lib.optional withWebKit qtwebkit ++ lib.optional withWebSockets qtwebsockets ++ lib.optional withLocation qtlocation From 2c2d8384a8e163af82261bb1f8a951178590010d Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 16 Nov 2023 18:54:03 +0300 Subject: [PATCH 16/21] qt5.qtwebengine: update cross compilation support --- .../libraries/qt-5/5.15/default.nix | 1 + .../qt-5/5.15/qtwebengine-cross-build.patch | 149 +++++++++++++ .../libraries/qt-5/modules/qtwebengine.nix | 200 +++++++++--------- 3 files changed, 252 insertions(+), 98 deletions(-) create mode 100644 pkgs/development/libraries/qt-5/5.15/qtwebengine-cross-build.patch diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 710c80079a334..c0e9e4f4d9552 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -193,6 +193,7 @@ let hash = "sha256-s4GsGMJTBNWw2gTJuIEP3tqT82AmTsR2mbj59m2p6rM="; }) ./qtwebengine-link-pulseaudio.patch + ./qtwebengine-cross-build.patch ] ++ lib.optionals stdenv.isDarwin [ ./qtwebengine-darwin-no-platform-check.patch ./qtwebengine-mac-dont-set-dsymutil-path.patch diff --git a/pkgs/development/libraries/qt-5/5.15/qtwebengine-cross-build.patch b/pkgs/development/libraries/qt-5/5.15/qtwebengine-cross-build.patch new file mode 100644 index 0000000000000..81e18bbc65107 --- /dev/null +++ b/pkgs/development/libraries/qt-5/5.15/qtwebengine-cross-build.patch @@ -0,0 +1,149 @@ +commit 8d8892f237a510a614311e37ebcc4d70b71b7924 +Author: eryngion +AuthorDate: Fri Dec 1 10:59:02 2023 +0300 + + Use buildBuld version of stdenv.cc in the "host" toolchain for chromium + + Chromium builds some tools for itself as a part of its build process. + Those tools don't end up in outputs of Nix packages, so we can actually + just compile them for the buildPlatform. + + It is mostly a Nixified version of this patch + https://github.com/meta-qt5/meta-qt5/raw/9537acc9fdd07f2dae6ea562eed34ba41ccde39d/recipes-qt/qt5/qtwebengine/0001-Force-host-toolchain-configuration.patch + Plus a small change that allows v8_snapshot_toolchain to properly find ICU + on the buildPlatform instead of resorting to the bundled ICU as done in + https://github.com/meta-qt5/meta-qt5/blob/9537acc9fdd07f2dae6ea562eed34ba41ccde39d/recipes-qt/qt5/qtwebengine/chromium/0010-chromium-icu-use-system-library-only-targets.patch + + The original commentary of the first patch is below: + + From: Samuli Piippo + Date: Wed, 15 Mar 2017 13:53:28 +0200 + Subject: [PATCH] Force host toolchain configuration + + Force gcc/g++ to be used for parts using host toolchain, since + the option(host_build) does not work in yocto builds. + + Don't use QT_ARCH for the host architecture, since that's always + the target architecture in bitbake builds, instead ask specifically + for the qmakes's host architecture. + + Upstream-Status: Inappropriate [OE specific] + Signed-off-by: Samuli Piippo + +diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf +index 7f63058..6b658e8 100644 +--- a/mkspecs/features/functions.prf ++++ b/mkspecs/features/functions.prf +@@ -109,6 +109,7 @@ defineReplace(gnArch) { + contains(qtArch, "x86_64"): return(x64) + contains(qtArch, "arm"): return(arm) + contains(qtArch, "arm64"): return(arm64) ++ contains(qtArch, "aarch64"): return(arm64) + contains(qtArch, "mips"): return(mipsel) + contains(qtArch, "mips64"): return(mips64el) + contains(qtArch, "mips64el"): return(mips64el) +diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri +index 7507d51..5bc9c1b 100644 +--- a/src/buildtools/config/linux.pri ++++ b/src/buildtools/config/linux.pri +@@ -118,7 +118,7 @@ contains(QT_ARCH, "mips") { + + host_build { + gn_args += custom_toolchain=\"$$QTWEBENGINE_OUT_ROOT/src/toolchain:host\" +- GN_HOST_CPU = $$gnArch($$QT_ARCH) ++ GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch) + gn_args += host_cpu=\"$$GN_HOST_CPU\" + # Don't bother trying to use system libraries in this case + gn_args += use_glib=false +@@ -138,7 +138,7 @@ host_build { + # Strip '>2 /dev/null' from $$pkgConfigExecutable() + PKGCONFIG = $$first($$list($$pkgConfigExecutable())) + gn_args += pkg_config=\"$$PKGCONFIG\" +- PKG_CONFIG_HOST = $$(GN_PKG_CONFIG_HOST) ++ PKG_CONFIG_HOST = $$(PKG_CONFIG_FOR_BUILD) + pkgConfigLibDir = $$(PKG_CONFIG_LIBDIR) + pkgConfigSysrootDir = $$(PKG_CONFIG_SYSROOT_DIR) + isEmpty(PKG_CONFIG_HOST): cross_compile { +diff --git a/src/buildtools/configure_host.pro b/src/buildtools/configure_host.pro +index dd0d3e3..8703801 100644 +--- a/src/buildtools/configure_host.pro ++++ b/src/buildtools/configure_host.pro +@@ -4,7 +4,7 @@ TEMPLATE = aux + # Pick up the host toolchain + option(host_build) + +-GN_HOST_CPU = $$gnArch($$QT_ARCH) ++GN_HOST_CPU = $$gnArch($$QMAKE_HOST.arch) + !isEmpty(QT_TARGET_ARCH): GN_TARGET_CPU = $$gnArch($$QT_TARGET_ARCH) + else: GN_TARGET_CPU = $$GN_HOST_CPU + GN_OS = $$gnOS() +@@ -23,20 +23,17 @@ contains(GN_TARGET_CPU, "arm")|contains(GN_TARGET_CPU, "mipsel")|contains(GN_TAR + else: contains(GN_V8_HOST_CPU, mips64el): GN_V8_HOST_CPU = "mipsel" + } + +-GN_HOST_EXTRA_CPPFLAGS = $$(GN_HOST_TOOLCHAIN_EXTRA_CPPFLAGS) +- + # We always use the gcc_toolchain, because clang_toolchain is just + # a broken wrapper around it for Google's custom clang binaries. + GN_CONTENTS = \ + "import(\"//build/config/sysroot.gni\")" \ + "import(\"//build/toolchain/gcc_toolchain.gni\")" \ + "gcc_toolchain(\"host\") {" \ +-" cc = \"$$which($$QMAKE_CC)\" " \ +-" cxx = \"$$which($$QMAKE_CXX)\" " \ +-" ld = \"$$which($$QMAKE_LINK)\" " \ +-" ar = \"$$which(ar)\" " \ +-" nm = \"$$which(nm)\" " \ +-" extra_cppflags = \"$$GN_HOST_EXTRA_CPPFLAGS\" " \ ++" cc = \"$$which($$(CC_FOR_BUILD))\" " \ ++" cxx = \"$$which($$(CXX_FOR_BUILD))\" " \ ++" ld = \"$$which($$(CXX_FOR_BUILD))\" " \ ++" ar = \"$$which($$(AR_FOR_BUILD))\" " \ ++" nm = \"$$which($$(NM_FOR_BUILD))\" " \ + " toolchain_args = { " \ + " current_os = \"$$GN_OS\" " \ + " current_cpu = \"$$GN_HOST_CPU\" " \ +@@ -45,11 +42,11 @@ GN_CONTENTS = \ + " } " \ + "}" \ + "gcc_toolchain(\"v8_snapshot\") {" \ +-" cc = \"$$which($$QMAKE_CC)\" " \ +-" cxx = \"$$which($$QMAKE_CXX)\" " \ +-" ld = \"$$which($$QMAKE_LINK)\" " \ +-" ar = \"$$which(ar)\" " \ +-" nm = \"$$which(nm)\" " \ ++" cc = \"$$which($$(CC_FOR_BUILD))\" " \ ++" cxx = \"$$which($$(CXX_FOR_BUILD))\" " \ ++" ld = \"$$which($$(CXX_FOR_BUILD))\" " \ ++" ar = \"$$which($$(AR_FOR_BUILD))\" " \ ++" nm = \"$$which($$(NM_FOR_BUILD))\" " \ + " toolchain_args = { " \ + " current_os = \"$$GN_OS\" " \ + " current_cpu = \"$$GN_V8_HOST_CPU\" " \ +diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro +index f94694d..8035d5a 100644 +--- a/src/buildtools/gn.pro ++++ b/src/buildtools/gn.pro +@@ -19,9 +19,8 @@ build_pass|!debug_and_release { + gn_bootstrap = $$system_path($$absolute_path(gn/build/gen.py, $$src_3rd_party_dir)) + + gn_gen_args = --no-last-commit-position --out-path $$out_path \ +- --cc \"$$which($$QMAKE_CC)\" --cxx \"$$which($$QMAKE_CXX)\" \ +- --ld \"$$which($$QMAKE_LINK)\" +- !isEmpty(QMAKE_AR): gn_gen_args += --ar \"$$which($$first(QMAKE_AR))\" ++ --cc \"$$which($$(CC_FOR_BUILD))\" --cxx \"$$which($$(CXX_FOR_BUILD))\" \ ++ --ld \"$$which($$(CXX_FOR_BUILD))\" --ar \"$$which($$(AR_FOR_BUILD))\" + + msvc:!clang_cl: gn_gen_args += --use-lto + +--- a/src/3rdparty/chromium/build/config/linux/pkg_config.gni ++++ b/src/3rdparty/chromium/build/config/linux/pkg_config.gni +@@ -91,7 +91,7 @@ + assert(defined(invoker.packages), + "Variable |packages| must be defined to be a list in pkg_config.") + config(target_name) { +- if (host_toolchain == current_toolchain) { ++ if (default_toolchain != current_toolchain) { + args = host_pkg_config_args + invoker.packages + } else { + args = pkg_config_args + invoker.packages diff --git a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix index 0194d3b43902c..c67c7523deffb 100644 --- a/pkgs/development/libraries/qt-5/modules/qtwebengine.nix +++ b/pkgs/development/libraries/qt-5/modules/qtwebengine.nix @@ -1,23 +1,22 @@ { qtModule , qtdeclarative, qtquickcontrols, qtlocation, qtwebchannel +, srcs -, bison, flex, git, gperf, ninja, pkg-config, python, which, python3 +, bison, flex, git, gperf, ninja, pkg-config, python, which , nodejs, qtbase, perl , buildPackages -, pkgsBuildTarget -, pkgsBuildBuild , xorg, libXcursor, libXScrnSaver, libXrandr, libXtst , fontconfig, freetype, harfbuzz, icu, dbus, libdrm , zlib, minizip, libjpeg, libpng, libtiff, libwebp, libopus -, jsoncpp, protobuf, libvpx, srtp, snappy, nss, libevent +, libvpx, srtp, snappy, nss, libevent +, lcms2, libxml2, libxslt , alsa-lib , pulseaudio , libcap , pciutils , systemd , enableProprietaryCodecs ? true -, gn , cctools, libobjc, libpm, libunwind, sandbox, xnu , ApplicationServices, AVFoundation, Foundation, ForceFeedback, GameController, AppKit , ImageCaptureCore, CoreBluetooth, IOBluetooth, CoreWLAN, Quartz, Cocoa, LocalAuthentication @@ -30,46 +29,79 @@ , pipewireSupport ? stdenv.isLinux , pipewire_0_2 , postPatch ? "" -, nspr -, lndir , dbusSupport ? !stdenv.isDarwin, expat }: let - # qtwebengine expects to find an executable in $PATH which runs on - # the build platform yet knows about the host `.pc` files. Most - # configury allows setting $PKG_CONFIG to point to an - # arbitrarily-named script which serves this purpose; however QT - # insists that it is named `pkg-config` with no target prefix. So - # we re-wrap the host platform's pkg-config. - pkg-config-wrapped-without-prefix = stdenv.mkDerivation { - name = "pkg-config-wrapper-without-target-prefix"; - dontUnpack = true; - dontBuild = true; - installPhase = '' - mkdir -p $out/bin - ln -s '${buildPackages.pkg-config}/bin/${buildPackages.pkg-config.targetPrefix}pkg-config' $out/bin/pkg-config + isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; + + # qtwebengine requires its own very particular specially patched for qt version of gn + gnQtWebengine = with srcs.qtwebengine; buildPackages.gn.overrideAttrs { + pname = "gn-qtwebengine"; + inherit src version; + sourceRoot = "${src.name}/src/3rdparty/gn"; + buildPhase = '' + # using $CXX as ld because the script uses --gc-sections, and ld doesn't recognize it. + # on a related note, here we can see as QT developers intentionally de-standardize build tools: + # https://github.com/qt/qtwebengine-chromium/commit/0e7e61966f9215babb0d4b32d97b9c0b73db1ca9 + python build/gen.py --no-last-commit-position --cc $CC --cxx $CXX --ld $CXX --ar $AR + ninja -j $NIX_BUILD_CORES -C out gn ''; }; - qtPlatformCross = plat: with plat; - if isLinux - then "linux-generic-g++" - else throw "Please add a qtPlatformCross entry for ${plat.config}"; - + # Overriding stdenv seems to be a common thing for qt5 scope, so I'm using the + # "__spliced or" construction here instead of pkgsBuildBuild. + # FIXME: on Darwin stdenv is always overriden in a way that prevents its splicing + # even on a cross system, so we'll need to figure out a way to get a BuildBuild + # version of it here. + stdenvForBuildPlatform = stdenv.__spliced.buildBuild or stdenv; + + cflagsForPlatform = stdenv: + toString ( + [ "-w " + ] ++ lib.optionals stdenv.cc.isGNU [ + # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit + "-Wno-class-memaccess" + ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ + # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 + # TODO: investigate and fix properly + "-march=westmere" + ] ++ lib.optionals stdenv.cc.isClang [ + "-Wno-elaborated-enum-base" + ]); in qtModule ({ pname = "qtwebengine"; nativeBuildInputs = [ - bison flex git gperf ninja pkg-config python which gn nodejs - ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - perl - lndir (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtbase) - pkgsBuildBuild.pkg-config - (lib.getDev pkgsBuildTarget.targetPackages.qt5.qtquickcontrols) - pkg-config-wrapped-without-prefix - ] ++ lib.optional stdenv.isDarwin xcbuild; + bison flex git gperf ninja pkg-config python which nodejs gnQtWebengine + ] ++ lib.optionals stdenv.isDarwin [ + xcbuild cctools + + # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py` + # to get some information about the host platform. + (writeScriptBin "sw_vers" '' + #!${stdenv.shell} + + while [ $# -gt 0 ]; do + case "$1" in + -buildVersion) echo "17E199";; + *) break ;; + + esac + shift + done + '') + ]; + + # For "host" builds in chromium. Only cc in depsBuildBuild will produce + # _FOR_BUILD env variables that are used in qtwebengine-cross-build.patch. + depsBuildBuild = [ stdenvForBuildPlatform.cc pkg-config zlib nss icu + # apparently chromium doesn't care if these deps are non-functional on the buildPlatform + # but build fails if pkg-config can't find them + libjpeg libpng libwebp freetype harfbuzz + ]; + strictDeps = true; doCheck = true; outputs = [ "bin" "dev" "out" ]; @@ -85,6 +117,9 @@ qtModule ({ postPatch = '' # Patch Chromium build tools ( + # Force configure to accept qtwebengine's own version of gn when passed from outside + substituteInPlace configure.pri --replace 'qtLog("Gn version too old")' 'return(true)' + cd src/3rdparty/chromium; # Manually fix unsupported shebangs @@ -145,45 +180,27 @@ qtModule ({ '') + postPatch; env = { - NIX_CFLAGS_COMPILE = - toString ( - lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - "-w " - ] ++ lib.optionals stdenv.cc.isGNU [ - # with gcc8, -Wclass-memaccess became part of -Wall and this exceeds the logging limit - "-Wno-class-memaccess" - ] ++ lib.optionals (stdenv.hostPlatform.gcc.arch or "" == "sandybridge") [ - # it fails when compiled with -march=sandybridge https://github.com/NixOS/nixpkgs/pull/59148#discussion_r276696940 - # TODO: investigate and fix properly - "-march=westmere" - ] ++ lib.optionals stdenv.cc.isClang [ - "-Wno-elaborated-enum-base" - ]); - } // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - NIX_CFLAGS_LINK = "-Wl,--no-warn-search-mismatch"; - "NIX_CFLAGS_LINK_${buildPackages.stdenv.cc.suffixSalt}" = "-Wl,--no-warn-search-mismatch"; + NIX_CFLAGS_COMPILE = cflagsForPlatform stdenv; + NIX_CFLAGS_COMPILE_FOR_BUILD = cflagsForPlatform stdenvForBuildPlatform; }; preConfigure = '' export NINJAFLAGS=-j$NIX_BUILD_CORES - - if [ -d "$PWD/tools/qmake" ]; then - QMAKEPATH="$PWD/tools/qmake''${QMAKEPATH:+:}$QMAKEPATH" - fi - '' + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' - export QMAKE_CC=$CC - export QMAKE_CXX=$CXX - export QMAKE_LINK=$CXX - export QMAKE_AR=$AR ''; - qmakeFlags = [ "--" "-system-ffmpeg" ] - ++ lib.optional (pipewireSupport && stdenv.buildPlatform == stdenv.hostPlatform) "-webengine-webrtc-pipewire" + qmakeFlags = [ "--" "-feature-webengine-system-gn" "-webengine-icu" ] + # webengine-embedded-build disables WebRTC, "Printing and PDF" and breaks PyQtWebEngine build. + # It is automatically switched on for cross compilation. We probably always want it disabled. + ++ lib.optional stdenv.isLinux "-no-webengine-embedded-build" + ++ lib.optional (ffmpeg_4 != null) "-webengine-ffmpeg" + ++ lib.optional (pipewireSupport && !isCrossBuild) "-webengine-webrtc-pipewire" ++ lib.optional enableProprietaryCodecs "-proprietary-codecs"; - propagatedBuildInputs = [ - qtdeclarative qtquickcontrols qtlocation qtwebchannel + propagatedBuildInputs = [ qtdeclarative qtquickcontrols qtlocation qtwebchannel ]; + # Optional dependency on system-provided re2 library is not used here because it activates + # some broken code paths in chromium. + buildInputs = [ # Image formats libjpeg libpng libtiff libwebp @@ -194,28 +211,39 @@ qtModule ({ libopus # Text rendering - harfbuzz icu + harfbuzz icu freetype libevent ffmpeg_4 + + lcms2 + + snappy minizip zlib + ] ++ lib.optionals (!stdenv.isDarwin) [ - dbus zlib minizip snappy nss protobuf jsoncpp + dbus nss # Audio formats alsa-lib pulseaudio # Text rendering - fontconfig freetype + fontconfig libcap pciutils + # there's an explicit check for LIBXML_ICU_ENABLED at configuraion time + # FIXME: still doesn't work because of the propagation of non-icu libxml2 + # from qtbase. Not sure what is the right move here. + # FIXME: those could also be used on Darwin if we fix https://github.com/NixOS/nixpkgs/issues/272383 + libxslt (libxml2.override { icuSupport=true; }) + # X11 libs xorg.xrandr libXScrnSaver libXcursor libXrandr xorg.libpciaccess libXtst xorg.libXcomposite xorg.libXdamage libdrm xorg.libxkbfile - ] ++ lib.optionals pipewireSupport [ + ] ++ lib.optionals (pipewireSupport && !isCrossBuild) [ # Pipewire pipewire_0_2 ] @@ -224,7 +252,6 @@ qtModule ({ # around it. Chromium pulls this in while bootstrapping GN. ++ lib.optionals stdenv.isDarwin [ libobjc - cctools # frameworks ApplicationServices @@ -250,33 +277,21 @@ qtModule ({ openbsm libunwind - ]; - buildInputs = lib.optionals stdenv.isDarwin [ cups libpm sandbox - - # `sw_vers` is used by `src/3rdparty/chromium/build/config/mac/sdk_info.py` - # to get some information about the host platform. - (writeScriptBin "sw_vers" '' - #!${stdenv.shell} - - while [ $# -gt 0 ]; do - case "$1" in - -buildVersion) echo "17E199";; - *) break ;; - - esac - shift - done - '') ]; + # to get progress output in `nix-build` and `nix build -L` + preBuild = '' + export TERM=dumb + ''; + dontUseNinjaBuild = true; dontUseNinjaInstall = true; - postInstall = lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + postInstall = lib.optionalString isCrossBuild '' mkdir -p $out/libexec '' + lib.optionalString stdenv.isLinux '' cat > $out/libexec/qt.conf < Date: Sat, 2 Dec 2023 23:52:55 +0300 Subject: [PATCH 17/21] pyqtwebengine: update cross compilation support I expect here that qtwebengine will propagate qtwebchannel and qtdeclarative and that qtdeclarative will propagate itself as a nativeBuildInput. But maybe we shouldn't rely on those propagations? --- .../python-modules/pyqtwebengine/default.nix | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pkgs/development/python-modules/pyqtwebengine/default.nix b/pkgs/development/python-modules/pyqtwebengine/default.nix index b72fde6277f7b..f12188e3d68c1 100644 --- a/pkgs/development/python-modules/pyqtwebengine/default.nix +++ b/pkgs/development/python-modules/pyqtwebengine/default.nix @@ -8,8 +8,6 @@ qtbase, qtsvg, qtwebengine, - qtwebchannel, - qtdeclarative, wrapQtAppsHook, darwin, buildPackages, @@ -60,13 +58,9 @@ buildPythonPackage ( python.pythonOnBuildForHost.pkgs.sip ] ++ [ - qtbase - qtsvg - qtwebengine pyqt-builder pythonPackages.setuptools ] - ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ qtdeclarative ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ]; buildInputs = @@ -75,10 +69,6 @@ buildPythonPackage ( qtbase qtsvg qtwebengine - ] - ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ - qtwebchannel - qtdeclarative ]; propagatedBuildInputs = [ pyqt5 ]; @@ -109,11 +99,4 @@ buildPythonPackage ( hydraPlatforms = lib.lists.intersectLists qtwebengine.meta.platforms platforms.mesaPlatforms; }; } - // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) { - # TODO: figure out why the env hooks aren't adding these inclusions automatically - env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [ - "-I${lib.getDev qtbase}/include/QtPrintSupport/" - "-I${lib.getDev qtwebchannel}/include/QtWebChannel/" - ]; - } ) From 5d64c292be5497b8990a5bb878d3243ee9d97b11 Mon Sep 17 00:00:00 2001 From: eryngion Date: Sun, 3 Dec 2023 22:34:38 +0300 Subject: [PATCH 18/21] qt5.qtbase: add preliminary support for cross on Darwin --- .../libraries/qt-5/5.15/default.nix | 1 + .../libraries/qt-5/hooks/qtbase-setup-hook.sh | 15 +++--- .../libraries/qt-5/modules/qtbase.nix | 48 ++++++++++++------- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index c0e9e4f4d9552..75e4f67faecf4 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -262,6 +262,7 @@ let qtbase = callPackage ../modules/qtbase.nix { inherit (srcs.qtbase) src version; patches = patches.qtbase; + # do we really need this inherit here? inherit bison cups harfbuzz libGL; withGtk3 = !stdenv.isDarwin; inherit dconf gtk3; inherit developerBuild decryptSslTraffic; diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index 83a06c63b4b28..f72453f207e09 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -39,17 +39,16 @@ isCrossBuild() { if isCrossBuild; then # When cross compiling we're using a native-built qmake binary and # it will need a little help finding the target of cross compilation. - if [[ "$(uname)" == 'Linux' ]]; then - qtPlatformCross="linux-generic-g++" + if nixCrossConf="$(basename $(ls -d @dev@/mkspecs/*-nix-cross))"; then + # Force qmake to use this config as the target instead of QMAKE_XSPEC + # that was baked into it at compile time. + export "XQMAKESPEC=$nixCrossConf" + # Use the same config for tools marked with host_build + export "QMAKESPEC=$XQMAKESPEC" else - echo "Please add a qtPlatformCross entry for $(uname)" >&2 + echo "Please add a qtPlatformCross entry for $($CC -dumpmachine)" >&2 exit 1 fi - - # Enable cross-compilation in qmake - export "XQMAKESPEC=devices/$qtPlatformCross" - # Use the same config for tools marked with host_build - export "QMAKESPEC=$XQMAKESPEC" fi providesQtRuntime() { diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 61bebb155826f..6e4fe01e42dc0 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -35,10 +35,23 @@ let debugSymbols = debug || developerBuild; isCrossBuild = stdenv.buildPlatform != stdenv.hostPlatform; - qtPlatformCross = plat: with plat; + + qtPlatformCross = with stdenv.hostPlatform; if isLinux - then "linux-generic-g++" - else throw "Please add a qtPlatformCross entry for ${plat.config}"; + then "devices/linux-generic-g++" + else if isDarwin + then + # the logic from the configure script + if isAarch64 then "macx-clang-arm64" + else "macx-clang-x64" + else + if isCrossBuild then throw "Please add a qtPlatformCross entry for ${config}" + else null; + + # We need to keep the original mkspec name in the string for pyqt-builder to determine + # the target platform. + nixCrossConf = builtins.baseNameOf qtPlatformCross + "-nix-cross"; + postFixupPatch = ../${lib.versions.majorMinor version}/qtbase.patch.d/0016-qtbase-cross-build-postFixup.patch; in @@ -163,7 +176,6 @@ stdenv.mkDerivation (finalAttrs: ({ -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/" \ @@ -193,17 +205,19 @@ stdenv.mkDerivation (finalAttrs: ({ ./bin/syncqt.pl -version $version - # generate a cross compilation config unconditionally so we can pass a natively-built qtbase + '' + # generate a cross compilation config even for native builds so we can pass a natively-built qtbase # as a build dependency for a cross build and to avoid specifying CROSS_COMPILE prefix for qmake later - sed -i '1 i CROSS_COMPILE=${stdenv.hostPlatform.config + "-"}' mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf - echo 'QMAKE_PKG_CONFIG=''$''$(PKG_CONFIG)' >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf - - # does this flag propagation really do anything? - echo "QMAKE_LFLAGS=''${LDFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf - echo "QMAKE_CFLAGS=''${CFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf - echo "QMAKE_CXXFLAGS=''${CXXFLAGS}" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf - '' + lib.optionalString isCrossBuild '' + + lib.optionalString (qtPlatformCross != null) '' + mkdir mkspecs/${nixCrossConf} + echo 'CROSS_COMPILE=${stdenv.hostPlatform.config + "-"}' > mkspecs/${nixCrossConf}/qmake.conf + echo 'QMAKE_PKG_CONFIG=''$''$(PKG_CONFIG)' >> mkspecs/${nixCrossConf}/qmake.conf + echo 'include(../${qtPlatformCross}/qmake.conf)' >> mkspecs/${nixCrossConf}/qmake.conf + echo '#include "../${qtPlatformCross}/qplatformdefs.h"' > mkspecs/${nixCrossConf}/qplatformdefs.h + + '' # QT's configure script will refuse to use pkg-config unless these two environment variables are set + + lib.optionalString isCrossBuild '' export PKG_CONFIG_SYSROOT_DIR=/ export PKG_CONFIG_LIBDIR=${lib.getLib pkg-config}/lib ''; @@ -345,6 +359,9 @@ stdenv.mkDerivation (finalAttrs: ({ ''-${if mysqlSupport then "plugin" else "no"}-sql-mysql'' ''-${if postgresql != null then "plugin" else "no"}-sql-psql'' + ] ++ lib.optionals (qttranslations != null) [ + "-translationdir" "${qttranslations}/translations" + # regular build, Darwin options ] ++ (if stdenv.isDarwin then [ "-qt-freetype" @@ -378,14 +395,11 @@ stdenv.mkDerivation (finalAttrs: ({ ] ++ lib.optionals (mysqlSupport) [ "-L" "${libmysqlclient}/lib" "-I" "${libmysqlclient}/include" - - ] ++ lib.optional (qttranslations != null) [ - "-translationdir" "${qttranslations}/translations" ] # cross compilation options ))) ++ lib.optionals isCrossBuild [ - "-device ${qtPlatformCross stdenv.hostPlatform}" + "-xplatform ${nixCrossConf}" "-external-hostbindir ${qtbase-bootstrap.qmake}/bin" ] From 0199c7340a8dbc4456a8c84e07ec14ad8866afa7 Mon Sep 17 00:00:00 2001 From: eryngion Date: Tue, 5 Dec 2023 02:09:41 +0300 Subject: [PATCH 19/21] qt5.full: simplify package functions' definitions and calls Rely on callPackage whenever possible. And pass a spliced version of stdenv to fix cross compilaton for qtwebengine. --- pkgs/development/libraries/qt-5/5.15/default.nix | 14 ++++---------- .../libraries/qt-5/modules/qtmultimedia.nix | 5 ++--- pkgs/top-level/all-packages.nix | 14 +++----------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 75e4f67faecf4..420274b5b98d8 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -8,10 +8,8 @@ Check for any minor version changes. */ { makeScopeWithSplicing', generateSplicesForMkScope -, lib, stdenv, fetchurl, fetchgit, fetchpatch, fetchFromGitHub, makeSetupHook, makeWrapper -, bison, cups ? null, harfbuzz, libGL, perl, python3 -, gstreamer, gst-plugins-base, gtk3, dconf -, llvmPackages_15, overrideSDK, overrideLibcxx +, lib, stdenv, fetchurl, fetchgit, fetchpatch, fetchFromGitHub, makeSetupHook +, python3, llvmPackages_15, overrideSDK, overrideLibcxx , darwin , buildPackages @@ -262,9 +260,7 @@ let qtbase = callPackage ../modules/qtbase.nix { inherit (srcs.qtbase) src version; patches = patches.qtbase; - # do we really need this inherit here? - inherit bison cups harfbuzz libGL; - withGtk3 = !stdenv.isDarwin; inherit dconf gtk3; + withGtk3 = !stdenv.isDarwin; 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; @@ -288,9 +284,7 @@ let qtlocation = callPackage ../modules/qtlocation.nix {}; qtlottie = callPackage ../modules/qtlottie.nix {}; qtmacextras = callPackage ../modules/qtmacextras.nix {}; - qtmultimedia = callPackage ../modules/qtmultimedia.nix { - inherit gstreamer gst-plugins-base; - }; + qtmultimedia = callPackage ../modules/qtmultimedia.nix {}; qtnetworkauth = callPackage ../modules/qtnetworkauth.nix {}; qtpim = callPackage ../modules/qtpim.nix {}; qtpositioning = callPackage ../modules/qtpositioning.nix {}; diff --git a/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix b/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix index d5dc16c528233..a15eb545a2ee9 100644 --- a/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix +++ b/pkgs/development/libraries/qt-5/modules/qtmultimedia.nix @@ -5,8 +5,7 @@ , qtdeclarative , pkg-config , alsa-lib -, gstreamer -, gst-plugins-base +, gst_all_1 , libpulseaudio , wayland }: @@ -15,7 +14,7 @@ qtModule { pname = "qtmultimedia"; propagatedBuildInputs = [ qtbase qtdeclarative ]; nativeBuildInputs = [ pkg-config ]; - buildInputs = [ gstreamer gst-plugins-base ] + buildInputs = [ gst_all_1.gstreamer gst_all_1.gst-plugins-base ] # https://github.com/NixOS/nixpkgs/pull/169336 regarding libpulseaudio ++ lib.optionals stdenv.isLinux [ libpulseaudio alsa-lib wayland ]; outputs = [ "bin" "dev" "out" ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f56bbb4bfd7f5..bc91eb1052f46 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23939,17 +23939,9 @@ with pkgs; quartoMinimal = callPackage ../development/libraries/quarto { rWrapper = null; python3 = null; }; - qt5 = recurseIntoAttrs (makeOverridable - (import ../development/libraries/qt-5/5.15) { - inherit (__splicedPackages) - makeScopeWithSplicing' generateSplicesForMkScope lib fetchurl fetchpatch fetchgit fetchFromGitHub makeSetupHook makeWrapper - bison cups dconf harfbuzz libGL perl gtk3 python3 - llvmPackages_15 overrideSDK overrideLibcxx - darwin buildPackages; - inherit (__splicedPackages.gst_all_1) gstreamer gst-plugins-base; - inherit config; - stdenv = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv; - }); + qt5 = recurseIntoAttrs (__splicedPackages.callPackage ../development/libraries/qt-5/5.15 { + stdenv = with __splicedPackages; if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv; + }); libsForQt5 = (recurseIntoAttrs (import ./qt5-packages.nix { inherit lib __splicedPackages makeScopeWithSplicing' generateSplicesForMkScope pkgsHostTarget; From dbabeed8379d51fbc9fede12f4e3d41abe68d6cf Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 7 Dec 2023 00:30:40 +0300 Subject: [PATCH 20/21] qt5.qtbase: remove broken QMAKEMODULES code It never worked and it's just an attempt to duplicate the logic from qmake (i.e. QMAKEPATH -> QMAKEMODULES translation) that qmake does all by itself. --- pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh index f72453f207e09..83d03d67d1eb2 100644 --- a/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh +++ b/pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh @@ -65,9 +65,6 @@ export QMAKE QMAKEPATH= export QMAKEPATH -QMAKEMODULES= -export QMAKEMODULES - declare -Ag qmakePathSeen=() qmakePathHook() { # Skip this path if we have seen it before. @@ -76,7 +73,6 @@ qmakePathHook() { qmakePathSeen[$1]=1 if [ -d "$1/mkspecs" ] then - QMAKEMODULES="${QMAKEMODULES}${QMAKEMODULES:+:}/mkspecs" QMAKEPATH="${QMAKEPATH}${QMAKEPATH:+:}$1" fi } From 27353f135c645ae40ea87946da6ebdb7978599f4 Mon Sep 17 00:00:00 2001 From: eryngion Date: Thu, 7 Dec 2023 01:06:30 +0300 Subject: [PATCH 21/21] qt5.qtbase: fix mysql support for cross builds --- pkgs/development/libraries/qt-5/5.15/default.nix | 4 ++++ pkgs/development/libraries/qt-5/modules/qtbase.nix | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 420274b5b98d8..76528789b03cb 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -46,6 +46,10 @@ let ./qtbase.patch.d/0010-qtbase-assert.patch ./qtbase.patch.d/0011-fix-header_module.patch ./qtbase.patch.d/0015-qtbase-cross-build.patch + (fetchpatch { + url = "https://sources.debian.org/data/main/q/qtbase-opensource-src/5.15.8%2Bdfsg-11/debian/patches/cross_build_mysql.diff"; + hash = "sha256-tzmmLmMXmeDwRVjdpWekDJvSkrIIlslC12HP7XPcm3E="; + }) ]; qtdeclarative = [ ./qtdeclarative.patch diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 6e4fe01e42dc0..58a3d5d219bd7 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -20,8 +20,7 @@ # options , libGLSupported ? !stdenv.isDarwin , libGL - # qmake detection for libmysqlclient does not seem to work when cross compiling -, mysqlSupport ? stdenv.hostPlatform == stdenv.buildPlatform +, mysqlSupport ? true , libmysqlclient , buildExamples ? false , buildTests ? false @@ -393,8 +392,8 @@ stdenv.mkDerivation (finalAttrs: ({ "-I" "${cups.dev}/include" ] ++ lib.optionals (mysqlSupport) [ - "-L" "${libmysqlclient}/lib" - "-I" "${libmysqlclient}/include" + "-L" "${libmysqlclient}/lib/mysql" + "-I" "${libmysqlclient.dev}/include/mysql" ] # cross compilation options