* "guix environment --pure" different to guix-daemon's environment
@ 2018-03-30 22:53 Danny Milosavljevic
2018-03-31 20:33 ` Ludovic Courtès
0 siblings, 1 reply; 2+ messages in thread
From: Danny Milosavljevic @ 2018-03-30 22:53 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1.1: Type: text/plain, Size: 418 bytes --]
Hi,
so I'm trying to get mrustc to work (see attachment) but I've hit a snag.
When I use "guix build", gcc will eventually fail with SIGABRT.
When I then try to reproduce the problem via "guix environment" gcc works just
fine (using the failed tempdir and the failed command line).
What could be up in this case?
Can I get guix-daemon to make gcc dump core on SIGABRT? (setrlimit in a build phase? :->)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: wip-mrustc.patch --]
[-- Type: text/x-patch, Size: 8546 bytes --]
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 70140579b..ceb3510fc 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -46,6 +46,7 @@
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module ((guix build utils) #:select (alist-replace))
@@ -148,7 +149,87 @@ in turn be used to build the final Rust.")
"rustc-" version "-src.tar.gz"))
(sha256 (base32 hash))
(modules '((guix build utils)))
- (snippet '(begin (delete-file-recursively "src/llvm") #t))))
+ ; FIXME (snippet '(begin (delete-file-recursively "src/llvm") #t))
+ ))
+
+(define-public mrustc
+ (let ((commit "e49cd3b71a5b5458ecd3f3937c04d1a35871a190")
+ (revision "0")
+ (rustc-version "1.19.0"))
+ (package
+ (name "mrustc")
+ (version (git-version "0.0.0" revision commit))
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/thepowersgang/mrustc.git")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "02r012cqj0h92rz90n2limbp58102kyak54lgi7a0pnd6pmgygzp"))))
+ (build-system gnu-build-system)
+ (inputs
+ `(("llvm" ,llvm-3.9.1)))
+ (native-inputs
+ `(("bison" ,bison)
+ ("flex" ,flex)
+ ;; Required for the libstd sources.
+ ("rustc"
+ ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
+ (arguments
+ `(#:tests? #f
+ #:make-flags (list (string-append "LLVM_CONFIG="
+ (assoc-ref %build-inputs "llvm")
+ "/bin/llvm-config"))
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'unpack-target
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (substitute* "minicargo.mk" ; source
+ (("^[$][(]LLVM_CONFIG[)]:") "xxx:"))
+ (invoke "tar" "xf" (assoc-ref inputs "rustc"))
+ (chdir "rustc-1.19.0-src")
+ (delete-file-recursively "src/llvm")
+ (setenv "LLVM_LINK_SHARED" "1") ; FIXME move?
+ (invoke "patch" "-p0" "../rust_src.patch")
+ (chdir "..")
+ #t))
+ (delete 'configure)
+ (add-after 'build 'build-minicargo
+ (lambda _
+ (for-each (lambda (target)
+ (invoke "make" "-f" "minicargo.mk" target))
+ '("output/libstd.hir" "output/libpanic_unwind.hir"
+ "output/libproc_macro.hir"))
+ ;; Technically the above already does it - but we want to be clear.
+ (invoke "make" "-C" "tools/minicargo")))
+ (replace 'install
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (let* ((out (string-append (assoc-ref outputs "out")))
+ (bin (string-append out "/bin"))
+ (tools-bin (string-append out "/tools/bin"))
+ (lib (string-append out "/lib"))
+ (lib/rust (string-append lib "/mrust"))
+ (gcc (assoc-ref inputs "gcc")))
+ ;; These files are not reproducible.
+ (for-each delete-file (find-files "output" "\\.txt$"))
+ (mkdir-p lib)
+ (copy-recursively "output" lib/rust)
+ (mkdir-p bin)
+ (mkdir-p tools-bin)
+ (install-file "tools/bin/minicargo" tools-bin)
+ (install-file "bin/mrustc" bin)
+ ;; Rust requires a C toolchain for linking, as "cc".
+ (symlink (string-append gcc "/bin/gcc")
+ (string-append out "/bin/cc"))
+ #t))))))
+ (synopsis "Compiler for the Rust progamming language")
+ (description "Rust is a systems programming language that provides memory
+safety and thread safety guarantees.")
+ (home-page "https://github.com/thepowersgang/mrustc")
+;;; TODO: Add env vars: CFG_COMPILER_HOST_TRIPLE=x86_64-unknown-linux-gnu LLVM_CONFIG CFG_RELEASE= CFG_RELEASE_CHANNEL=stable CFG_VERSION=$(RUSTC_VERSION=1.19.0)-$(RUSTC_CHANNEL)-mrustc CFG_PREFIX=mrustc CFG_LIBDIR_RELATIVE=lib
+ (license license:expat))))
(define-public rust-1.23
(package
@@ -199,7 +280,9 @@ in turn be used to build the final Rust.")
"#[ignore]\nfn connect_timeout_unroutable"))
;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
(substitute* "src/libstd/sys/unix/process/process_common.rs"
- (("fn test_process_mask") "#[ignore]\nfn test_process_mask"))
+ (("#\\[cfg_attr\\(target_arch = \"arm\", ignore\\)\\]
+ fn test_process_mask") "#[ignore]
+ fn test_process_mask"))
;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
(delete-file-recursively "src/test/run-make/linker-output-non-utf8")
@@ -318,6 +401,57 @@ safety and thread safety guarantees.")
;; Dual licensed.
(license (list license:asl2.0 license:expat))))
+(define-public rust-1.19.0
+ (package (inherit rust-1.23)
+ (name "rust")
+ (version "1.19.0")
+ (source (rust-source version "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))
+ (arguments
+ (substitute-keyword-arguments
+ (package-arguments rust-1.23)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'build
+ (lambda* (#:key inputs outputs #:allow-other-keys)
+ (substitute* "src/librustc_errors/Cargo.toml"
+ (("[[]dependencies[]]") "
+[dependencies]
+term = \"0.4.4\"
+"))
+ (substitute* "src/librustc/Cargo.toml"
+ (("[[]dependencies[]]") "
+[dependencies]
+getopts = { path = \"../libgetopts\" }
+"))
+
+ (setenv "CFG_COMPILER_HOST_TRIPLE" "x86_64-unknown-linux-gnu")
+ ;(setenv "LLVM_CONFIG")
+ (setenv "CFG_RELEASE" "")
+ (setenv "CFG_RELEASE_CHANNEL" "stable")
+ (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
+ (setenv "CFG_PREFIX" "mrustc")
+ (setenv "CFG_LIBDIR_RELATIVE" "lib")
+ ;; Make Rust find "gcc".
+ ;(setenv "PATH" (string-append (assoc-ref inputs "gcc") "/bin:" (getenv "PATH")))
+ (invoke (string-append (assoc-ref inputs "rustc-bootstrap") "/tools/bin/minicargo")
+ "src/rustc" "--vendor-dir" "src/vendor" ;"-j" "3"
+ "-L" (string-append (assoc-ref inputs "rustc-bootstrap") "/lib/mrust"))
+ ; "--output-dir" "b/build" -L "b"
+ (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
+ ;(setenv "LLVM_CONFIG")
+ (setenv "CFG_RELEASE" #f)
+ (setenv "CFG_RELEASE_CHANNEL" #f)
+ (setenv "CFG_VERSION" #f)
+ (setenv "CFG_PREFIX" #f)
+ (setenv "CFG_LIBDIR_RELATIVE" #f)
+ (invoke (string-append (assoc-ref inputs "rustc-bootstrap") "/tools/bin/minicargo")
+ "src/tools/cargo" "--vendor-dir" "src/vendor"
+ "-L" (string-append (assoc-ref inputs "rustc-bootstrap") "/lib/mrust"))
+ #t))))))
+ (native-inputs
+ (alist-replace "rustc-bootstrap" (list mrustc)
+ (package-native-inputs rust-1.23)))))
+
(define-public rust
(let ((base-rust rust-1.23))
(package
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: "guix environment --pure" different to guix-daemon's environment
2018-03-30 22:53 "guix environment --pure" different to guix-daemon's environment Danny Milosavljevic
@ 2018-03-31 20:33 ` Ludovic Courtès
0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2018-03-31 20:33 UTC (permalink / raw)
To: Danny Milosavljevic; +Cc: guix-devel
Hello!
Danny Milosavljevic <dannym@scratchpost.org> skribis:
> so I'm trying to get mrustc to work (see attachment) but I've hit a snag.
>
> When I use "guix build", gcc will eventually fail with SIGABRT.
> When I then try to reproduce the problem via "guix environment" gcc works just
> fine (using the failed tempdir and the failed command line).
>
> What could be up in this case?
Did you try ‘guix environment -C’? There’d still be a few differences
compared to what guix-daemon does, but not that much (info "(guix)
Debugging Build Failures").
> Can I get guix-daemon to make gcc dump core on SIGABRT? (setrlimit in a build phase? :->)
Yes, you can! :-)
Add a phase that does this:
;; Allow us to dump core during the test suite so GDB
;; can report backtraces.
(let ((MiB (* 1024 1024)))
(setrlimit 'core (* 300 MiB) (* 500 MiB)))
(From <https://gitlab.inria.fr/guix-hpc/guix-hpc/blob/master/modules/inria/storm.scm#L59>.)
HTH,
Ludo’.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-31 20:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-30 22:53 "guix environment --pure" different to guix-daemon's environment Danny Milosavljevic
2018-03-31 20:33 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).