Re: Guix build side - including modules (guix hash), (guix gcrypt): How to provide shared library?

2017-01-02 Thread Ludovic Courtès
David Craven  skribis:

>> Also, why is sha256 used via FFI via an external library? It's not exactly 
>> difficult to implement in Guile :P
>
> I'm not sure we want to write our own crypto primitives... And it's
> not quite as trivial, I don't know or care what a Newton-Raphson
> algorithm is ;)
> http://stackoverflow.com/questions/24093199/a-pure-scheme-implementation-r5rs-of-sha256

I suspect it would be slow with Guile 2.0, and (guix hash) is used in
performance-critical locations.

That said, if there’s a need for it on the build side where performance
does not matter much, it makes sense to add a pure-Scheme
implementation.  I think Weinhölt’s Industria library has one.

Alternately, we could make it easier to import (guix hash).  All we need
is to create a custom (guix config) module where ‘%libgcrypt’ is found
to the right thing, or something like that.

HTH!

Ludo’.



Re: Guix build side - including modules (guix hash), (guix gcrypt): How to provide shared library?

2017-01-02 Thread David Craven
I find it useful to look at the generated drv
(/gnu/store/asr76labrpqq0kcg64yni0sqsxj0d30y-rust-gtk-0.1.1.drv) and
build script (/gnu/store/hash-rust-gtk-0.1.1.builder) and see if those
make sense.

Sounds like a hard problem dough. Good luck! :)

I notice you haven't rebased yet, I added a couple of commits to the
cargo-build-system yesterday...

> Also, why is sha256 used via FFI via an external library? It's not exactly 
> difficult to implement in Guile :P

I'm not sure we want to write our own crypto primitives... And it's
not quite as trivial, I don't know or care what a Newton-Raphson
algorithm is ;)
http://stackoverflow.com/questions/24093199/a-pure-scheme-implementation-r5rs-of-sha256

>  @dfeuer Not for the purposes of deriving the SHA-2 initialisation values. 
> Most implementations use IEEE-754 doubles, which have only 53 bits of 
> significand, not nearly enough for the 64-bit values used in the constants. I 
> basically convert the doubles to rationals, then use Newton-Raphson to get 
> the extra precision necessary. – Chris Jester-Young Jun 19 '14 at 6:10

> @dfeuer And now, on Mark Weaver's suggestion, I don't even use doubles at 
> all, but instead use pure Newton-Raphson. It does make the startup slower, 
> but that's a one-time cost. – Chris Jester-Young Aug 12 '14 at 15:26



Re: Guix build side - including modules (guix hash), (guix gcrypt): How to provide shared library?

2017-01-02 Thread Danny Milosavljevic
Hi David,

On Mon, 2 Jan 2017 11:06:27 +0100
David Craven  wrote:

> > how can I use (guix hash) on the build side? It requires the libgcrypt 
> > shared library and that's not available on the build side...  
> 
> Depends. For a one off package I'd add it to native-inputs. Otherwise
> you can create a new build-system that wraps the gnu-build-system and
> extend the gnu-build-system's implicit inputs with libgcrypt. Which is
> basically just automatically adding it to native-inputs for you.

Hmm. I tried both, also in host-inputs and native-inputs but it doesn't seem to 
work. What I mean is I want to use gcrypt in Guile on the build side. That's a 
lot more difficult than I thought...

Also, why is sha256 used via FFI via an external library? It's not exactly 
difficult to implement in Guile :P

Error messages:

