Skip to content

Commit

Permalink
replace opam variable with environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pqwy committed Nov 15, 2015
1 parent f9b6de1 commit ec061f0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
(trunk):
* Avoid including intrinsics-related headers if SSE/AES-NI is disabled
* Replace opam variable `nocrypto-inhibit-modernity` with `$NOCRYPTO_NO_ACCEL`
* Remove cstruct equality

0.5.1 (2015-07-07):
* Disable AES-NI if not supported in the `./configure` step.
* Support the global opam variable `nocrypto-inhibit-modernity`.
Expand Down
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,11 @@ compiled the library with acceleration, but you are using it on a machine that d

`./configure --enable-modernity` enables non-portable code if the build machine supports it.

It defaults to `enable`, but the `opam` file disables it if global opam variable
`nocrypto-inhibit-modernity` is `true`. You can do something like:

```
switch=$(opam config var switch)
echo 'nocrypto-inhibit-modernity: true' >> ~/.opam/${switch}/config/global-config.config
```

#### Opam woes

Opam dies:

```
[ERROR] nocrypto-inhibit-modernity is not a valid variable.
[WARNING] Invalid variable nocrypto-inhibit-modernity in filter
[ERROR] 'nocrypto-inhibit-modernity' has type string, but a env element of type bool was expected.
[ERROR] The compilation of nocrypto.XXX failed.
```

Either upgrade opam, or set the variable, as above.
The flag defaults to `enable`.

A second way to disable this feature is by exporting `$NOCRYPTO_NO_ACCEL`
environment variable during build. This is desirable, for example, when building
via `opam`.

[docs]: http://mirleft.github.io/ocaml-nocrypto
[nocrypto-mli]: https://github.com/mirleft/ocaml-nocrypto/blob/master/src/nocrypto.mli
1 change: 0 additions & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ license: "BSD2"

build: [
[ "./configure" "--prefix" prefix
"--disable-modernity" {nocrypto-inhibit-modernity}
"--%{lwt:enable}%-lwt"
"--%{mirage-xen+mirage-entropy-xen:enable}%-xen" ]
[ make ]
Expand Down
15 changes: 11 additions & 4 deletions postconf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ XEN_CFLAGS="disabled"
grep -q '^xen="true"' setup.data && XEN_CFLAGS="$(pkg-config --static mirage-xen --cflags)"
echo "XEN_CFLAGS=\"${XEN_CFLAGS}\"" >> setup.data

# Kill CPU acceleration if requested but unsupported by the current host.
# Kill CPU acceleration if requested in ./configure, but:
# * unsupported by the current host CPU;
# * unsupported by the current toolchain; or
# * disabled via NOCRYPTO_NO_ACCEL env var.
#
if grep -q '^modernity="true"' setup.data; then
function test_platform {
CPUDETECT=$(mktemp -t nocrypto.XXXXXX)
( cc src/native/cpudetect_static.c -o ${CPUDETECT} > /dev/null 2>&1 \
&& ${CPUDETECT} ) || echo "modernity=\"false\"" >> setup.data
(cc src/native/cpudetect_static.c -o ${CPUDETECT} > /dev/null 2>&1 && ${CPUDETECT})
ok=$?
rm -f ${CPUDETECT}
return $ok
}
if grep -q '^modernity="true"' setup.data; then
[[ -z $NOCRYPTO_NO_ACCEL ]] && test_platform || echo "modernity=\"false\"" >> setup.data
fi

0 comments on commit ec061f0

Please sign in to comment.