Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native compilation on non-GNU Unix systems #5237

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions scheme-libs/racket/unison/crypto.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@
(error 'blake2 "~a failed with return value ~a" fn r))))))

(define blake2b-raw (libb2-raw "blake2b"))
(define blake2s-raw (libb2-raw "blake2s"))

(define HashAlgorithm.Md5 (lc-algo "EVP_md5" 128))
(define HashAlgorithm.Sha1 (lc-algo "EVP_sha1" 160))
(define HashAlgorithm.Sha2_256 (lc-algo "EVP_sha256" 256))
(define HashAlgorithm.Sha2_512 (lc-algo "EVP_sha512" 512))
(define HashAlgorithm.Sha3_256 (lc-algo "EVP_sha3_256" 256))
(define HashAlgorithm.Sha3_512 (lc-algo "EVP_sha3_512" 512))
(define HashAlgorithm.Blake2s_256 (lc-algo "EVP_blake2s256" 256))
(define HashAlgorithm.Blake2b_512 (lc-algo "EVP_blake2b512" 512))

(define _EVP_PKEY-pointer (_cpointer 'EVP_PKEY))
(define _EVP_MD_CTX-pointer (_cpointer 'EVP_MD_CTX))
Expand Down Expand Up @@ -234,6 +233,8 @@
(chunked-bytes->bytes input)
(chunked-bytes->bytes signature)))

(define (HashAlgorithm.Blake2s_256) (cons 'blake2s 256))
(define (HashAlgorithm.Blake2b_512) (cons 'blake2b 512))
; This one isn't provided by libcrypto, for some reason
(define (HashAlgorithm.Blake2b_256) (cons 'blake2b 256))

Expand All @@ -252,6 +253,7 @@
[algo (car kind)])
(case algo
['blake2b (blake2b-raw output input #f bytes (bytes-length input) 0)]
['blake2s (blake2s-raw output input #f bytes (bytes-length input) 0)]
[else (EVP_Digest input (bytes-length input) output #f algo #f)])

output))
Expand Down Expand Up @@ -294,6 +296,7 @@
(define (hmacBytes-raw kind key input)
(case (car kind)
['blake2b (hmacBlake kind key input)]
['blake2s (hmacBlake kind key input)]
[else
(let* ([bytes (/ (cdr kind) 8)]
[output (make-bytes bytes)]
Expand Down
8 changes: 4 additions & 4 deletions unison-src/builtin-tests/jit-tests.output.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ foo = do
I found and typechecked these definitions in scratch.u. If you
do an `add` or `update`, here's how your codebase would
change:

⍟ These new definitions are ok to `add`:

foo : '{Exception} ()

```
Expand All @@ -58,10 +58,10 @@ an exception.
runtime-tests/selected> run.native testBug

💔💥

I've encountered a call to builtin.bug with the following
value:

"testing"

```
8 changes: 3 additions & 5 deletions unison-src/builtin-tests/jit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env sh
set -ex

# the first arg is the path to the unison executable
Expand All @@ -8,9 +8,6 @@ if [ -z "$1" ]; then
exit 1
fi

# call unison with all its args quoted
ucm=("$@")

runtime_tests_version="@unison/runtime-tests/main"
echo $runtime_tests_version

Expand All @@ -27,4 +24,5 @@ runtime_tests_version="$runtime_tests_version" \
< unison-src/builtin-tests/jit-tests.tpl.md \
> unison-src/builtin-tests/jit-tests.md

time "${ucm[@]}" transcript.fork -C $codebase -S $codebase unison-src/builtin-tests/jit-tests.md
# call unison with all its args quoted
time "$@" transcript.fork -C $codebase -S $codebase unison-src/builtin-tests/jit-tests.md
Loading