@ build-started 
/gnu/store/3lfanl2xnmx3gr2j11hc51a3m7sp7ljp-module-import-compiled.drv - 
x86_64-linux 
/var/log/guix/drvs/3l//fanl2xnmx3gr2j11hc51a3m7sp7ljp-module-import-compiled.drv.bz2
Backtrace:
In ice-9/boot-9.scm:
2404: 19 [save-module-excursion #]
3088: 18 [#]
In unknown file:
   ?: 17 [primitive-load-path "guix/hash" ...]
In ice-9/eval.scm:
 505: 16 [# (define-module # # 
...)]
In ice-9/psyntax.scm:
1106: 15 [expand-top-sequence ((define-module (guix hash) #:use-module ...)) () 
...]
 989: 14 [scan ((define-module (guix hash) #:use-module ...)) () ...]
 279: 13 [scan ((#(syntax-object let # ...) (#) (# #) ...)) () ...]
In ice-9/eval.scm:
 411: 12 [eval # ()]
In ice-9/boot-9.scm:
2954: 11 [define-module* (guix hash) #:filename ...]
2929: 10 [resolve-imports ((#) (#) (#) (#) ...)]
2867: 9 [resolve-interface (guix gcrypt) #:select ...]
2792: 8 [# # ...]
3068: 7 [try-module-autoload (guix gcrypt) #f]
2404: 6 [save-module-excursion #]
3088: 5 [#]
In unknown file:
   ?: 4 [primitive-load-path "guix/gcrypt" ...]
In ice-9/eval.scm:
 453: 3 [eval # ()]
 411: 2 [eval # ()]
In unknown file:
   ?: 1 [dynamic-link 
"/gnu/store/4pnp5scrgmjp21flaihmgbckwrz6z4g3-libgcrypt-1.7.3/lib/libgcrypt"]
In ice-9/boot-9.scm:
 109: 0 [# 
misc-error ...]

ice-9/boot-9.scm:109:20: In procedure #:
ice-9/boot-9.scm:109:20: In procedure dynamic-link: file: 
"/gnu/store/4pnp5scrgmjp21flaihmgbckwrz6z4g3-libgcrypt-1.7.3/lib/libgcrypt", 
message: "file not found"
here- 8w6yqqc5f0ny3yq5x5lnx7hhiw60p6l9-gcrypt.scm
note: keeping build directory `/tmp/guix-build-module-import-compiled.drv-0'
builder for 
`/gnu/store/3lfanl2xnmx3gr2j11hc51a3m7sp7ljp-module-import-compiled.drv' failed 
with exit code 1
@ build-failed 
/gnu/store/3lfanl2xnmx3gr2j11hc51a3m7sp7ljp-module-import-compiled.drv - 1 
builder for 
`/gnu/store/3lfanl2xnmx3gr2j11hc51a3m7sp7ljp-module-import-compiled.drv' failed 
with exit code 1
cannot build derivation 
`/gnu/store/asr76labrpqq0kcg64yni0sqsxj0d30y-rust-gtk-0.1.1.drv': 1 
dependencies couldn't be built
guix build: error: build failed: build of 
`/gnu/store/asr76labrpqq0kcg64yni0sqsxj0d30y-rust-gtk-0.1.1.drv' failed

My log file doesn't contain any matching files (I added debugging "display" 
statements).

Source (for important parts search for the text "HERE"):

;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 David Craven 
;;;
;;; 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 (guix build cargo-build-system)
  #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  #:use-module (guix build utils)
  #:use-module (guix hash)
  #:use-module (guix base32)
  #:use-module (ice-9 ftw)
  #:use-module (ice-9 format)
  #:use-module (ice-9 match)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (rnrs bytevectors)
  #:use-module (ice-9 binary-ports)
  #:use-module (system foreign)
  #:use-module ((guix build utils) #:select (dump-port))
  #:use-module (srfi srfi-11)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (srfi srfi-60)
  #:use-module (rnrs bytevectors)
  #:use-module (ice-9 vlist)
  #:use-module (system foreign)
  #:export (%standard-phases
cargo-build))

;; Commentary:
;;
;; Builder-side code of the standard Rust package build procedure.
;;
;; Code:

;; FIXME: Needs to be parsed from url not package name.
(define (package-name->crate-name name)
  "Return the crate name of NAME."
  (match (string-split name #\-)
   

Re: Guix build side - including modules (guix hash), (guix gcrypt): How to provide shared library?

2017-01-02 Thread David Craven
> how can I use (guix hash) on the build side? It requires the libgcrypt shared 
> library and that's not available on the build side...

Depends. For a one off package I'd add it to native-inputs. Otherwise
you can create a new build-system that wraps the gnu-build-system and
extend the gnu-build-system's implicit inputs with libgcrypt. Which is
basically just automatically adding it to native-inputs for you.



Guix build side - including modules (guix hash), (guix gcrypt): How to provide shared library?

2017-01-01 Thread Danny Milosavljevic
Hi,

how can I use (guix hash) on the build side? It requires the libgcrypt shared 
library and that's not available on the build side...