From 18b057d628f849dd11de1756068e2bee5986f584 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 3 Mar 2016 18:07:30 +0100 Subject: [PATCH 1/2] WIP arm-none-eabi cross-compiler --- gnu/packages/bootstrap.scm | 1 + gnu/packages/embedded.scm | 160 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 gnu/packages/embedded.scm diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm index f5bf069..4acbb62 100644 --- a/gnu/packages/bootstrap.scm +++ b/gnu/packages/bootstrap.scm @@ -169,6 +169,7 @@ successful, or false to signal an error." ;; XXX: This one is used bare-bones, without a libc, so add a case ;; here just so we can keep going. + ((string=? system "arm-eabi") "no-ld.so") ((string=? system "xtensa-elf") "no-ld.so") ((string=? system "avr") "no-ld.so") diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm new file mode 100644 index 0000000..bf6b44d --- /dev/null +++ b/gnu/packages/embedded.scm @@ -0,0 +1,160 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016 Ricardo Wurmus +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages embedded) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix svn-download) + #:use-module (guix git-download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix build-system gnu) + #:use-module (gnu packages) + #:use-module (gnu packages bison) + #:use-module (gnu packages cross-base) + #:use-module (gnu packages flex) + #:use-module (gnu packages perl) + #:use-module (gnu packages texinfo)) + +(define-public xbinutils-arm-none-eabi + (let ((parent (cross-binutils "arm-none-eabi")) + (commit "136a940ac535e464d2a7a86880ce1f1a5554c484")) + (package (inherit parent) + (source (origin + (method git-fetch) + (uri (git-reference + (url "git://sourceware.org/git/binutils-gdb.git") + (commit commit))) + (file-name (string-append "xbinutils-arm-none-eabi-" + (package-version parent) "-" + (string-take commit 9) "-checkout")) + (patches (origin-patches (package-source parent))) + (sha256 + (base32 + "185sfmhbplidvj8n3h1clqqf6c0wqcigzm3phn9sqfy9arsv3mg8")))) + (native-inputs + `(("texinfo" ,texinfo) + ("perl" ,perl) + ("bison" ,bison) + ("flex" ,flex) + ,@(package-native-inputs parent))) + (arguments + `(,@(substitute-keyword-arguments (package-arguments parent) + ((#:configure-flags flags) + `(cons "--enable-multilib" + (delete "--disable-multilib" ,flags))))))))) + +;; Cannot just use the released GCC sources here, must be from SVN. +(define-public gcc-arm-none-eabi + (let ((xgcc (cross-gcc "arm-none-eabi" + xbinutils-arm-none-eabi)) + (revision 224288)) + (package (inherit xgcc) + (source + (origin + (method svn-fetch) + (uri (svn-reference + (url "svn://gcc.gnu.org/svn/gcc/branches/ARM/embedded-4_9-branch/") + (revision revision))) + (file-name (string-append "gcc-arm-embedded-" + (package-version xgcc) "-" + (number->string revision) "-checkout")) + (sha256 + (base32 + "113r98kygy8rrjfv2pd3z6zlfzbj543pq7xyq8bgh72c608mmsbr")) + (patches (origin-patches (package-source xgcc))))) + (native-inputs + `(("flex" ,flex) + ,@(package-native-inputs xgcc))) + (arguments + `(,@(substitute-keyword-arguments (package-arguments xgcc) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'fix-genmultilib + (lambda _ + (substitute* "gcc/genmultilib" + (("#!/bin/sh") (string-append "#!" (which "sh")))) + #t)))) + ((#:configure-flags flags) + `(cons "--with-newlib" + (cons "--enable-multilib" + (delete "--disable-multilib" ,flags)))))))))) + +(define-public newlib-arm-none-eabi + (package + (name "newlib") + (version "2.2.0") + (source (origin + (method url-fetch) + (uri (string-append "ftp://sourceware.org/pub/newlib/newlib-" + version ".tar.gz")) + (sha256 + (base32 + "1gimncxzq663l4gp8zd89ynfzhk2q802mcaiyjpr2xbkn1ix5bgq")))) + (build-system gnu-build-system) + (arguments + `(#:out-of-source? #t + #:configure-flags '("--target=arm-none-eabi" + "--enable-newlib-io-long-long" + "--enable-newlib-register-fini" + "--disable-newlib-supplied-syscalls" + "--disable-nls") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'fix-shell-shebangs-please + (lambda _ + (setenv "SHELL" (which "sh")) + (setenv "CONFIG_SHELL" (which "sh")) + (substitute* '("libgloss/arm/configure" + "libgloss/arm/cpu-init/Makefile.in" + "libgloss/arm/Makefile.in" + "libgloss/libnosys/Makefile.in" + "libgloss/Makefile.in") + (("/bin/sh") (which "sh"))) + #t))))) + (native-inputs `(("xbinutils" ,xbinutils-arm-none-eabi) + ("xgcc" ,gcc-arm-none-eabi) + ("texinfo" ,texinfo))) + (home-page "http://www.sourceware.org/newlib/") + (synopsis "C library for use on embedded systems") + (description + "Newlib is a C library intended for use on embedded systems. It is a +conglomeration of several library parts, that are easily usable on embedded +products.") + (license (license:non-copyleft + "https://www.sourceware.org/newlib/COPYING.NEWLIB")))) + +(define-public newlib-nano-arm-none-eabi + (package (inherit newlib-arm-none-eabi) + (name "newlib-nano") + (arguments + (substitute-keyword-arguments (package-arguments newlib-arm-none-eabi) + ((#:configure-flags flags) + ``("--target=arm-none-eabi" + "--enable-multilib" + "--disable-newlib-supplied-syscalls" + "--enable-newlib-reent-small" + "--disable-newlib-fvwrite-in-streamio" + "--disable-newlib-fseek-optimization" + "--disable-newlib-wide-orient" + "--enable-newlib-nano-malloc" + "--disable-newlib-unbuf-stream-opt" + "--enable-lite-exit" + "--enable-newlib-global-atexit" + "--enable-newlib-nano-formatted-io" + "--disable-nls")))))) -- 2.6.3