From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Le Bihan Subject: Re: rust work in progress conflicts Date: Thu, 28 Jul 2016 20:31:44 +0200 Message-ID: <20160728203144.7df4bb8c@itchy> References: <20160325184540.4e02cb2d@scratchpost.org> <87k2kq6wma.fsf@grrlz.net> <87oa8mt8lh.fsf@gmail.com> <87eg9gzgqb.fsf@libertad.pw> <87popyp3od.fsf@we.make.ritual.n0.is> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/kVAYN6EFZvhgQlY_g0DMcO9" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSq66-0003oA-LW for guix-devel@gnu.org; Thu, 28 Jul 2016 14:31:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSq62-0004WC-CL for guix-devel@gnu.org; Thu, 28 Jul 2016 14:31:53 -0400 Received: from smtp5-g21.free.fr ([2a01:e0c:1:1599::14]:39803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSq62-0004W5-2g for guix-devel@gnu.org; Thu, 28 Jul 2016 14:31:50 -0400 In-Reply-To: <87popyp3od.fsf@we.make.ritual.n0.is> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: ng0 Cc: guix-devel@gnu.org --MP_/kVAYN6EFZvhgQlY_g0DMcO9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi ng0, all! Le Thu, 28 Jul 2016 08:28:18 +0000, ng0 a =C3=A9crit : > ng0 writes: [...] > > So I picked up rust.scm again and forgot about this thread, only a > search for rust brought it up again. > As this will be a long task obviously, however we finish it, can we > file a bug on it so it is obvious that work is being done on it and > there'll be no dual work on this? >=20 > Recently released version 1.10.0 of rust merged the > "--disable-codegen-tests" I needed back when i worked on it. It happens that I tried to package Rust, as an introduction to Guix. Here is my version, inspired by the Haskell package, where Rust 1.10.0 is built, bootstrapped by a binary version of rustc 1.9.0. It uses the "cc" wrapper trick previously presented. Some questions, though: 1. I can compile a sample program in a guix environment created using `guix environment gcc glibc binutils rust`, but the program generated fails to run because libgcc_s.so.1 can not be found. How can it be added to the environment? 2. Having a Rust compiler is cool, but having Cargo, the Rust package manager, would be even better. Cargo is also bootstrapped, and it is also built using zillions of crates (Rust packages) downloaded from the Internet. How could this case be handled in Guix? Best regards, --=20 ELB --MP_/kVAYN6EFZvhgQlY_g0DMcO9 Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=0001-gnu-Add-rust.patch =46rom fb1fbc92cd68331b3dea94c238274f8a01b98afa Mon Sep 17 00:00:00 2001 From: Eric Le Bihan Date: Thu, 28 Jul 2016 20:09:01 +0200 Subject: [PATCH 1/1] gnu: Add rust * gnu/packages/rust.scm(rust): New variable. Signed-off-by: Eric Le Bihan --- gnu/packages/rust.scm | 141 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 141 insertions(+) create mode 100644 gnu/packages/rust.scm diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm new file mode 100644 index 0000000..6c6ec0c --- /dev/null +++ b/gnu/packages/rust.scm @@ -0,0 +1,141 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2016 Eric Le Bihan +;;; +;;; 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 rust) + #:use-module (ice-9 regex) + #:use-module ((guix licenses) #:select (asl2.0 x11-style)) + #:use-module (guix packages) + #:use-module (guix download) + #:use-module (guix build-system gnu) + #:use-module (gnu packages base) + #:use-module (gnu packages bootstrap) + #:use-module (gnu packages curl) + #:use-module (gnu packages elf) + #:use-module (gnu packages gcc) + #:use-module (gnu packages jemalloc) + #:use-module (gnu packages perl) + #:use-module (gnu packages python)) + +(define rust-bootstrap-x86_64-1.9.0 + (origin + (method url-fetch) + (uri + "https://static.rust-lang.org/dist/2016-05-24/rustc-1.9.0-x86_64-unkno= wn-linux-gnu.tar.gz") + (sha256 + (base32 + "1i44rlvvn3pr81sli6bdbkzd78ar1ibybxx6mzpw6rkw4c84sw6h")))) + +(define rust-bootstrap-i686-1.9.0 + (origin + (method url-fetch) + (uri + "https://static.rust-lang.org/dist/2016-05-24/rustc-1.9.0-i686-unknown= -linux-gnu.tar.gz") + (sha256 + (base32 + "0fdf5xvh3g4hdza0y80w1r9vnfczjqnbzbvs7k878yc26p4dwl99")))) + +(define-public rust + (package + (name "rust") + (version "1.10.0") + (source (origin + (method url-fetch) + (uri (string-append "https://static.rust-lang.org/dist/rustc-" + version "-src.tar.gz")) + (sha256 + (base32 + "0sb82xb8y2pzs8l1hk91z228bambwx3dmi2kj8isin7nyjn5l0d4")))) + (build-system gnu-build-system) + (native-inputs + `(("curl" ,curl) + ("gcc" ,gcc) + ("gcc-lib" ,gcc "lib") + ("jemalloc" ,jemalloc) + ("patchelf" ,patchelf) + ("perl" ,perl) + ("python" ,python-2) + ("rust-bootstrap" + ,(if (string-match "x86_64" (or (%current-target-system) (%current-= system))) + rust-bootstrap-x86_64-1.9.0 + rust-bootstrap-i686-1.9.0)) + ("which" ,which))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'unpack-bootstrap + (lambda* (#:key inputs #:allow-other-keys) + (with-directory-excursion (getcwd) + (zero? (system* + "tar" + "--strip-components=3D1" + "-xzf" + (assoc-ref inputs "rust-bootstrap")))))) + (replace 'configure + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (binutils (assoc-ref inputs "binutils")) + (gcc (assoc-ref inputs "gcc")) + (gcc-lib (assoc-ref inputs "gcc-lib")) + (jemalloc (assoc-ref inputs "jemalloc")) + (ld-so (string-append + (assoc-ref inputs "libc") + ,(glibc-dynamic-linker))) + (python (assoc-ref inputs "python"))) + (setenv "SHELL" (which "sh")) + (setenv "CONFIG_SHELL" (which "sh")) + ;; Tell where to find libgcc_s.so + (setenv "LD_LIBRARY_PATH" (string-append gcc-lib "/lib")) + ;; Remove reference to "/lib64/ld-linux-x86-64.so.2" from bina= ry + (zero? (system* + "patchelf" + "--set-interpreter" ld-so + (string-append (getcwd) "/rustc/bin/rustc"))) + (zero? (system* + "./configure" + (string-append "--prefix=3D" out) + (string-append "--default-linker=3D" gcc "/bin/gcc") + (string-append "--default-ar=3D" binutils "/bin/ar") + (string-append "--jemalloc-root=3D" jemalloc "/lib") + (string-append "--enable-rpath") + (string-append "--enable-local-rust") + (string-append "--local-rust-root=3D" (getcwd) "/rustc= ") + (string-append "--python=3D" python "/bin/python2") + "--disable-manage-submodules"))))) + (add-before 'build 'pre-build + (lambda _ + (let* ((bindir (string-append (getcwd) "/bin")) + (cc (string-append bindir "/cc"))) + (mkdir bindir) + (call-with-output-file cc + (lambda (port) + (format port + "#!~a\n\nexec gcc \"$@\"\n" (which "sh= ")))) + (chmod cc #o755)))) + (replace 'build + (lambda* (#:key outputs #:allow-other-keys) + (setenv "PATH" + (string-append (getcwd) "/bin:" (getenv "PATH"))) + (mkdir (assoc-ref outputs "out")) + (zero? (system* "make"))))) + #:tests? #f)) + (synopsis "Compiler for the Rust progamming language") + (description + "Rust is a systems programming language that runs blazingly fast, prev= ents + segfaults, and guarantees thread safety.") + (home-page "https://www.rust-lang.org") + (license (list asl2.0 (x11-style "file://LICENSE-MIT"))))) --=20 2.4.11 --MP_/kVAYN6EFZvhgQlY_g0DMcO9--