summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-10-12 15:09:59 -0500
committerMatthew Bauer <mjbauer95@gmail.com>2018-10-29 14:34:09 -0500
commitd59a9ac7cf5e17f42aa1d971028f108864f2d252 (patch)
treeb6a8dd275ba5fdcb10b2d8c1cc0c5c004702ffe0
parent075e4883e0abea400aecb886e6244a6c2acf7bd8 (diff)
downloadnixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar.gz
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar.bz2
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar.lz
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar.xz
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.tar.zst
nixlib-d59a9ac7cf5e17f42aa1d971028f108864f2d252.zip
avr: use new compilation infrastructure
Gets rid of:
  avrbinutils
  avrgcc

to replace with:
  pkgsCross.avr.buildPackages.binutils
  pkgsCross.avr.buildPackages.gcc
-rw-r--r--lib/systems/examples.nix4
-rw-r--r--lib/systems/inspect.nix1
-rw-r--r--lib/systems/parse.nix5
-rw-r--r--pkgs/build-support/bintools-wrapper/default.nix1
-rw-r--r--pkgs/development/misc/avr/binutils/default.nix22
-rw-r--r--pkgs/development/misc/avr/gcc/avrbinutils-path.patch15
-rw-r--r--pkgs/development/misc/avr/gcc/default.nix60
-rw-r--r--pkgs/development/misc/avr/libc/default.nix17
-rw-r--r--pkgs/top-level/all-packages.nix12
9 files changed, 19 insertions, 118 deletions
diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix
index 8ba03a63fd8d..e19143543902 100644
--- a/lib/systems/examples.nix
+++ b/lib/systems/examples.nix
@@ -99,6 +99,10 @@ rec {
   riscv64 = riscv "64";
   riscv32 = riscv "32";
 
+  arduino-uno = {
+    config = "avr";
+    platform = { name = "avr5"; };
+  };
 
   #
   # Darwin
diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix
index 65f560328af5..2fcf1afe4628 100644
--- a/lib/systems/inspect.nix
+++ b/lib/systems/inspect.nix
@@ -19,6 +19,7 @@ rec {
     isRiscV        = { cpu = { family = "riscv"; }; };
     isSparc        = { cpu = { family = "sparc"; }; };
     isWasm         = { cpu = { family = "wasm"; }; };
+    isAvr          = { cpu = { family = "avr"; }; };
 
     is32bit        = { cpu = { bits = 32; }; };
     is64bit        = { cpu = { bits = 64; }; };
diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix
index bb26c93f3d7a..058d4bed9085 100644
--- a/lib/systems/parse.nix
+++ b/lib/systems/parse.nix
@@ -101,6 +101,8 @@ rec {
 
     wasm32   = { bits = 32; significantByte = littleEndian; family = "wasm"; };
     wasm64   = { bits = 64; significantByte = littleEndian; family = "wasm"; };
+
+    avr      = { bits = 8; family = "avr"; };
   };
 
   ################################################################################
@@ -255,6 +257,9 @@ rec {
     setType "system" components;
 
   mkSkeletonFromList = l: {
+    "1" = if elemAt l 0 == "avr"
+      then { cpu = elemAt l 0; kernel = "none"; abi = "unknown"; }
+      else throw "Target specification with 1 components is ambiguous";
     "2" = # We only do 2-part hacks for things Nix already supports
       if elemAt l 1 == "cygwin"
         then { cpu = elemAt l 0;                      kernel = "windows";  abi = "cygnus";   }
diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix
index f9ca245beea6..99f556b973a1 100644
--- a/pkgs/build-support/bintools-wrapper/default.nix
+++ b/pkgs/build-support/bintools-wrapper/default.nix
@@ -186,6 +186,7 @@ stdenv.mkDerivation {
         }.${targetPlatform.parsed.cpu.name}
       else if targetPlatform.isPower then if targetPlatform.isBigEndian then "ppc" else "lppc"
       else if targetPlatform.isSparc then "sparc"
+      else if targetPlatform.isAvr then "avr"
       else throw "unknown emulation for platform: " + targetPlatform.config;
     in targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
 
diff --git a/pkgs/development/misc/avr/binutils/default.nix b/pkgs/development/misc/avr/binutils/default.nix
deleted file mode 100644
index 83ba93e63b76..000000000000
--- a/pkgs/development/misc/avr/binutils/default.nix
+++ /dev/null
@@ -1,22 +0,0 @@
-{ stdenv, fetchurl }:
-
-let
-  version = "2.31.1";
-in
-stdenv.mkDerivation {
-  name = "avr-binutils-${version}";
-
-  src = fetchurl {
-    url = "mirror://gnu/binutils/binutils-${version}.tar.bz2";
-    sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z";
-  };
-  configureFlags = [ "--target=avr" "--enable-languages=c,c++" ];
-
-  meta = with stdenv.lib; {
-    description = "the GNU Binutils for AVR microcontrollers";
-    homepage = http://www.gnu.org/software/binutils/;
-    license = licenses.gpl3Plus;
-    platforms = platforms.unix;
-    maintainers = with maintainers; [ mguentner ];
-  };
-}
diff --git a/pkgs/development/misc/avr/gcc/avrbinutils-path.patch b/pkgs/development/misc/avr/gcc/avrbinutils-path.patch
deleted file mode 100644
index f0ec21b7589f..000000000000
--- a/pkgs/development/misc/avr/gcc/avrbinutils-path.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
-index 838ebc2..3ac4ee7 100644
---- a/gcc/gcc-ar.c
-+++ b/gcc/gcc-ar.c
-@@ -118,8 +118,8 @@ setup_prefixes (const char *exec_path)
- 				dir_separator, NULL);
-   prefix_from_string (self_libexec_prefix, &target_path);
- 
--  /* Add path as a last resort.  */
--  prefix_from_env ("PATH", &path);
-+  /* Add path to avrbinutils.  */
-+  prefix_from_string ("@avrbinutils@/bin", &path);
- }
- 
- int 
diff --git a/pkgs/development/misc/avr/gcc/default.nix b/pkgs/development/misc/avr/gcc/default.nix
deleted file mode 100644
index 5c9b56c99183..000000000000
--- a/pkgs/development/misc/avr/gcc/default.nix
+++ /dev/null
@@ -1,60 +0,0 @@
-{ stdenv, fetchurl, gmp, mpfr, libmpc, zlib, avrbinutils, texinfo }:
-
-let
-  version = "8.2.0";
-in
-stdenv.mkDerivation {
-
-  name = "avr-gcc-${version}";
-  src = fetchurl {
-    url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
-    sha256 = "10007smilswiiv2ymazr3b6x2i933c0ycxrr529zh4r6p823qv0r";
-  };
-
-  patches = [
-    ./avrbinutils-path.patch
-  ];
-
-  # avrbinutils-path.patch introduces a reference to @avrbinutils@, substitute
-  # it now.
-  postPatch = ''
-    substituteInPlace gcc/gcc-ar.c --subst-var-by avrbinutils ${avrbinutils}
-  '';
-
-  buildInputs = [ gmp mpfr libmpc zlib avrbinutils ];
-
-  nativeBuildInputs = [ texinfo ];
-
-  hardeningDisable = [ "format" ];
-
-  stripDebugList= [ "bin" "libexec" ];
-
-  enableParallelBuilding = true;
-
-  configurePhase = ''
-    mkdir gcc-build
-    cd gcc-build
-    ../configure   \
-    --prefix=$out  \
-    --host=$CHOST  \
-    --build=$CHOST \
-    --target=avr   \
-    --with-as=${avrbinutils}/bin/avr-as \
-    --with-gnu-as  \
-    --with-gnu-ld  \
-    --with-ld=${avrbinutils}/bin/avr-ld \
-    --with-system-zlib \
-    --disable-install-libiberty \
-    --disable-nls \
-    --disable-libssp \
-    --with-dwarf2 \
-    --enable-languages=c,c++'';
-
-  meta = with stdenv.lib; {
-    description = "GNU Compiler Collection, version ${version} for AVR microcontrollers";
-    homepage = http://gcc.gnu.org;
-    license = licenses.gpl3Plus;
-    platforms = with platforms; linux ++ darwin;
-    maintainers = with maintainers; [ mguentner ];
-  };
-}
diff --git a/pkgs/development/misc/avr/libc/default.nix b/pkgs/development/misc/avr/libc/default.nix
index 039846d5fcfb..9bfffe7b2fee 100644
--- a/pkgs/development/misc/avr/libc/default.nix
+++ b/pkgs/development/misc/avr/libc/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchurl, avrgcc, avrbinutils, automake, autoconf }:
+{ stdenv, fetchurl, automake, autoconf }:
 
 let
   version = "2.0.0";
@@ -11,18 +11,7 @@ stdenv.mkDerivation {
     sha256 = "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj";
   };
 
-  buildInputs = [ avrgcc avrbinutils automake autoconf ];
-  configurePhase = ''
-    unset LD
-    unset AS
-    unset AR
-    unset CC
-    unset CXX
-    unset RANLIB
-    unset STRIP
-
-    ./configure --prefix=$out --build=$(./config.guess) --host=avr
-  '';
+  nativeBuildInputs = [ automake autoconf ];
 
   # Make sure we don't strip the libraries in lib/gcc/avr.
   stripDebugList= "bin";
@@ -32,7 +21,7 @@ stdenv.mkDerivation {
     description = "a C runtime library for AVR microcontrollers";
     homepage = http://savannah.nongnu.org/projects/avr-libc/;
     license = licenses.bsd3;
-    platforms = platforms.unix;
+    platforms = platforms.all;
     maintainers = with maintainers; [ mguentner ];
   };
 }
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 3ace934df957..c6e2205a0bb9 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7991,13 +7991,10 @@ with pkgs;
 
   amtk = callPackage ../development/libraries/amtk { };
 
-  avrgcclibc = throw "avrgcclibs are now separate packages, install avrbinutils, avrgcc and avrlibc";
-
-  avrbinutils = callPackage ../development/misc/avr/binutils {};
-
-  avrgcc      = callPackage ../development/misc/avr/gcc {};
-
-  avrlibc     = callPackage ../development/misc/avr/libc {};
+  avrlibc      = callPackage ../development/misc/avr/libc {};
+  avrlibcCross = callPackage ../development/misc/avr/libc {
+    stdenv = crossLibcStdenv;
+  };
 
   avr8burnomat = callPackage ../development/misc/avr8-burn-omat { };
 
@@ -9746,6 +9743,7 @@ 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 == "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