From 3fa0ba917742c0790ff5418de0db65d94ee8b82e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 6 May 2018 15:10:46 -0400 Subject: [PATCH 1/6] lib/systems: Parse more arm cpu types --- lib/systems/parse.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 8a6c951d5e5e..ffedd98c98d8 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -69,9 +69,15 @@ rec { cpuTypes = with significantBytes; setTypes types.openCpuType { arm = { bits = 32; significantByte = littleEndian; family = "arm"; }; armv5tel = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv6m = { bits = 32; significantByte = littleEndian; family = "arm"; }; armv6l = { bits = 32; significantByte = littleEndian; family = "arm"; }; armv7a = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv7r = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv7m = { bits = 32; significantByte = littleEndian; family = "arm"; }; armv7l = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv8a = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv8r = { bits = 32; significantByte = littleEndian; family = "arm"; }; + armv8m = { bits = 32; significantByte = littleEndian; family = "arm"; }; aarch64 = { bits = 64; significantByte = littleEndian; family = "arm"; }; i686 = { bits = 32; significantByte = littleEndian; family = "x86"; }; x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; }; From e42a7a5c0bdeb4c40921d319ae6a14f7e304e4df Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 May 2018 23:33:31 -0400 Subject: [PATCH 2/6] lib/systems: Add uClibc just like MUSL --- lib/systems/default.nix | 1 + lib/systems/inspect.nix | 1 + lib/systems/parse.nix | 3 +++ 3 files changed, 5 insertions(+) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index bd408e00bb14..9b9308246098 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -29,6 +29,7 @@ rec { /**/ if final.isDarwin then "libSystem" else if final.isMinGW then "msvcrt" else if final.isMusl then "musl" + else if final.isUClibc then "uclibc" else if final.isAndroid then "bionic" else if final.isLinux /* default */ then "glibc" # TODO(@Ericson2314) think more about other operating systems diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 91ae2cd2557e..6738ae3d441e 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -36,6 +36,7 @@ rec { isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ]; isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf ]; + isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ]; isKexecable = map (family: { kernel = kernels.linux; cpu.family = family; }) [ "x86" "arm" "aarch64" "mips" ]; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index ffedd98c98d8..7ba06f129db8 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -193,6 +193,9 @@ rec { musleabi = {}; musleabihf = {}; musl = {}; + uclibceabihf = {}; + uclibceabi = {}; + uclibc = {}; unknown = {}; }; From f063a860d69c5fbf3695a262da6a551ddd92a5f2 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 May 2018 22:40:27 -0400 Subject: [PATCH 3/6] xbursttools: Cleanup slightly --- lib/systems/examples.nix | 14 ++++++++++++++ pkgs/tools/misc/xburst-tools/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 18 ++---------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 848737700b0b..f3abfe2c621f 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -57,6 +57,20 @@ rec { platform = platforms.pogoplug4; }; + ben-nanonote = rec { + config = "mipsel-unknown-linux-uclibc"; + arch = "mips"; + float = "soft"; + platform = { + name = "ben_nanonote"; + kernelMajor = "2.6"; + kernelArch = "mips"; + gcc = { + arch = "mips32"; + }; + }; + }; + fuloongminipc = rec { config = "mipsel-unknown-linux-gnu"; arch = "mips"; diff --git a/pkgs/tools/misc/xburst-tools/default.nix b/pkgs/tools/misc/xburst-tools/default.nix index c64ae609bcbb..21aabc4e89cc 100644 --- a/pkgs/tools/misc/xburst-tools/default.nix +++ b/pkgs/tools/misc/xburst-tools/default.nix @@ -1,5 +1,5 @@ { stdenv, fetchgit, libusb, libusb1, autoconf, automake, confuse, pkgconfig -, gccCross ? null, crossPrefix +, gccCross ? null }: let @@ -19,7 +19,7 @@ stdenv.mkDerivation { ''; configureFlags = if gccCross != null then - "--enable-firmware CROSS_COMPILE=${crossPrefix}-" + "--enable-firmware CROSS_COMPILE=${gccCross.targetPrefix}" else ""; # Not to strip cross build binaries (this is for the gcc-cross-wrapper) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d38f8d201889..627bac20e938 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5512,28 +5512,14 @@ with pkgs; x11_ssh_askpass = callPackage ../tools/networking/x11-ssh-askpass { }; - xbursttools = assert stdenv ? glibc; callPackage ../tools/misc/xburst-tools rec { + xbursttools = callPackage ../tools/misc/xburst-tools { # It needs a cross compiler for mipsel to build the firmware it will # load into the Ben Nanonote - crossPrefix = "mipsel-unknown-linux-gnu"; gccCross = let pkgsCross = nixpkgsFun { # Ben Nanonote system - crossSystem = { - config = crossPrefix; - arch = "mips"; - float = "soft"; - libc = "uclibc"; - platform = { - name = "ben_nanonote"; - kernelMajor = "2.6"; - kernelArch = "mips"; - }; - gcc = { - arch = "mips32"; - }; - }; + crossSystem = lib.systems.examples.ben-nanonote; }; in pkgsCross.buildPackages.gccCrossStageStatic; From d65fe65616f28b60102fd9d05e593676e5a75555 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 May 2018 20:49:12 -0400 Subject: [PATCH 4/6] uclibc: Fix eval --- pkgs/os-specific/linux/uclibc/default.nix | 38 ++++++++++++----------- pkgs/top-level/all-packages.nix | 9 +++--- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix index 180aabc94cc6..426834d42255 100644 --- a/pkgs/os-specific/linux/uclibc/default.nix +++ b/pkgs/os-specific/linux/uclibc/default.nix @@ -1,8 +1,8 @@ -{stdenv, fetchzip, linuxHeaders, libiconvReal, cross ? null, gccCross ? null, -extraConfig ? ""}: - -assert stdenv.isLinux; -assert cross != null -> gccCross != null; +{ stdenv, buildPackages +, fetchzip, linuxHeaders, libiconvReal +, buildPlatform, hostPlatform +, extraConfig ? "" +}: let configParser = '' @@ -28,9 +28,6 @@ let } ''; - archMakeFlag = if cross != null then "ARCH=${cross.arch}" else ""; - crossMakeFlag = if cross != null then "CROSS=${cross.config}-" else ""; - # UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds. nixConfig = '' RUNTIME_PREFIX "/" @@ -43,7 +40,7 @@ let UCLIBC_SUSV4_LEGACY y UCLIBC_HAS_THREADS_NATIVE y KERNEL_HEADERS "${linuxHeaders}/include" - '' + stdenv.lib.optionalString (stdenv.isAarch32 && cross == null) '' + '' + stdenv.lib.optionalString (stdenv.isAarch32 && buildPlatform != hostPlatform) '' CONFIG_ARM_EABI y ARCH_WANTS_BIG_ENDIAN n ARCH_BIG_ENDIAN n @@ -58,7 +55,7 @@ let in stdenv.mkDerivation { - name = name + stdenv.lib.optionalString (cross != null) ("-" + cross.config); + inherit name; src = fetchzip { name = name + "-source"; @@ -68,13 +65,12 @@ stdenv.mkDerivation { # 'ftw' needed to build acl, a coreutils dependency configurePhase = '' - make defconfig ${archMakeFlag} + make defconfig ${configParser} cat << EOF | parseconfig ${nixConfig} ${extraConfig} - ${if cross != null then stdenv.lib.attrByPath [ "uclibc" "extraConfig" ] "" cross else ""} - $extraCrossConfig + ${hostPlatform.platform.uclibc.extraConfig or ""} EOF ( set +o pipefail; yes "" | make oldconfig ) ''; @@ -82,11 +78,16 @@ stdenv.mkDerivation { hardeningDisable = [ "stackprotector" ]; # Cross stripping hurts. - dontStrip = cross != null; + dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; - makeFlags = [ crossMakeFlag "VERBOSE=1" ]; + depsBuildBuild = [ buildPackages.stdenv.cc ]; - buildInputs = stdenv.lib.optional (gccCross != null) gccCross; + makeFlags = [ + "ARCH=${hostPlatform.parsed.cpu.name}" + "VERBOSE=1" + ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "CROSS=${stdenv.cc.targetPrefix}" + ]; # `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`: # error: bits/sysnum.h: No such file or directory @@ -94,7 +95,7 @@ stdenv.mkDerivation { installPhase = '' mkdir -p $out - make PREFIX=$out VERBOSE=1 install ${crossMakeFlag} + make PREFIX=$out VERBOSE=1 install (cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .) # libpthread.so may not exist, so I do || true sed -i s@/lib/@$out/lib/@g $out/lib/libc.so $out/lib/libpthread.so || true @@ -110,6 +111,7 @@ stdenv.mkDerivation { description = "A small implementation of the C library"; maintainers = with maintainers; [ rasendubi ]; license = licenses.lgpl2; - platforms = subtractLists ["aarch64-linux"] platforms.linux; + platforms = platforms.linux; + broken = hostPlatform.isAarch64; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 627bac20e938..c27168530e0e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8903,7 +8903,7 @@ with pkgs; # hack fixes the hack, *sigh*. /**/ if name == "glibc" then targetPackages.glibcCross or glibcCross else if name == "bionic" then targetPackages.bionic - else if name == "uclibc" then uclibcCross + else if name == "uclibc" then targetPackages.uclibcCross else if name == "musl" then targetPackages.muslCross or muslCross else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 else if name == "libSystem" then darwin.xcode @@ -13819,10 +13819,9 @@ with pkgs; uclibc = callPackage ../os-specific/linux/uclibc { }; - uclibcCross = lowPrio (callPackage ../os-specific/linux/uclibc { - gccCross = gccCrossStageStatic; - cross = assert targetPlatform != buildPlatform; targetPlatform; - }); + uclibcCross = callPackage ../os-specific/linux/uclibc { + stdenv = crossLibcStdenv; + }; udev = systemd; libudev = udev; From a31984ecdaf7b011163c3c71679eb285d951d735 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 9 May 2018 23:20:29 -0400 Subject: [PATCH 5/6] uclibc: Bump to uclibc-ng 1.0.30 --- pkgs/os-specific/linux/uclibc/default.nix | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pkgs/os-specific/linux/uclibc/default.nix b/pkgs/os-specific/linux/uclibc/default.nix index 426834d42255..3da12c41dc12 100644 --- a/pkgs/os-specific/linux/uclibc/default.nix +++ b/pkgs/os-specific/linux/uclibc/default.nix @@ -1,5 +1,5 @@ { stdenv, buildPackages -, fetchzip, linuxHeaders, libiconvReal +, fetchurl, linuxHeaders, libiconvReal , buildPlatform, hostPlatform , extraConfig ? "" }: @@ -49,18 +49,17 @@ let UCLIBC_HAS_FPU n ''; - name = "uclibc-0.9.34-pre-20150131"; - rev = "343f6b8f1f754e397632b0552e4afe586c8b392b"; - + version = "1.0.30"; in stdenv.mkDerivation { - inherit name; + name = "uclibc-ng-${version}"; + inherit version; - src = fetchzip { - name = name + "-source"; - url = "http://git.uclibc.org/uClibc/snapshot/uClibc-${rev}.tar.bz2"; - sha256 = "1kgylzpid7da5i7wz7slh5q9rnq1m8bv5h9ilm76g0xwc2iwlhbw"; + src = fetchurl { + url = "https://downloads.uclibc-ng.org/releases/${version}/uClibc-ng-${version}.tar.bz2"; + # from "${url}.sha256"; + sha256 = "3e0f057f24882823d697126015aa4d7d48fa2542be3939985cb3c26dcbcab5a8"; }; # 'ftw' needed to build acl, a coreutils dependency @@ -107,11 +106,10 @@ stdenv.mkDerivation { }; meta = with stdenv.lib; { - homepage = http://www.uclibc.org/; + homepage = "https://uclibc-ng.org"; description = "A small implementation of the C library"; maintainers = with maintainers; [ rasendubi ]; license = licenses.lgpl2; platforms = platforms.linux; - broken = hostPlatform.isAarch64; }; } From a02be2bd85b37ed8b257e969d9439357844baa24 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 10 May 2018 00:57:52 -0400 Subject: [PATCH 6/6] treewide: Get rid of `*Platform.arch` Use `parsed.cpu.name` or `platform.gcc.arch` instead. --- lib/systems/examples.nix | 12 +----------- pkgs/applications/video/omxplayer/default.nix | 2 +- pkgs/development/libraries/ffmpeg-full/default.nix | 2 +- pkgs/development/libraries/ffmpeg/generic.nix | 2 +- pkgs/development/libraries/fontconfig/2.10.nix | 4 +++- pkgs/development/libraries/fontconfig/default.nix | 4 +++- pkgs/development/libraries/libav/default.nix | 2 +- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index f3abfe2c621f..80e320406bf4 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -11,22 +11,19 @@ rec { sheevaplug = rec { config = "armv5tel-unknown-linux-gnueabi"; - arch = "armv5tel"; float = "soft"; platform = platforms.sheevaplug; }; raspberryPi = rec { config = "armv6l-unknown-linux-gnueabihf"; - arch = "armv6l"; float = "hard"; fpu = "vfp"; platform = platforms.raspberrypi; }; armv7l-hf-multiplatform = rec { - config = "arm-unknown-linux-gnueabihf"; - arch = "armv7-a"; + config = "armv7a-unknown-linux-gnueabihf"; float = "hard"; fpu = "vfpv3-d16"; platform = platforms.armv7l-hf-multiplatform; @@ -34,13 +31,11 @@ rec { aarch64-multiplatform = rec { config = "aarch64-unknown-linux-gnu"; - arch = "aarch64"; platform = platforms.aarch64-multiplatform; }; aarch64-android-prebuilt = rec { config = "aarch64-unknown-linux-android"; - arch = "aarch64"; platform = platforms.aarch64-multiplatform; useAndroidPrebuilt = true; }; @@ -51,7 +46,6 @@ rec { }; pogoplug4 = rec { - arch = "armv5tel"; config = "armv5tel-unknown-linux-gnueabi"; float = "soft"; platform = platforms.pogoplug4; @@ -59,7 +53,6 @@ rec { ben-nanonote = rec { config = "mipsel-unknown-linux-uclibc"; - arch = "mips"; float = "soft"; platform = { name = "ben_nanonote"; @@ -73,7 +66,6 @@ rec { fuloongminipc = rec { config = "mipsel-unknown-linux-gnu"; - arch = "mips"; float = "hard"; platform = platforms.fuloong2f_n32; }; @@ -122,7 +114,6 @@ rec { # 32 bit mingw-w64 mingw32 = { config = "i686-pc-mingw32"; - arch = "x86"; # Irrelevant libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain platform = {}; }; @@ -131,7 +122,6 @@ rec { mingwW64 = { # That's the triplet they use in the mingw-w64 docs. config = "x86_64-pc-mingw32"; - arch = "x86_64"; # Irrelevant libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain platform = {}; }; diff --git a/pkgs/applications/video/omxplayer/default.nix b/pkgs/applications/video/omxplayer/default.nix index 825bfe7955a8..520451df400f 100644 --- a/pkgs/applications/video/omxplayer/default.nix +++ b/pkgs/applications/video/omxplayer/default.nix @@ -52,7 +52,7 @@ let "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" "--target_os=linux" - "--arch=${hostPlatform.arch}" + "--arch=${hostPlatform.parsed.cpu.name}" ]; }; diff --git a/pkgs/development/libraries/ffmpeg-full/default.nix b/pkgs/development/libraries/ffmpeg-full/default.nix index 67e364715f09..f991418ffdab 100644 --- a/pkgs/development/libraries/ffmpeg-full/default.nix +++ b/pkgs/development/libraries/ffmpeg-full/default.nix @@ -442,7 +442,7 @@ stdenv.mkDerivation rec { "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" "--target_os=${hostPlatform.parsed.kernel.name}" - "--arch=${hostPlatform.arch}" + "--arch=${hostPlatform.parsed.cpu.name}" ]; }; diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index 4a05eab87bd7..530639d757de 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -176,7 +176,7 @@ stdenv.mkDerivation rec { "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" "--target_os=${hostPlatform.parsed.kernel.name}" - "--arch=${hostPlatform.arch}" + "--arch=${hostPlatform.parsed.cpu.name}" ]; }; diff --git a/pkgs/development/libraries/fontconfig/2.10.nix b/pkgs/development/libraries/fontconfig/2.10.nix index 3f3c04b15a30..5fb0ea4429e7 100644 --- a/pkgs/development/libraries/fontconfig/2.10.nix +++ b/pkgs/development/libraries/fontconfig/2.10.nix @@ -24,7 +24,9 @@ stdenv.mkDerivation rec { ]; # We should find a better way to access the arch reliably. - crossArch = hostPlatform.arch or null; + crossArch = if stdenv.hostPlatform != stdenv.buildPlatform + then hostPlatform.parsed.cpu.name + else null; preConfigure = '' if test -n "$crossConfig"; then diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index 9c4116c8f0ba..ce41f1ac7ebc 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -56,7 +56,9 @@ stdenv.mkDerivation rec { ]; # We should find a better way to access the arch reliably. - crossArch = hostPlatform.arch or null; + crossArch = if stdenv.hostPlatform != stdenv.buildPlatform + then hostPlatform.parsed.cpu.name + else null; preConfigure = '' if test -n "$crossConfig"; then diff --git a/pkgs/development/libraries/libav/default.nix b/pkgs/development/libraries/libav/default.nix index a069894f6c8c..1b52d18fd6b1 100644 --- a/pkgs/development/libraries/libav/default.nix +++ b/pkgs/development/libraries/libav/default.nix @@ -113,7 +113,7 @@ let "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" "--target_os=linux" - "--arch=${hostPlatform.arch}" + "--arch=${hostPlatform.parsed.cpu.name}" ]; };