diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-11-03 22:14:43 -0700 |
---|---|---|
committer | Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com> | 2023-11-05 00:55:16 +0000 |
commit | 80c4676224571c249df4d3e255fe0ac848af0ece (patch) | |
tree | fa2969e2346c99447e2933f2d13eb008522c8dc6 /pkgs/development/libraries | |
parent | c591f4d63596a0e4ca226ace2182f6a531768c5d (diff) | |
download | nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar.gz nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar.bz2 nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar.lz nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar.xz nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.tar.zst nixlib-80c4676224571c249df4d3e255fe0ac848af0ece.zip |
qt5.qtbase: fix cross
Diffstat (limited to 'pkgs/development/libraries')
-rw-r--r-- | pkgs/development/libraries/qt-5/modules/qtbase.nix | 62 |
1 files changed, 51 insertions, 11 deletions
diff --git a/pkgs/development/libraries/qt-5/modules/qtbase.nix b/pkgs/development/libraries/qt-5/modules/qtbase.nix index 9f0feaf94e58..67e9bd5440d1 100644 --- a/pkgs/development/libraries/qt-5/modules/qtbase.nix +++ b/pkgs/development/libraries/qt-5/modules/qtbase.nix @@ -29,13 +29,18 @@ , 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: { +stdenv.mkDerivation (finalAttrs: ({ pname = "qtbase"; inherit qtCompatVersion src version; debug = debugSymbols; @@ -83,6 +88,13 @@ stdenv.mkDerivation (finalAttrs: { 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 ]; + } // { + propagatedNativeBuildInputs = [ lndir ]; # libQt5Core links calls CoreFoundation APIs that call into the system ICU. Binaries linked @@ -162,6 +174,13 @@ 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 + 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 ''; postConfigure = '' @@ -186,21 +205,34 @@ stdenv.mkDerivation (finalAttrs: { done ''; - env.NIX_CFLAGS_COMPILE = toString ([ - "-Wno-error=sign-compare" # freetype-2.5.4 changed signedness of some struct fields - ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"'' - ''-DLIBRESOLV_SO="${stdenv.cc.libc.out}/lib/libresolv"'' - ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"'' - ] ++ lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"'' + 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" + ] ++ [ + ''-DNIXPKGS_QTCOMPOSE="${libX11.out}/share/X11/locale"'' + ''-DLIBRESOLV_SO="${stdenv.cc.libc.out}/lib/libresolv"'' + ''-DNIXPKGS_LIBXCURSOR="${libXcursor.out}/lib/libXcursor"'' + ] ++ lib.optional libGLSupported ''-DNIXPKGS_MESA_GL="${libGL.out}/lib/libGL"'' ++ lib.optional stdenv.isLinux "-DUSE_X11" ++ lib.optionals (stdenv.hostPlatform.system == "x86_64-darwin") [ # ignore "is only available on macOS 10.12.2 or newer" in obj-c code "-Wno-error=unguarded-availability" ] ++ lib.optionals withGtk3 [ - ''-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"); + ''-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 "; @@ -209,6 +241,9 @@ 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) { + configurePlatforms = [ ]; + } // { # TODO Remove obsolete and useless flags once the build will be totally mastered configureFlags = [ "-plugindir $(out)/$(qtPluginPrefix)" @@ -235,11 +270,16 @@ 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 [ "-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 [ @@ -381,4 +421,4 @@ stdenv.mkDerivation (finalAttrs: { platforms = platforms.unix; }; -}) +})) |