summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/misc/newlib/default.nix34
-rw-r--r--pkgs/top-level/all-packages.nix8
2 files changed, 41 insertions, 1 deletions
diff --git a/pkgs/development/misc/newlib/default.nix b/pkgs/development/misc/newlib/default.nix
new file mode 100644
index 000000000000..e26f0f78f210
--- /dev/null
+++ b/pkgs/development/misc/newlib/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchurl, buildPackages }:
+
+let version = "3.0.0";
+in stdenv.mkDerivation {
+  name = "newlib-${version}";
+  src = fetchurl {
+    url = "ftp://sourceware.org/pub/newlib/newlib-${version}.tar.gz";
+    sha256 = "0chka3szh50krcz2dcxcsr1v1i000jylwnsrp2pgrrblxqsn6mn8";
+  };
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+
+  # newlib expects CC to build for build platform, not host platform
+  preConfigure = ''
+    export CC=cc
+  '';
+
+  configurePlatforms = [ "build" "target" ];
+  configureFlags = [
+    "--host=${stdenv.buildPlatform.config}"
+
+    "--disable-newlib-supplied-syscalls"
+    "--disable-nls"
+    "--enable-newlib-io-long-long"
+    "--enable-newlib-register-fini"
+  ];
+
+  dontDisableStatic = true;
+
+  passthru = {
+    incdir = "/${stdenv.hostPlatform.config}/include";
+    libdir = "/${stdenv.hostPlatform.config}/lib";
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index c6e2205a0bb9..d4749c1f49ba 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -9743,7 +9743,8 @@ with pkgs;
     /**/ if name == "glibc" then targetPackages.glibcCross or glibcCross
     else if name == "bionic" then targetPackages.bionic
     else if name == "uclibc" then targetPackages.uclibcCross
-    else if name == "avrlibc" then targetPackages.avrlibcCross
+    else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross
+    else if name == "newlib" then targetPackages.newlibCross or newlibCross
     else if name == "musl" then targetPackages.muslCross or muslCross
     else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
     else if stdenv.targetPlatform.useiOSPrebuilt then targetPackages.darwin.iosSdkPkgs.libraries
@@ -22836,4 +22837,9 @@ with pkgs;
   };
 
   tsung = callPackage ../applications/networking/tsung {};
+
+  newlib = callPackage ../development/misc/newlib { };
+  newlibCross = callPackage ../development/misc/newlib {
+    stdenv = crossLibcStdenv;
+  };
 }