gdb: Modernize and simplify derivation

- `isGNU` to `isHurd`, my sedding did not catch
- Simplify cross compilation in general
- Be more careful about python
- no more `gdbCross` in all-packages

+29 -41
+28 -36
pkgs/development/tools/misc/gdb/default.nix
··· 1 1 { fetchurl, stdenv, ncurses, readline, gmp, mpfr, expat, texinfo, zlib 2 2 , dejagnu, perl, pkgconfig 3 - , python ? null 3 + 4 + , buildPlatform, hostPlatform, targetPlatform 5 + 6 + , pythonSupport ? hostPlatform == buildPlatform && !hostPlatform.isCygwin, python ? null 4 7 , guile ? null 5 - , target ? null 8 + 6 9 # Support all known targets in one gdb binary. 7 10 , multitarget ? false 11 + 8 12 # Additional dependencies for GNU/Hurd. 9 13 , mig ? null, hurd ? null 10 - 11 14 }: 12 15 13 16 let 14 - 15 - basename = "gdb-7.12.1"; 16 - 17 - # Whether (cross-)building for GNU/Hurd. This is an approximation since 18 - # having `stdenv ? cross' doesn't tell us if we're building `crossDrv' and 19 - # `nativeDrv'. 20 - isGNU = 21 - stdenv.system == "i686-gnu" 22 - || (stdenv ? cross && stdenv.cross.config == "i586-pc-gnu"); 23 - 17 + basename = "gdb-${version}"; 18 + version = "7.12.1"; 24 19 in 25 20 26 - assert isGNU -> mig != null && hurd != null; 21 + assert targetPlatform.isHurd -> mig != null && hurd != null; 22 + assert pythonSupport -> python != null; 27 23 28 24 stdenv.mkDerivation rec { 29 - name = basename + stdenv.lib.optionalString (target != null) 30 - ("-" + target.config); 25 + name = 26 + stdenv.lib.optionalString (targetPlatform != hostPlatform) 27 + (targetPlatform.config + "-") 28 + + basename; 31 29 32 30 src = fetchurl { 33 31 url = "mirror://gnu/gdb/${basename}.tar.xz"; ··· 35 33 }; 36 34 37 35 nativeBuildInputs = [ pkgconfig texinfo perl ] 38 - ++ stdenv.lib.optional isGNU mig; 36 + # TODO(@Ericson2314) not sure if should be host or target 37 + ++ stdenv.lib.optional targetPlatform.isHurd mig; 39 38 40 - buildInputs = [ ncurses readline gmp mpfr expat zlib python guile ] 41 - ++ stdenv.lib.optional isGNU hurd 39 + buildInputs = [ ncurses readline gmp mpfr expat zlib guile ] 40 + ++ stdenv.lib.optional pythonSupport python 41 + ++ stdenv.lib.optional targetPlatform.isHurd hurd 42 42 ++ stdenv.lib.optional doCheck dejagnu; 43 43 44 44 enableParallelBuilding = true; ··· 46 46 # darwin build fails with format hardening since v7.12 47 47 hardeningDisable = stdenv.lib.optionals stdenv.isDarwin [ "format" ]; 48 48 49 - configureFlags = with stdenv.lib; 50 - [ "--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline" 51 - "--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}" 49 + configureFlags = with stdenv.lib; [ 50 + "--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline" 51 + "--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}" 52 + ] ++ stdenv.lib.optional hostPlatform.isLinux 53 + # TODO(@Ericson2314): make this conditional on whether host platform is NixOS 52 54 "--with-separate-debug-dir=/run/current-system/sw/lib/debug" 53 - ] 54 - ++ optional (target != null) "--target=${target.config}" 55 - ++ optional multitarget "--enable-targets=all" 56 - ++ optional (elem stdenv.system platforms.cygwin) "--without-python"; 57 - 58 - crossAttrs = { 59 - # Do not add --with-python here to avoid cross building it. 60 - configureFlags = with stdenv.lib; 61 - [ "--with-gmp=${gmp.crossDrv}" "--with-mpfr=${mpfr.crossDrv}" "--with-system-readline" 62 - "--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.crossDrv}" "--without-python" 63 - ] 64 - ++ optional (target != null) "--target=${target.config}" 65 - ++ optional multitarget "--enable-targets=all"; 66 - }; 55 + ++ stdenv.lib.optional (!pythonSupport) "--without-python" 56 + # TODO(@Ericson2314): This should be done in stdenv, not per-package 57 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "--target=${target.config}" 58 + ++ stdenv.lib.optional multitarget "--enable-targets=all"; 67 59 68 60 postInstall = 69 61 '' # Remove Info files already provided by Binutils and other packages.
-4
pkgs/top-level/all-packages.nix
··· 7076 7076 7077 7077 gdbGuile = lowPrio (gdb.override { inherit guile; }); 7078 7078 7079 - gdbCross = lowPrio (callPackage ../development/tools/misc/gdb { 7080 - target = if targetPlatform != buildPlatform then targetPlatform else null; 7081 - }); 7082 - 7083 7079 gdb-multitarget = lowPrio (gdb.override { multitarget = true; }); 7084 7080 7085 7081 valgrind = callPackage ../development/tools/analysis/valgrind {
+1 -1
pkgs/top-level/release-cross.nix
··· 24 24 }; 25 25 26 26 linuxCommon = lib.recursiveUpdate gnuCommon { 27 - buildPackages.gdbCross = nativePlatforms; 27 + buildPackages.gdb = nativePlatforms; 28 28 29 29 bison = nativePlatforms; 30 30 busybox = nativePlatforms;