12 stdenv = stdenvNoLibc;
13 isCross = (stdenv.buildPlatform != stdenv.hostPlatform);
15 function parseconfig {
18 NAME=`echo "$LINE" | cut -d \ -f 1`
19 OPTION=`echo "$LINE" | cut -d \ -f 2`
21 if test -z "$NAME"; then
25 echo "parseconfig: removing $NAME"
26 sed -i /^$NAME=/d .config
28 #if test "$OPTION" != n; then
29 echo "parseconfig: setting $NAME=$OPTION"
30 echo "$NAME=$OPTION" >> .config
37 # UCLIBC_SUSV4_LEGACY defines 'tmpnam', needed for gcc libstdc++ builds.
45 UCLIBC_HAS_PROGRAM_INVOCATION_NAME y
46 UCLIBC_HAS_RESOLVER_SUPPORT y
48 UCLIBC_HAS_THREADS_NATIVE y
49 KERNEL_HEADERS "${linuxHeaders}/include"
50 '' + lib.optionalString (stdenv.hostPlatform.gcc.float or "" == "soft") ''
52 '' + lib.optionalString (stdenv.hostPlatform.isAarch32 && isCross) ''
54 ARCH_WANTS_BIG_ENDIAN n
56 ARCH_WANTS_LITTLE_ENDIAN y
61 stdenv.mkDerivation (finalAttrs: {
66 url = "https://downloads.uclibc-ng.org/releases/${finalAttrs.version}/uClibc-ng-${finalAttrs.version}.tar.xz";
67 hash = "sha256-rthnJR9II6dOpeOjmT06fBIygKvhXjjcIGdww5aPIc8=";
70 # 'ftw' needed to build acl, a coreutils dependency
74 cat << EOF | parseconfig
77 ${stdenv.hostPlatform.uclibc.extraConfig or ""}
79 ( set +o pipefail; yes "" | make oldconfig )
82 hardeningDisable = [ "stackprotector" ];
84 # Cross stripping hurts.
87 depsBuildBuild = [ buildPackages.stdenv.cc ];
90 "ARCH=${stdenv.hostPlatform.linuxArch}"
91 "TARGET_ARCH=${stdenv.hostPlatform.linuxArch}"
93 ] ++ lib.optionals (isCross) [
94 "CROSS=${stdenv.cc.targetPrefix}"
97 # `make libpthread/nptl/sysdeps/unix/sysv/linux/lowlevelrwlock.h`:
98 # error: bits/sysnum.h: No such file or directory
99 enableParallelBuilding = false;
105 make $makeFlags PREFIX=$out VERBOSE=1 install
106 (cd $out/include && ln -s $(ls -d ${linuxHeaders}/include/* | grep -v "scsi$") .)
107 # libpthread.so may not exist, so I do || true
108 sed -i s@/lib/@$out/lib/@g $out/lib/libc.so $out/lib/libpthread.so || true
114 # Derivations may check for the existance of this attribute, to know what to
116 libiconv = libiconvReal;
118 updateScript = gitUpdater {
119 url = "https://git.uclibc-ng.org/git/uclibc-ng.git";
125 homepage = "https://uclibc-ng.org";
126 description = "Embedded C library";
128 uClibc-ng is a small C library for developing embedded Linux systems. It
129 is much smaller than the GNU C Library, but nearly all applications
130 supported by glibc also work perfectly with uClibc-ng.
132 Porting applications from glibc to uClibc-ng typically involves just
133 recompiling the source code. uClibc-ng supports shared libraries and
134 threading. It currently runs on standard Linux and MMU-less (also known as
135 uClinux) systems with support for Aarch64, Alpha, ARC, ARM, AVR32,
136 Blackfin, CRIS, C-Sky, C6X, FR-V, H8/300, HPPA, i386, IA64, KVX, LM32,
137 M68K/Coldfire, Metag, Microblaze, MIPS, MIPS64, NDS32, NIOS2, OpenRISC,
138 PowerPC, RISCV64, Sparc, Sparc64, SuperH, Tile, X86_64 and XTENSA
139 processors. Alpha, FR-V, HPPA, IA64, LM32, NIOS2, Tile and Sparc64 are
140 experimental and need more testing.
142 license = lib.licenses.lgpl2Plus;
143 maintainers = with lib.maintainers; [ rasendubi AndersonTorres ];
144 platforms = lib.platforms.linux;
145 badPlatforms = lib.platforms.aarch64;