Skip to content

Commit

Permalink
Allow to override flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
mtzguido committed Feb 12, 2025
1 parent 2d04a43 commit 8aa1ab7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/Driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ let detect_cc () =
KPrint.bprintf "%scc is:%s %s%s\n" Ansi.underline Ansi.reset !cc real
end;

cc_flavor := detect_compiler_flavor !cc;
begin
match !Options.cc_flavor with
| Some f -> cc_flavor := f
| None -> cc_flavor := detect_compiler_flavor !cc
end;

if not !Options.silent then
KPrint.bprintf "%scc flavor is:%s %s\n" Ansi.underline Ansi.reset
(Options.string_of_compiler_flavor !cc_flavor);
Expand Down
9 changes: 9 additions & 0 deletions lib/Options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ let string_of_compiler_flavor = function
| Compcert -> "compcert"
| MSVC -> "msvc"

let compiler_flavor_of_string = function
| "generic" -> Generic
| "gcc" -> GCC
| "clang" -> Clang
| "compcert" -> Compcert
| "msvc" -> MSVC
| s -> failwith ("unrecognized compiler flavor: " ^ s)

let pinc b = function
| All -> Buffer.add_string b "*"
| HeaderOnly h -> Buffer.add_string b h; Buffer.add_string b ".h"
Expand All @@ -43,6 +51,7 @@ let verbose = ref false
let silent = ref false
let exe_name = ref ""
let cc = ref ""
let cc_flavor : compiler_flavor option ref = ref None
let m32 = ref false
let fsopts: string list ref = ref []
let ccopts: string list ref = ref []
Expand Down
9 changes: 7 additions & 2 deletions src/Karamel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,13 @@ Supported options:|}
(* KaRaMeL as a driver *)
"-fstar", Arg.Set_string Options.fstar, " fstar.exe to use; defaults to \
'fstar.exe'";
"-cc", Arg.Set_string Options.cc, " compiler to use; one of gcc (default), \
compcert, g++, clang, msvc";
"-cc", Arg.Set_string Options.cc, " compiler to use; default is 'cc'. \
you can also set the CC environment variable";
"-ccflavor", Arg.String (fun s ->
let flav = Options.compiler_flavor_of_string s in
Options.cc_flavor := Some flav), " C compiler flavor. This is \
normally autodetected. It can be set to 'gcc', 'clang', 'compcert', 'msvc' \
or 'generic'";
"-m32", Arg.Set Options.m32, " turn on 32-bit cross-compiling";
"-fsopt", Arg.String (prepend Options.fsopts), " option to pass to F* (use \
-fsopts to pass a comma-separated list of values)";
Expand Down

0 comments on commit 8aa1ab7

Please sign in to comment.