all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Some more rust/cargo insights
@ 2021-06-06 14:15 Hartmut Goebel
       [not found] ` <20210606183857.gthvipntymstivh4@thebird.nl>
  2021-06-14  5:22 ` Maxim Cournoyer
  0 siblings, 2 replies; 13+ messages in thread
From: Hartmut Goebel @ 2021-06-06 14:15 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

Hi.,

these day I had spent some more hours struggling with rust ans cargo, 
trying to get "pre-built" crates.

Summery; Cargo is cruft, no solution found yet.

I tried reusing a crate from the very same place it was built (see 
enclosed script). Anyhow, this does not work since cargo uses a 
different "metadata" value, even if noting changed. Based in the verbose 
output (cargo build -v …) I assume that some parameters of the 
"destination" build get included into this value.

This meets another observation; when building the sequoia suite, several 
crates are build several times - even if all builds are performed in the 
same environment.

Rust's build system is such a cruft - I really would like to throw it 
where it belongs: into the trash.

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | h.goebel@crazy-compilers.com               |
| www.crazy-compilers.com | compilers which you thought are impossible |


[-- Attachment #2: rlib-test.scm --]
[-- Type: text/x-scheme, Size: 4300 bytes --]

(use-modules
 (guix download)
 (guix packages)
 (guix build-system cargo)
 (gnu packages crates-io)
 (srfi srfi-1)
 (srfi srfi-26)
 (gnu packages crates-graphics)
 (gnu packages rust-apps))

(define-public rust-pretty-assertions-0.5
  (package
    (inherit rust-pretty-assertions-0.6)
    (name "rust-pretty-assertions")
    (version "0.5.1")
    (source
     (origin
       (method url-fetch)
       (uri (crate-uri "pretty_assertions" version))
       (file-name
        (string-append name "-" version ".tar.gz"))
       (sha256
          (base32 "1ins6swkpxmrh8q5h96h8nv0497d3dclsiyx2lyvqi6py0q980is"))))
    (build-system cargo-build-system)
    (arguments
     `(#:tests? #f
       #:cargo-inputs
       (("rust-ansi-term" ,rust-ansi-term-0.11)
        ("rust-difference" ,rust-difference-2))))))

;; /gnu/store/wknzymkfbfjbxwfd3djrn4hk9zdfgs56-rust-xmlparser-0.13.3 -- original
;; 
;; libxmlparser-f82b201ea4144ed3.rlib

(define-public myrust-xmlparser
  (package
    (inherit rust-xmlparser-0.13)
    (outputs '("out" "rlib"))
    (arguments
     `(#:skip-build? #f
       #:tests? #f
       #:cargo-build-flags (list "--release" "-vv")
       #:phases
       (modify-phases %standard-phases
         (add-after 'install 'install-rlib
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((rout (assoc-ref outputs "rlib"))
                    (dest (string-append rout "/rlib")))
               ;;(mkdir dest)
               ;;(for-each (cut install-file <> (string-append rout "/rlib"))
               (for-each (lambda (fn)
                           (install-file fn (string-append rout "/rlib")))
                         (find-files "target/release/deps" "\\.(rlib|rmeta)$"))
               )))
          ;; (add-after 'install 'fail
          ;;   (lambda _ #f))
    )))))

(define-public myrust-roxmltree
  (package
    (inherit rust-roxmltree-0.14)
    ;;(outputs '("out" "crate"))
    (inputs
     `(("rust-xmlparser" ,myrust-xmlparser "rlib")))
    (arguments
     `(#:skip-build? #f
       #:tests? #f
       ;;#:vendor-dir "/tmp/src"
       #:cargo-build-flags (list "--release" "-vv")
       #:cargo-inputs
       (("rust-xmlparser:src" ,rust-xmlparser-0.13)
        ("rust-pretty-assertions" ,rust-pretty-assertions-0.5))
       #:phases
       (modify-phases %standard-phases
         (add-after 'patch-cargo-checksums 'bring-in-rlib
           (lambda* (#:key inputs #:allow-other-keys)
             (let* ((rin (assoc-ref inputs "rust-xmlparser"))
                    (src (assoc-ref inputs "rust-xmlparser"))
                    (rlib (string-append rin "/rlib")))
               (mkdir "/tmp/guix-build-rust-xmlparser-0.13.3.drv-0/")
               (copy-recursively
               "guix-vendor/rust-xmlparser-0.13.3.tar.gz"
               "/tmp/guix-build-rust-xmlparser-0.13.3.drv-0/xmlparser-0.13.3")
               (rename-file
                "guix-vendor/rust-xmlparser-0.13.3.tar.gz"
                "../rust-xmlparser-0.13.3.tar.gz")
               (symlink
                "/tmp/guix-build-rust-xmlparser-0.13.3.drv-0/xmlparser-0.13.3"
                "guix-vendor/rust-xmlparser-0.13.3")
;;                (let ((port (open-file ".cargo/config" "w" #:encoding "utf-8")))
;;                  (display "
;; #paths = [\"/tmp/guix-build-rust-xmlparser-0.13.3.drv-0/xmlparser-0.13.3\"]

;; [source.crates-io]
;; replace-with = 'vendored-sources'

;; #[patch.crates-io]
;; #xmlparser = { path = '/tmp/guix-build-rust-xmlparser-0.13.3.drv-0/xmlparser-0.13.3' }

;; [source.vendored-sources]
;; directory = '" port)
;;                  (display (string-append (getcwd) "/guix-vendor") port)
;;                  (display "'
;; " port)
;;     (close-port port))
               ;; (substitute* ".cargo/config"
               ;;   (("\\.vendored-sources\\]" _)
               ;;    (string-append _ "\n[paths]"))
               (for-each (lambda (fn)
                           (install-file fn "target/release/deps"))
                         (pk (find-files rlib "\\.(rlib|rmeta)$")))
               #t
               )))
         (add-before 'install 'fail
           (lambda _ #f)))
    ))))


;;myrust-xmlparser
myrust-roxmltree

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: Some more rust/cargo insights
@ 2021-06-07 18:48 Leo Prikler
  2021-06-08 17:01 ` Leo Famulari
  0 siblings, 1 reply; 13+ messages in thread
From: Leo Prikler @ 2021-06-07 18:48 UTC (permalink / raw)
  To: h.goebel; +Cc: guix-devel

> Our issue is a different one: Its about being able to reuse already
> compiled binaries - keeping current behavior of rust binaries being
> statically linked.
> 
> While this looks like being the same as dynamic library support, it
> is not: While for dynamic libraries you meet to ensure the very
> correct version of a "crate" is loaded, for static linking with pre-
> build binaries you only need to ensure this at build-time. (For guix,
> of course, both would not be a problem, but I doubt we can make rust
> people understand this. And other distros will still have the
> problem.)
That plus static libraries can't be grafted, which can be a problem
when your programming language despite being touted as secure still
allows large arrays of buggy behaviour.  So while "statically linked,
but reusable and I swear, it really is reproducible" might work for the
time being, it is not a long-term solution.

One might be tempted to compare this to Go, which we also can't
dynamically link, but the important difference here is that Rust is
already being pulled in by core-updatesy stuff like GTK, so a bug in
certain Rust software would affect *a lot* of Guix users whereas Go is
mostly an ecosystem onto itself.  (Note, though, that a Go update would
need to go through staging – not an ideal situation either.)

Regards,
Leo



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-06-14  5:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-06 14:15 Some more rust/cargo insights Hartmut Goebel
     [not found] ` <20210606183857.gthvipntymstivh4@thebird.nl>
2021-06-07  7:10   ` Hartmut Goebel
2021-06-07  8:28     ` Pjotr Prins
2021-06-07 12:04       ` Hartmut Goebel
2021-06-07 15:13         ` John Soo
2021-06-07 15:15           ` John Soo
2021-06-07 16:26           ` Hartmut Goebel
2021-06-07 16:41             ` Hartmut Goebel
2021-06-08  9:15               ` Efraim Flashner
2021-06-08 15:38                 ` Hartmut Goebel
2021-06-14  5:22 ` Maxim Cournoyer
  -- strict thread matches above, loose matches on Subject: below --
2021-06-07 18:48 Leo Prikler
2021-06-08 17:01 ` Leo Famulari

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.