Skip to content

Commit

Permalink
Merge pull request #40269 from obsidiansystems/uclibc-18.03
Browse files Browse the repository at this point in the history
Uclibc 18.03
  • Loading branch information
Ericson2314 committed May 10, 2018
2 parents 4009b08 + a31984e commit c7be9f2
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 49 deletions.
1 change: 1 addition & 0 deletions lib/systems/default.nix
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions lib/systems/examples.nix
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions lib/systems/inspect.nix
Expand Up @@ -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" ];
Expand Down
3 changes: 3 additions & 0 deletions lib/systems/parse.nix
Expand Up @@ -193,6 +193,9 @@ rec {
musleabi = {};
musleabihf = {};
musl = {};
uclibceabihf = {};
uclibceabi = {};
uclibc = {};

unknown = {};
};
Expand Down
52 changes: 26 additions & 26 deletions 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
, fetchurl, linuxHeaders, libiconvReal
, buildPlatform, hostPlatform
, extraConfig ? ""
}:

let
configParser = ''
Expand All @@ -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 "/"
Expand All @@ -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
Expand All @@ -52,49 +49,52 @@ let
UCLIBC_HAS_FPU n
'';

name = "uclibc-0.9.34-pre-20150131";
rev = "343f6b8f1f754e397632b0552e4afe586c8b392b";

version = "1.0.30";
in

stdenv.mkDerivation {
name = name + stdenv.lib.optionalString (cross != null) ("-" + cross.config);
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
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 )
'';

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
enableParallelBuilding = false;

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
Expand All @@ -106,10 +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 = subtractLists ["aarch64-linux"] platforms.linux;
platforms = platforms.linux;
};
}
4 changes: 2 additions & 2 deletions 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
Expand All @@ -19,7 +19,7 @@ stdenv.mkDerivation {
'';

configureFlags = if gccCross != null then
"--enable-firmware CROSS_COMPILE=${crossPrefix}-"
"--enable-firmware CROSS_COMPILE=${gccCross.targetPrefix}"
else "";

hardeningDisable = [ "pic" "stackprotector" ];
Expand Down
27 changes: 6 additions & 21 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -5524,28 +5524,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;
Expand Down Expand Up @@ -8994,7 +8980,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
Expand Down Expand Up @@ -13982,10 +13968,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;
Expand Down

0 comments on commit c7be9f2

Please sign in to comment.