Skip to content

Commit

Permalink
check if SSSE3 is supported before enabling BLST by default on AMD64 (#…
Browse files Browse the repository at this point in the history
…72)

* check if SSSE3 is supported before enabling BLST by default on AMD64

* cross-compilation support
  • Loading branch information
stefantalpalaru authored Aug 24, 2020
1 parent 2317e9c commit da9ae49
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions blscurve/bls_backend.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# This file may not be copied, modified, or distributed except according to
# those terms.

import os

const BLS_FORCE_BACKEND*{.strdefine.} = "auto"

static: doAssert BLS_FORCE_BACKEND == "auto" or
Expand All @@ -19,10 +21,12 @@ type BlsBackendKind* = enum
Miracl

when BLS_FORCE_BACKEND == "blst" or (
BLS_FORCE_BACKEND == "auto" and
sizeof(int) == 8 and
(defined(arm64) or defined(amd64))
):
BLS_FORCE_BACKEND == "auto" and
sizeof(int) == 8 and
(defined(arm64) or (
defined(amd64) and
gorgeEx(getEnv("CC", "gcc") & " -march=native -dM -E -x c /dev/null | grep -q SSSE3").exitCode == 0))
):
const BLS_BACKEND* = BLST
else:
const BLS_BACKEND* = Miracl
Expand Down

0 comments on commit da9ae49

Please sign in to comment.