Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

qt5.qtbase: fix cross #227900

Merged
4 commits merged into from Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkgs/development/libraries/qt-5/5.15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ let
import ../qtModule.nix
{
inherit perl;
inherit lib;
inherit lib stdenv;
inherit buildPackages;
# Use a variant of mkDerivation that does not include wrapQtApplications
# to avoid cyclic dependencies between Qt modules.
mkDerivation =
Expand Down
2 changes: 2 additions & 0 deletions pkgs/development/libraries/qt-5/hooks/qtbase-setup-hook.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
if [[ -n "${__nix_qtbase-}" ]]; then
if [ -z "${dontWorryAboutQtMismatch-}" ]; then
# Throw an error if a different version of Qt was already set up.
if [[ "$__nix_qtbase" != "@dev@" ]]; then
echo >&2 "Error: detected mismatched Qt dependencies:"
echo >&2 " @dev@"
echo >&2 " $__nix_qtbase"
exit 1
fi
fi
else # Only set up Qt once.
__nix_qtbase="@dev@"

Expand Down
20 changes: 20 additions & 0 deletions pkgs/development/libraries/qt-5/modules/qtbase.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
, developerBuild ? false
, decryptSslTraffic ? false
, testers
, buildPackages
}:

let
debugSymbols = debug || developerBuild;
qtPlatformCross = plat: with plat;
if isLinux
then "linux-generic-g++"
else throw "Please add a qtPlatformCross entry for ${plat.config}";
in

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -82,6 +87,11 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ bison flex gperf lndir perl pkg-config which ]
++ lib.optionals stdenv.isDarwin [ xcbuild ];

# `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 ];

propagatedNativeBuildInputs = [ lndir ];

# libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked
Expand Down Expand Up @@ -161,6 +171,11 @@ stdenv.mkDerivation (finalAttrs: {
export MAKEFLAGS+=" -j$NIX_BUILD_CORES"

./bin/syncqt.pl -version $version
'' + lib.optionalString (stdenv.buildPlatform != 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
This conversation was marked as resolved.
Show resolved Hide resolved
echo "QMAKE_PKG_CONFIG=''$''${CROSS_COMPILE}pkg-config" >> mkspecs/devices/${qtPlatformCross stdenv.hostPlatform}/qmake.conf
This conversation was marked as resolved.
Show resolved Hide resolved
'';

postConfigure = ''
Expand Down Expand Up @@ -208,6 +223,8 @@ stdenv.mkDerivation (finalAttrs: {
# To prevent these failures, we need to override PostgreSQL detection.
PSQL_LIBS = lib.optionalString (postgresql != null) "-L${postgresql.lib}/lib -lpq";

# do not pass --host and --build to configureFlags as QT's configure script doesn't understand them
configurePlatforms = [ ];
# TODO Remove obsolete and useless flags once the build will be totally mastered
configureFlags = [
"-plugindir $(out)/$(qtPluginPrefix)"
Expand All @@ -234,6 +251,9 @@ stdenv.mkDerivation (finalAttrs: {
"-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 [
Expand Down
12 changes: 10 additions & 2 deletions pkgs/development/libraries/qt-5/qtModule.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ lib, mkDerivation, perl }:
{ lib
, stdenv
, mkDerivation, perl
, buildPackages
}:

let inherit (lib) licenses maintainers platforms; in

Expand All @@ -17,7 +21,8 @@ mkDerivation (args // {
patches = (args.patches or []) ++ (patches.${pname} or []);

nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ perl self.qmake ];
propagatedBuildInputs = args.qtInputs ++ (args.propagatedBuildInputs or []);
propagatedBuildInputs = (args.qtInputs or []) ++ (args.propagatedBuildInputs or []);
depsBuildBuild = [ buildPackages.stdenv.cc ];

outputs = args.outputs or [ "out" "dev" ];
setOutputFlags = args.setOutputFlags or false;
Expand Down Expand Up @@ -74,4 +79,7 @@ mkDerivation (args // {
maintainers = with maintainers; [ qknight ttuegel periklis bkchr ];
platforms = platforms.unix;
} // (args.meta or {});

} // lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
dontWorryAboutQtMismatch = true;
Comment on lines +83 to +84
Copy link
Member

Choose a reason for hiding this comment

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

(Now, since I've been made aware of this PR... let's look into it...)

Is this an appropriate change? Mismatches in Qt will lead to severe issues down the line.

I suspect it's a cross-compilation idiosyncrasy here, but without a comment explaining it, I have no way to know for sure.

If a platform name ended-up breaking this check, the platform name should be added to the check.

})