13 stdenv = stdenvNoLibc;
14 isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
16 function parseconfig {
19 NAME=`echo "$LINE" | cut -d \ -f 1`
20 OPTION=`echo "$LINE" | cut -d \ -f 2`
22 if test -z "$NAME"; then
26 echo "parseconfig: removing $NAME"
27 sed -i /^$NAME=/d .config
29 #if test "$OPTION" != n; then
30 echo "parseconfig: setting $NAME=$OPTION"
31 echo "$NAME=$OPTION" >> .config
38 # UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
47 UCLIBC_HAS_PROGRAM_INVOCATION_NAME y
48 UCLIBC_HAS_RESOLVER_SUPPORT y
50 UCLIBC_HAS_THREADS_NATIVE y
51 KERNEL_HEADERS "${linuxHeaders}/include"
53 + lib.optionalString (stdenv.hostPlatform.gcc.float or "" == "soft") ''
56 + lib.optionalString (stdenv.hostPlatform.isAarch32 && isCross) ''
58 ARCH_WANTS_BIG_ENDIAN n
60 ARCH_WANTS_LITTLE_ENDIAN y
65 stdenv.mkDerivation (finalAttrs: {
70 url = "https://downloads.uclibc-ng.org/releases/${finalAttrs.version}/uClibc-ng-${finalAttrs.version}.tar.xz";
71 hash = "sha256-rthnJR9II6dOpeOjmT06fBIygKvhXjjcIGdww5aPIc8=";
74 # 'ftw' needed to build acl, a coreutils dependency
78 cat << EOF | parseconfig
81 ${stdenv.hostPlatform.uclibc.extraConfig or ""}
83 ( set +o pipefail; yes "" | make oldconfig )
86 hardeningDisable = [ "stackprotector" ];
88 # Cross stripping hurts.
91 depsBuildBuild = [ buildPackages.stdenv.cc ];
95 "ARCH=${stdenv.hostPlatform.linuxArch}"
96 "TARGET_ARCH=${stdenv.hostPlatform.linuxArch}"
99 ++ lib.optionals (isCross) [
100 "CROSS=${stdenv.cc.targetPrefix}"
103 # `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`:
104 # error: bits/sysnum.h: No such file or directory
105 enableParallelBuilding = false;
111 make $makeFlags PREFIX=$out VERBOSE=1 install
112 (cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
113 # libpthread.so may not exist, so I do || true
114 sed -i s@/lib/@$out/lib/@g $out/lib/libc.so $out/lib/libpthread.so || true
120 # Derivations may check for the existance of this attribute, to know what to
122 libiconv = libiconvReal;
124 updateScript = gitUpdater {
125 url = "https://git.uclibc-ng.org/git/uclibc-ng.git";
131 homepage = "https://uclibc-ng.org";
132 description = "Embedded C library";
134 uClibc-ng is a small C library for developing embedded Linux systems. It
135 is much smaller than the GNU C Library, but nearly all applications
136 supported by glibc also work perfectly with uClibc-ng.
138 Porting applications from glibc to uClibc-ng typically involves just
139 recompiling the source code. uClibc-ng supports shared libraries and
140 threading. It currently runs on standard Linux and MMU-less (also known as
141 uClinux) systems with support for Aarch64, Alpha, ARC, ARM, AVR32,
142 Blackfin, CRIS, C-Sky, C6X, FR-V, H8/300, HPPA, i386, IA64, KVX, LM32,
143 M68K/Coldfire, Metag, Microblaze, MIPS, MIPS64, NDS32, NIOS2, OpenRISC,
144 PowerPC, RISCV64, Sparc, Sparc64, SuperH, Tile, X86_64 and XTENSA
145 processors. Alpha, FR-V, HPPA, IA64, LM32, NIOS2, Tile and Sparc64 are
146 experimental and need more testing.
148 license = lib.licenses.lgpl2Plus;
149 maintainers = with lib.maintainers; [
153 platforms = lib.platforms.linux;
154 badPlatforms = lib.platforms.aarch64;