forked from mirage/mirage-crypto
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Makefile to "cross"-build xen and freestanding
As discussed in mirage/mirage-xen#23, using dune's C compilation support leads to unexpected CFLAGS, especially -fPIC and -fno-strict-aliasing in our setup. To regain control of CFLAGS, instead use a Makefile. There's no need for the OCaml mirage-crypto.freestanding / mirage-crypto.xen sublibraries anymore. Failure of compilation are allowed if the respective opam packages (mirage-xen-posix, ocaml-freestanding) are not installed. For a successful cold `dune build @install` run, (alias install) is added to the (copy-files# ..) stanze in xen/dune and freestanding/dune. The libmirage_crypto_{xen,freestanding}_stubs.a are installed directly in the lib/mirage-crypto/ directory.
- Loading branch information
Showing
13 changed files
with
91 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# DUNE_GEN | ||
|
||
xen_linkopts = "-l:xen/libmirage_crypto_xen_stubs.a" | ||
freestanding_linkopts = "-l:freestanding/libmirage_crypto_freestanding_stubs.a" | ||
xen_linkopts = "-l:libmirage_crypto_xen_stubs.a" | ||
freestanding_linkopts = "-l:libmirage_crypto_freestanding_stubs.a" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
(lang dune 2.6) | ||
(lang dune 2.7) | ||
(name mirage-crypto) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig | ||
|
||
EXISTS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --exists ocaml-freestanding; echo $$?) | ||
|
||
.PHONY: all clean | ||
all: libmirage_crypto_freestanding_stubs.a | ||
|
||
ifeq ($(EXISTS), 1) | ||
libmirage_crypto_freestanding_stubs.a: | ||
touch $@ | ||
else | ||
CC ?= cc | ||
FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding) | ||
MIRAGE_CRYPTO_CFLAGS := $(shell sed 's/^(\(.*\))$$/\1/' ../src/cflags.sexp | tr -d '"') | ||
CFLAGS := $(MIRAGE_CRYPTO_CFLAGS) $(FREESTANDING_CFLAGS) | ||
|
||
OBJS=detect_cpu_features.o misc.o misc_sse.o hash_stubs.o md5.o sha1.o \ | ||
sha256.o sha512.o aes_generic.o aes_aesni.o des_generic.o chacha.o \ | ||
poly1305-donna.o ghash_pclmul.o ghash_generic.o ghash_ctmul.o \ | ||
entropy_cpu_stubs.o | ||
|
||
libmirage_crypto_freestanding_stubs.a: $(OBJS) | ||
$(AR) r $@ $^ | ||
endif | ||
|
||
clean: | ||
$(RM) $(OBJS) libmirage_crypto_freestanding_stubs.a |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
(copy_files# ../src/native/*) | ||
|
||
(library | ||
(name mirage_crypto_freestanding) | ||
(public_name mirage-crypto.freestanding) | ||
(optional) | ||
(libraries ocaml-freestanding) | ||
(foreign_stubs | ||
(language c) | ||
(flags | ||
(:standard) | ||
(:include ../src/cflags.sexp) | ||
(:include cflags-freestanding.sexp)) | ||
(names detect_cpu_features misc misc_sse hash_stubs md5 sha1 sha256 sha512 | ||
aes_generic aes_aesni des_generic chacha poly1305-donna ghash_pclmul | ||
ghash_generic ghash_ctmul entropy_cpu_stubs))) | ||
(copy_files# | ||
(alias install) | ||
(files ../src/native/*)) | ||
|
||
(rule | ||
(with-stdout-to | ||
cflags-freestanding.sexp | ||
(run ./cflags.sh))) | ||
(deps ../src/cflags.sexp Makefile) | ||
(targets libmirage_crypto_freestanding_stubs.a) | ||
(action | ||
(no-infer | ||
(progn | ||
(run %{make}))))) | ||
|
||
(install | ||
(package mirage-crypto) | ||
(section lib) | ||
(files libmirage_crypto_freestanding_stubs.a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig | ||
|
||
EXISTS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --exists mirage-xen-posix,mirage-xen-ocaml; echo $$?) | ||
|
||
.PHONY: all clean | ||
all: libmirage_crypto_xen_stubs.a | ||
|
||
ifeq ($(EXISTS), 1) | ||
libmirage_crypto_xen_stubs.a: | ||
touch $@ | ||
else | ||
CC ?= cc | ||
XEN_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags mirage-xen-posix,mirage-xen-ocaml) | ||
MIRAGE_CRYPTO_CFLAGS := $(shell sed 's/^(\(.*\))$$/\1/' ../src/cflags.sexp | tr -d '"') | ||
CFLAGS := $(MIRAGE_CRYPTO_CFLAGS) $(XEN_CFLAGS) | ||
|
||
OBJS=detect_cpu_features.o misc.o misc_sse.o hash_stubs.o md5.o sha1.o \ | ||
sha256.o sha512.o aes_generic.o aes_aesni.o des_generic.o chacha.o \ | ||
poly1305-donna.o ghash_pclmul.o ghash_generic.o ghash_ctmul.o \ | ||
entropy_cpu_stubs.o | ||
|
||
libmirage_crypto_xen_stubs.a: $(OBJS) | ||
$(AR) r $@ $^ | ||
endif | ||
|
||
clean: | ||
$(RM) $(OBJS) libmirage_crypto_xen_stubs.a |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
(copy_files# ../src/native/*) | ||
|
||
(library | ||
(name mirage_crypto_xen) | ||
(public_name mirage-crypto.xen) | ||
(optional) | ||
(libraries mirage-xen-posix) | ||
(foreign_stubs | ||
(language c) | ||
(names detect_cpu_features misc misc_sse hash_stubs md5 sha1 sha256 sha512 | ||
aes_generic aes_aesni des_generic chacha poly1305-donna ghash_pclmul | ||
ghash_generic ghash_ctmul entropy_cpu_stubs) | ||
(flags | ||
(:standard) | ||
(:include ../src/cflags.sexp) | ||
(:include cflags-xen.sexp)))) | ||
(copy_files# | ||
(alias install) | ||
(files ../src/native/*)) | ||
|
||
(rule | ||
(with-stdout-to | ||
cflags-xen.sexp | ||
(run ./cflags.sh))) | ||
(deps ../src/cflags.sexp Makefile) | ||
(targets libmirage_crypto_xen_stubs.a) | ||
(action | ||
(no-infer | ||
(progn | ||
(run %{make}))))) | ||
|
||
(install | ||
(package mirage-crypto) | ||
(section lib) | ||
(files libmirage_crypto_xen_stubs.a)) |