Revitalizing this old thread.

On Fri, Nov 20, 2015 at 9:20 AM, Ludovic Courtès <l...@gnu.org> wrote:
> "Thompson, David" <dthomps...@worcester.edu> skribis:
>
>> Not quite.  The avr-gcc build only provides a single version of
>> libgcc.a, whereas Debian's avr-gcc provides a separate libgcc.a for
>> each supported AVR family (avr2, avr3, avr35, etc.)  Mark thought it
>> might be the fault of the --disable-multilib configure flag, so I
>> removed it but it didn't solve anything.  I'm not sure what to do now.
>> I have no idea what flag or patch could be signalling to the gcc build
>> system that it shouldn't try to compile libraries for all of the
>> various AVR models.
>
> Are you sure the removal of --disable-multilib was effective?
>
> Otherwise no specific idea.  :-/ We’ll have to thoroughly study the
> (avr-)gcc doc.

With much help from Manolis, we were finally able to overcome the
multilib issue!  But there's another roadblock: avr-libc doesn't
build:

avr-gcc -DHAVE_CONFIG_H -I. -I../../../../avr-libc-2.0.0/avr/lib/avr2
-I../../..  -I../../../../avr-libc-2.0.0/common
-I../../../../avr-libc-2.0.0/include -I../../../include
-I../../../../avr-libc-2.0.0/common
-I../../../../avr-libc-2.0.0/include -I../../../include -x
assembler-with-cpp  -mmcu=avr2 -D__COMPILING_AVR_LIBC__   -MT abort.o
-MD -MP -MF .deps/abort.Tpo -c -o abort.o
../../../../avr-libc-2.0.0/libc/stdlib/abort.S
In file included from
/gnu/store/8m00x5x8ykmar27s9248cmhnkdb2n54a-glibc-2.22/include/features.h:389:0,
                 from
/gnu/store/8m00x5x8ykmar27s9248cmhnkdb2n54a-glibc-2.22/include/limits.h:25,
                 from ../../../../avr-libc-2.0.0/libc/stdlib/strtol.c:33:
/gnu/store/8m00x5x8ykmar27s9248cmhnkdb2n54a-glibc-2.22/include/gnu/stubs.h:7:27:
fatal error: gnu/stubs-32.h: No such file or directory
 # include <gnu/stubs-32.h>
                           ^
compilation terminated.


I don't know why it's including headers from the host system's libc.
Manolis was able to get past it by including a cross-libc built for
i686.  Does this seem wrong to anyone else?  Any thoughts on what
might be going on here?

We're closer than ever to having a working AVR toolchain.  I hope we
can iron out these last wrinkles.  Attached is the WIP code for the
toolchain.

- Dave
From 9773ef4c013f7a223ea112559f517c3ad9c10ac2 Mon Sep 17 00:00:00 2001
From: David Thompson <dthomp...@vistahigherlearning.com>
Date: Tue, 5 Apr 2016 12:12:48 -0400
Subject: [PATCH] wip AVR stuff

---
 gnu/packages/avr.scm        | 60 +++++++++++++++++++++++++++++++++++++--------
 gnu/packages/cross-base.scm |  6 -----
 2 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/avr.scm b/gnu/packages/avr.scm
index d59816b..7560eec 100644
--- a/gnu/packages/avr.scm
+++ b/gnu/packages/avr.scm
@@ -19,6 +19,7 @@
 
 (define-module (gnu packages avr)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix packages)
   #:use-module (guix build-system gnu)
@@ -27,31 +28,70 @@
   #:use-module (gnu packages vim)
   #:use-module (gnu packages zip))
 
+(define-public avr-binutils
+  (package
+    (inherit (cross-binutils "avr"))
+    (name "avr-binutils")
+    (arguments
+     '(#:configure-flags '("--target=avr"
+                           "--disable-nls")))))
+
+(define-public avr-gcc
+  (let ((xgcc (cross-gcc "avr" avr-binutils)))
+    (package
+      (inherit xgcc)
+      (name "avr-gcc")
+      (arguments
+       (substitute-keyword-arguments (package-arguments xgcc)
+         ((#:phases phases)
+          `(modify-phases ,phases
+             ;; Without a working multilib build, the resulting GCC lacks
+             ;; support for nearly every AVR chip.
+             (add-after 'unpack 'fix-genmultilib
+               (lambda _
+                 (substitute* "gcc/genmultilib"
+                   (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                 #t))))
+         ((#:configure-flags flags)
+          '(list "--target=avr"
+                 "--enable-languages=c,c++"
+                 "--disable-nls"
+                 "--disable-libssp"
+                 "--with-dwarf2"))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "CROSS_CPATH")
+              (files '("avr/include")))
+             (search-path-specification
+              (variable "CROSS_LIBRARY_PATH")
+              (files '("avr/lib"))))))))
+
 (define-public avr-libc
   (package
     (name "avr-libc")
-    (version "1.8.1")
+    (version "2.0.0")
     (source (origin
               (method url-fetch)
-              (uri (string-append
-                    "mirror://savannah//avr-libc/avr-libc-"
-                    version ".tar.bz2"))
+              (uri (string-append "mirror://savannah//avr-libc/avr-libc-"
+                                  version ".tar.bz2"))
               (sha256
                (base32
-                "0sd9qkvhmk9av4g1f8dsjwc309hf1g0731bhvicnjb3b3d42l1n3"))))
+                "15svr2fx8j6prql2il2fc0ppwlv50rpmyckaxx38d3gxxv97zpdj"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:out-of-source? #t
+     '(#:out-of-source? #t
        #:configure-flags '("--host=avr")))
-
-    (native-inputs `(("cross-binutils" ,(cross-binutils "avr"))
-                     ("cross-gcc" ,xgcc-avr)))
+    (native-inputs `(("avr-binutils" ,avr-binutils)
+                     ("avr-gcc" ,avr-gcc)
+                     ;;("libc" ,(cross-libc "i686-linux"))
+                     ))
     (home-page "http://www.nongnu.org/avr-libc/";)
     (synopsis "The AVR C Library")
     (description
      "AVR Libc is a project whose goal is to provide a high quality C library
 for use with GCC on Atmel AVR microcontrollers.")
-    (license (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt";))))
+    (license
+     (license:non-copyleft "http://www.nongnu.org/avr-libc/LICENSE.txt";))))
 
 (define-public microscheme
   (package
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 8bd599c..bdf17ba 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -352,12 +352,6 @@ XBINUTILS and the cross tool chain."
                                (package-supported-systems xgcc)
                                '("mips64el-linux" "i686-linux"))))))
 
-(define-public xgcc-avr
-  ;; AVR cross-compiler, used to build AVR-Libc.
-  (let ((triplet "avr"))
-    (cross-gcc triplet
-               (cross-binutils triplet))))
-
 (define-public xgcc-xtensa
   ;; Bare-bones Xtensa cross-compiler, used to build the Atheros firmware.
   (cross-gcc "xtensa-elf"))
-- 
2.7.3

Reply via email to