-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d056a79
commit 72eaf04
Showing
11 changed files
with
128 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,50 @@ | ||
let std_flags = ["--std=c11"; "-Wall"; "-Wextra"; "-Wpedantic"; "-O3"] | ||
let std_flags = ["-Wall"] | ||
|
||
let () = | ||
let c = Configurator.V1.create "mirage-crypto" in | ||
let ccomp_type_opt = Configurator.V1.ocaml_config_var c "ccomp_type" in | ||
let arch = | ||
let defines = | ||
Configurator.V1.C_define.import | ||
c | ||
~includes:[] | ||
[("__x86_64__", Switch); ("__i386__", Switch)] | ||
[("__x86_64__", Switch); ("__i386__", Switch); ("_WIN64", Switch); ("_WIN32", Switch)] | ||
in | ||
match defines with | ||
| (_, Switch true) :: _ -> `x86_64 | ||
| _ :: (_, Switch true) :: _ -> `x86 | ||
| _ :: _ :: (_, Switch true) :: _ -> `x86_64 | ||
| _ :: _ :: _ :: (_, Switch true) :: _ -> `x86 | ||
| _ -> `unknown | ||
in | ||
let accelerate_flags = | ||
match arch with | ||
| `x86_64 -> [ "-DACCELERATE"; "-mssse3"; "-maes"; "-mpclmul" ] | ||
match arch, ccomp_type_opt with | ||
| `x86_64, Some ccomp_type when ccomp_type = "msvc" -> [ "-DACCELERATE" ] | ||
| `x86_64, _ -> [ "-DACCELERATE"; "-mssse3"; "-maes"; "-mpclmul" ] | ||
| _ -> [] | ||
in | ||
let ent_flags = | ||
match arch with | ||
| `x86_64 | `x86 -> [ "-DENTROPY"; "-mrdrnd"; "-mrdseed" ] | ||
match arch, ccomp_type_opt with | ||
| (`x86_64 | `x86), Some ccomp_type when ccomp_type = "msvc" -> [ "-DENTROPY" ] | ||
| (`x86_64 | `x86), _ -> [ "-DENTROPY"; "-mrdrnd"; "-mrdseed" ] | ||
| _ -> [] | ||
in | ||
let flags = std_flags @ ent_flags in | ||
let lang_flags = | ||
match ccomp_type_opt with | ||
| Some ccomp_type when ccomp_type = "msvc" -> ["/std:c11"] | ||
| _ -> ["--std=c11"] | ||
in | ||
let warn_flags = | ||
match ccomp_type_opt with | ||
| Some ccomp_type when ccomp_type = "msvc" -> [] | ||
| _ -> ["-Wextra"; "-Wpedantic"] | ||
in | ||
let optimization_flags = | ||
match ccomp_type_opt with | ||
| Some ccomp_type when ccomp_type = "msvc" -> ["-O2"] | ||
| _ -> ["-O3"] | ||
in | ||
let flags = std_flags @ ent_flags @ lang_flags @ warn_flags @ optimization_flags in | ||
let opt_flags = flags @ accelerate_flags in | ||
Configurator.V1.Flags.write_sexp "cflags_optimized.sexp" opt_flags; | ||
Configurator.V1.Flags.write_sexp "cflags.sexp" flags |
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
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