Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for flambda's optimization options to OCamlbuild #68

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ branch; this version that should be usable for testing packages using
(François Bobot, review by Armaël Géneau)
- #51: synchronize handling of -o flag for C files with upstream OCaml
(whitequark)
- #67: Add support for flambda's optimization parameters
(martin-neuhaeusser)

OCamlbuild 0.9.0 (19 Jan 2016):
-------------------------------
Expand Down
56 changes: 54 additions & 2 deletions src/ocaml_specific.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ module C_tools = struct
if Filename.check_suffix x ".o" && !Options.ext_obj <> "o" then
Pathname.update_extension !Options.ext_obj x
else x in
let resluts = build (List.map (fun o -> List.map (fun dir -> dir / obj_of_o o) include_dirs) objs) in
let results = build (List.map (fun o -> List.map (fun dir -> dir / obj_of_o o) include_dirs) objs) in
let objs = List.map begin function
| Good o -> o
| Bad exn -> raise exn
end resluts in
end results in
Cmd(S[!Options.ocamlmklib; A"-o"; Px libname; T(tags_of_pathname a++"c"++"ocamlmklib"); atomize objs]);;
end

Expand Down Expand Up @@ -715,6 +715,42 @@ let () =
(fun param -> S [A "-open"; A param]);
pflag ["ocaml"; "link"] "runtime_variant" ~doc_param:"_pic"
(fun param -> S [A "-runtime-variant"; A param]);
pflag ["ocaml"; "native"; "compile"] "optimize" ~doc_param:"2"
(fun param ->
match param with
| "classic"
| "2"
| "3" -> S [A ("-O" ^ param)]
| _ ->
let e = Printf.sprintf
"Invalid parameter for \"optimize\" tag: %s (can be classic, 2, or 3)."
param
in
raise (Invalid_argument e));
pflag ["ocaml"; "native"; "compile"] "optimization_rounds" ~doc_param:"2"
(fun param -> S [A "-rounds"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_toplevel" ~doc_param:"160"
(fun param -> S [A "-inline-toplevel"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_branch_factor" ~doc_param:"0.1"
(fun param -> S [A "-inline-branch-factor"; A param];);
pflag ["ocaml"; "native"; "compile"] "inline_alloc_cost" ~doc_param:"7"
(fun param -> S [A "-inline-alloc-cost"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_branch_cost" ~doc_param:"5"
(fun param -> S [A "-inline-branch-cost"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_call_cost" ~doc_param:"5"
(fun param -> S [A "-inline-call-cost"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_indirect_cost" ~doc_param:"4"
(fun param -> S [A "-inline-indirect-cost"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_prim_cost" ~doc_param:"3"
(fun param -> S [A "-inline-prim-cost"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_lifting_benefit"
~doc_param:"1300" (fun param -> S [A "-inline-lifting-benefit"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_max_depth" ~doc_param:"1"
(fun param -> S [A "-inline-max-depth"; A param]);
pflag ["ocaml"; "native"; "compile"] "inline_max_unroll" ~doc_param:"0"
(fun param -> S [A "-inline-max-unroll"; A param]);
pflag ["ocaml"; "native"; "compile"] "unbox_closures_factor" ~doc_param:"10"
(fun param -> S [A "-unbox-closures-factor"; A param]);
()

let camlp4_flags camlp4s =
Expand Down Expand Up @@ -860,6 +896,22 @@ flag ["ocaml"; "doc"; "docfile"; "dot"] (A"-dot");;
flag ["ocaml"; "doc"; "docfile"; "tex"] (A"-latex");;
flag ["ocaml"; "doc"; "docfile"; "texi"] (A"-texi");;

(* Inlining and flambda optimization options *)
flag ["ocaml"; "native"; "compile"; "inlining_report"]
(A"-inlining-report");;

flag ["ocaml"; "native"; "compile"; "remove_unused_arguments"]
(A"-remove-unused-arguments");;

flag ["ocaml"; "native"; "compile"; "unbox_closures"]
(A"-unbox-closures");;

flag ["ocaml"; "native"; "compile"; "no_unbox_free_vars_of_closures"]
(A"-no-unbox-free-vars-of-closures");;

flag ["ocaml"; "native"; "compile"; "no_unbox_specialized_args"]
(A"-no-unbox-specialized-args");;

(* Kept for backward compatibility. *)
flag ["ocaml"; "doc"; "docdir"; "manpage"] (A"-man");;

Expand Down