Subject: Re: [bug#29555] [PATCHv3] gnu: rust: update rust to 1.22.1 and cargo to 1.23.0

From: Danny Milosavljevic <[email-masked]>
Date: Sun, 10 Dec 2017 10:27:23 +0100

Wow! Nice.

Review below:

+             ;; guix llvm-3.9.1 package install only shared libraries

"installs"

+             (setenv "LLVM_LINK_SHARED" "1")

+         (add-after 'patch-source-shebangs 'patch-cargo-checksums
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "src/Cargo.lock"
+               (("(\"checksum .* = )\".*\"" all name)
+                (string-append name "\"" ,%cargo-reference-hash "\"")))
+             (for-each
+              (lambda (filename)
+                (use-modules (guix build cargo-build-system))
+                (delete-file filename)
+                (let* ((dir (dirname filename)))
+                  (display (string-append
+                            "patch-cargo-checksums: generate-checksums for "
+                            dir "\n"))
+                  (generate-checksums dir ,%cargo-reference-project-file)))
+              (find-files "src/vendor" ".cargo-checksum.json"))))

Hmm, should return #t on success.

-         (add-after 'install 'wrap-rustc
+                    (jemalloc (assoc-ref inputs "jemalloc")))
+               (call-with-output-file "config.toml"
+                 (lambda (port)
+                   (display (string-append "
+[llvm]
+[build]
+cargo = \"" cargo "/bin/cargo" "\"
+rustc = \"" rustc "/bin/rustc" "\"
+python = \"" python "/bin/python2" "\"
+gdb = \"" gdb "/bin/gdb" "\"
+vendor = true
+submodules = false
+[install]
+prefix = \"" out "\"
+[rust]
+default-linker = \"" gcc "/bin/gcc" "\"
+default-ar = \"" binutils "/bin/ar" "\"
+channel = \"stable\"
+rpath = true
+# There is 2 failed codegen tests:
+# codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
+# This tests required patched LLVM
+codegen-tests = false
+[target." %host-type "]
+llvm-config = \"" llvm "/bin/llvm-config" "\"
+cc = \"" gcc "/bin/gcc" "\"
+cxx = \"" gcc "/bin/g++" "\"
+jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
+[dist]
+") port))))))

Should return #t on success.

+         (add-before 'build 'reset-timestamps-after-changes
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (define ref (stat "README.md"))
+             (for-each
+              (lambda (filename)
+                (set-file-time filename ref))
+              (find-files "." #:directories? #t))))

Same

+         (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
            (lambda* (#:key inputs #:allow-other-keys)
-             (let* ((gcc (assoc-ref inputs "gcc"))
-                    (cc (string-append gcc "/bin/gcc")))
-               (mkdir ".cargo")
-               (call-with-output-file ".cargo/config"
-                 (lambda (p)
-                   (format p "
+             (substitute* "Cargo.lock"
+               (("(\"checksum .* = )\".*\"" all name)
+                (string-append name "\"" ,%cargo-reference-hash "\"")))
+             (for-each
+              (lambda (filename)
+                (use-modules (guix build cargo-build-system))
+                (delete-file filename)
+                (let* ((dir (dirname filename)))
+                  (display (string-append
+                            "patch-cargo-checksums: generate-checksums for "
+                            dir "\n"))
+                  (generate-checksums dir ,%cargo-reference-project-file)))
+              (find-files "vendor" ".cargo-checksum.json"))))

Same

+         (replace 'configure
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (substitute* "tests/build.rs"
+               (("/usr/bin/env") (which "env"))
+               ;; Guix llvm compiled without asmjs-unknown-emscripten at all
+               (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
+             (substitute* "tests/death.rs"
+               ;; Stuck when built in container
+               (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
+             (mkdir ".cargo")
+             (call-with-output-file ".cargo/config"
+               (lambda (port)
+                 (display "
 [source.crates-io]
 registry = 'https://github.com/rust-lang/crates.io-index'
 replace-with = 'vendored-sources'
 
 [source.vendored-sources]
 directory = 'vendor'
-")))
-               (setenv "CMAKE_C_COMPILER" cc)
-               (setenv "CC" cc))
-             #t))
-         (delete 'configure))))
+" port)))
+             ;; Disable test for cross compilation support
+             (setenv "CFG_DISABLE_CROSS_TESTS" "1")
+             (setenv "SHELL" (which "sh"))
+             (setenv "CONFIG_SHELL" (which "sh"))
+             (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")))))))

Same