me
/
guix
Archived
1
0
Fork 0

gnu: rust-ring-0.13: Build all the files from source.

* gnu/packages/crates-io.scm (rust-ring-0.13-sources): New variable.
(rust-ring-0.13)[source]: Use rust-ring-0.13-sources.  Remove snippet.
[arguments]: Don't skip the build.  Remove phase generating curve25519
tables.
[native-inputs]: Remove field.

Change-Id: Iea4a7b7cd88c21e37b9cdab6484dc3e229ced3ea
master
Efraim Flashner 2024-01-08 09:05:36 +02:00
parent 2c40aaa60b
commit 097fb40dc3
No known key found for this signature in database
GPG Key ID: 41AAE7DCCA3D8351
1 changed files with 195 additions and 34 deletions

View File

@ -58146,50 +58146,211 @@ Digital Signature Algorithm} (ECDSA).")
("rust-untrusted" ,rust-untrusted-0.6)
("rust-winapi" ,rust-winapi-0.3))))))
(define rust-ring-0.13-sources
(let* ((version "0.13.5")
(upstream-source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/briansmith/ring")
(commit "704e4216a397bd830479bcd6d7dd67fc62cdbe67")))
(file-name (git-file-name "rust-ring" version))
(sha256
(base32 "0iqwf8i2i0a46ymrqss1ngbd2lqphk0mw74c65pxb8skyn2n7csi")))))
(origin
(method computed-origin-method)
(file-name (string-append "rust-ring-" version ".tar.gz"))
(sha256 #f)
(uri
(delay
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(set-path-environment-variable
"PATH" '("bin")
(list #+(canonical-package gzip)
#+(canonical-package tar)
#+perl
#+yasm
#+go
#+clang ; clang-format
#+python2-minimal))
(setenv "HOME" (getcwd))
(copy-recursively #+upstream-source
(string-append "ring-" #$version))
(with-directory-excursion (string-append "ring-" #$version)
(begin
;; Make some adjustments for newer versions of rust
;; error: `...` range patterns are deprecated
(substitute* "src/digest/sha1.rs"
(("0\\.\\.\\.") "0..="))
(substitute* "build.rs"
(("out_dir\\.clone\\(\\)") "out_dir")
(("libs\\.into_iter\\(\\)") "libs.iter()"))
;; It turns out Guix's yasm works just fine here.
(substitute* "build.rs"
(("yasm.exe") "yasm"))
;; Files which would be deleted in a snippet:
(delete-file "third_party/fiat/curve25519_tables.h")
(delete-file "crypto/fipsmodule/ec/ecp_nistz256_table.inl")
;; Files to be generated in the sources:
(format #t "Generating the missing files ...~%")
(force-output)
(with-directory-excursion "third_party/fiat"
(with-output-to-file "curve25519_tables.h"
(lambda _ (invoke "python" "make_curve25519_tables.py"))))
(with-directory-excursion "crypto/fipsmodule/ec"
;; This one seems to have been changed elsewhere in the
;; sources but not in the script generating the definition.
(substitute* "make_p256-x86_64-table.go"
(("ecp_nistz256_precomputed") "GFp_nistz256_precomputed"))
(with-output-to-file "ecp_nistz256_table.inl"
(lambda _ (invoke "go" "run" "make_p256-x86_64-table.go"))))
(format #t "Generating the pregenerated files ...~%")
(force-output)
(mkdir-p "pregenerated/tmp")
;; We generate all the files which upstream would normally be
;; generate by using '(cd pregenerate_asm && cargo clean &&
;; cargo build) ./pregenerate_asm/target/debug/pregenerate_asm'
;; in order to not include a dependency on cargo when
;; generating the sources.
(define (prefix script)
(string-append
"pregenerated/"
(string-drop-right
(string-drop script
(string-index-right script #\/)) 3)))
(for-each
(lambda (script)
(invoke "perl" script "elf"
(string-append (prefix script) "-elf.S"))
(invoke "perl" script "macosx"
(string-append (prefix script) "-macosx.S"))
(invoke "perl" script "nasm"
(string-append
"pregenerated/tmp/"
(string-drop (prefix script) 13) "-nasm.asm")))
'("crypto/fipsmodule/aes/asm/aes-x86_64.pl"
"crypto/fipsmodule/aes/asm/aesni-x86_64.pl"
"crypto/fipsmodule/aes/asm/vpaes-x86_64.pl"
"crypto/fipsmodule/bn/asm/x86_64-mont.pl"
"crypto/fipsmodule/bn/asm/x86_64-mont5.pl"
"crypto/chacha/asm/chacha-x86_64.pl"
"crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl"
"crypto/fipsmodule/modes/asm/aesni-gcm-x86_64.pl"
"crypto/fipsmodule/modes/asm/ghash-x86_64.pl"
"crypto/poly1305/asm/poly1305-x86_64.pl"
"crypto/fipsmodule/sha/asm/sha512-x86_64.pl"))
(invoke "perl" "crypto/fipsmodule/sha/asm/sha512-x86_64.pl"
"elf" "pregenerated/sha256-x86_64-elf.S")
(invoke "perl" "crypto/fipsmodule/sha/asm/sha512-x86_64.pl"
"macosx" "pregenerated/sha256-x86_64-macosx.S")
(invoke "perl" "crypto/fipsmodule/sha/asm/sha512-x86_64.pl"
"nasm" "pregenerated/tmp/sha256-x86_64-nasm.asm")
(for-each
(lambda (script)
(invoke "yasm" "-X" "vc" "--dformat=cv8"
"--oformat=win64" "--machine=amd64" "-o"
(string-append (prefix script) "obj") script))
(find-files "pregenerated/tmp" "\\.asm"))
(for-each
(lambda (script)
(invoke "perl" script "ios64"
(string-append (prefix script) "-ios64.S"))
(invoke "perl" script "linux64"
(string-append (prefix script) "-linux64.S")))
'("crypto/fipsmodule/aes/asm/aesv8-armx.pl"
"crypto/fipsmodule/modes/asm/ghashv8-armx.pl"
"crypto/fipsmodule/bn/asm/armv8-mont.pl"
"crypto/chacha/asm/chacha-armv8.pl"
"crypto/fipsmodule/ec/asm/ecp_nistz256-armv8.pl"
"crypto/poly1305/asm/poly1305-armv8.pl"
"crypto/fipsmodule/sha/asm/sha512-armv8.pl"))
(invoke "perl" "crypto/fipsmodule/sha/asm/sha512-armv8.pl"
"ios64" "pregenerated/sha256-armv8-ios64.S")
(invoke "perl" "crypto/fipsmodule/sha/asm/sha512-armv8.pl"
"linux64" "pregenerated/sha256-armv8-linux64.S")
(for-each
(lambda (script)
(invoke "perl" script "elf"
"-fPIC" "-DOPENSSL_IA32_SSE2"
(string-append (prefix script) "-elf.S"))
(invoke "perl" script "macosx"
"-fPIC" "-DOPENSSL_IA32_SSE2"
(string-append (prefix script) "-macosx.S"))
(invoke "perl" script "win32n"
"-fPIC" "-DOPENSSL_IA32_SSE2"
(string-append
"pregenerated/tmp/"
(string-drop (prefix script) 13) "-win32n.asm")))
'("crypto/fipsmodule/aes/asm/aes-586.pl"
"crypto/fipsmodule/aes/asm/aesni-x86.pl"
"crypto/fipsmodule/aes/asm/vpaes-x86.pl"
"crypto/fipsmodule/bn/asm/x86-mont.pl"
"crypto/chacha/asm/chacha-x86.pl"
"crypto/fipsmodule/ec/asm/ecp_nistz256-x86.pl"
"crypto/fipsmodule/modes/asm/ghash-x86.pl"
"crypto/poly1305/asm/poly1305-x86.pl"
"crypto/fipsmodule/sha/asm/sha256-586.pl"
"crypto/fipsmodule/sha/asm/sha512-586.pl"))
(for-each
(lambda (script)
(invoke "yasm" "-X" "vc" "--dformat=cv8"
"--oformat=win32" "--machine=x86" "-o"
(string-append (prefix script) "obj") script))
(find-files "pregenerated/tmp" "-win32n\\.asm"))
(for-each
(lambda (script)
(invoke "perl" script "ios32"
(string-append (prefix script) "-ios32.S"))
(invoke "perl" script "linux32"
(string-append (prefix script) "-linux32.S")))
'("crypto/fipsmodule/aes/asm/aesv8-armx.pl"
"crypto/fipsmodule/modes/asm/ghashv8-armx.pl"
"crypto/fipsmodule/aes/asm/aes-armv4.pl"
"crypto/fipsmodule/aes/asm/bsaes-armv7.pl"
"crypto/fipsmodule/bn/asm/armv4-mont.pl"
"crypto/chacha/asm/chacha-armv4.pl"
"crypto/fipsmodule/ec/asm/ecp_nistz256-armv4.pl"
"crypto/fipsmodule/modes/asm/ghash-armv4.pl"
"crypto/poly1305/asm/poly1305-armv4.pl"
"crypto/fipsmodule/sha/asm/sha256-armv4.pl"
"crypto/fipsmodule/sha/asm/sha512-armv4.pl"))
(format #t "Creating the tarball ...~%")
(force-output)
;; The other option is to use cargo package --allow-dirty
(with-directory-excursion "../"
(invoke "tar" "czf" #$output
;; avoid non-determinism in the archive
"--sort=name" "--mtime=@0"
"--owner=root:0" "--group=root:0"
(string-append "ring-" #$version))))))))))))
(define-public rust-ring-0.13
(package
(inherit rust-ring-0.14)
(name "rust-ring")
(version "0.13.5")
(source
(origin
(method url-fetch)
(uri (crate-uri "ring" version))
(file-name (string-append name "-" version ".tar.gz"))
(sha256
(base32 "12j580by6a438i5mw3136cj3lxylywymdr5p8rqlkwrm5s5bck9c"))
(modules '((guix build utils)))
(snippet
'(begin
;; error: `...` range patterns are deprecated
(substitute* "src/digest/sha1.rs"
(("0\\.\\.\\.") "0..="))
;; Remove some generated files.
(delete-file-recursively "pregenerated")
;; Regenerating the curve25519_tables requires python2 and clang-format.
(delete-file "third_party/fiat/curve25519_tables.h")
;; Pretend this isn't a relase tarball.
(with-output-to-file ".git"
(lambda _
(format #t "")))))))
(source rust-ring-0.13-sources)
(arguments
`(#:skip-build? #t ; TODO: Fix build
#:cargo-inputs
`(#:cargo-inputs
(("rust-lazy-static" ,rust-lazy-static-1)
("rust-libc" ,rust-libc-0.2)
("rust-untrusted" ,rust-untrusted-0.6)
;; build dependencies
("rust-cc" ,rust-cc-1))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'generate-curve25519-tables
(lambda _
(with-directory-excursion "third_party/fiat"
(with-output-to-file "curve25519_tables.h"
(lambda _
(invoke "python" "make_curve25519_tables.py")))))))))
(native-inputs
(list clang perl python-2))))
("rust-cc" ,rust-cc-1))))))
(define-public rust-ringbuf-0.2
(package