2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2005 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the file LICENSE. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
2005-10-26 06:23:27 -07:00
|
|
|
|
2017-06-01 14:24:12 -07:00
|
|
|
(** Command line flags *)
|
|
|
|
|
2016-01-14 03:27:30 -08:00
|
|
|
(** Optimization parameters represented as ints indexed by round number. *)
|
|
|
|
module Int_arg_helper : sig
|
2016-02-10 08:52:07 -08:00
|
|
|
type parsed
|
2016-01-14 03:27:30 -08:00
|
|
|
|
2016-03-09 02:40:16 -08:00
|
|
|
val parse : string -> string -> parsed ref -> unit
|
2016-01-14 09:13:43 -08:00
|
|
|
|
|
|
|
type parse_result =
|
|
|
|
| Ok
|
|
|
|
| Parse_failed of exn
|
2016-03-09 02:40:16 -08:00
|
|
|
val parse_no_error : string -> parsed ref -> parse_result
|
2016-01-14 09:13:43 -08:00
|
|
|
|
2016-01-14 03:27:30 -08:00
|
|
|
val get : key:int -> parsed -> int
|
|
|
|
end
|
|
|
|
|
|
|
|
(** Optimization parameters represented as floats indexed by round number. *)
|
|
|
|
module Float_arg_helper : sig
|
2016-02-10 08:52:07 -08:00
|
|
|
type parsed
|
2016-01-14 03:27:30 -08:00
|
|
|
|
2016-03-09 02:40:16 -08:00
|
|
|
val parse : string -> string -> parsed ref -> unit
|
2016-01-14 09:13:43 -08:00
|
|
|
|
|
|
|
type parse_result =
|
|
|
|
| Ok
|
|
|
|
| Parse_failed of exn
|
2016-03-09 02:40:16 -08:00
|
|
|
val parse_no_error : string -> parsed ref -> parse_result
|
2016-01-14 09:13:43 -08:00
|
|
|
|
2016-01-14 03:27:30 -08:00
|
|
|
val get : key:int -> parsed -> float
|
|
|
|
end
|
|
|
|
|
|
|
|
type inlining_arguments = {
|
|
|
|
inline_call_cost : int option;
|
|
|
|
inline_alloc_cost : int option;
|
|
|
|
inline_prim_cost : int option;
|
|
|
|
inline_branch_cost : int option;
|
|
|
|
inline_indirect_cost : int option;
|
|
|
|
inline_lifting_benefit : int option;
|
2016-02-10 08:52:07 -08:00
|
|
|
inline_branch_factor : float option;
|
|
|
|
inline_max_depth : int option;
|
|
|
|
inline_max_unroll : int option;
|
2016-01-14 03:27:30 -08:00
|
|
|
inline_threshold : float option;
|
|
|
|
inline_toplevel_threshold : int option;
|
|
|
|
}
|
|
|
|
|
|
|
|
val classic_arguments : inlining_arguments
|
|
|
|
val o1_arguments : inlining_arguments
|
|
|
|
val o2_arguments : inlining_arguments
|
|
|
|
val o3_arguments : inlining_arguments
|
|
|
|
|
|
|
|
(** Set all the inlining arguments for a round.
|
|
|
|
The default is set if no round is provided. *)
|
|
|
|
val use_inlining_arguments_set : ?round:int -> inlining_arguments -> unit
|
|
|
|
|
2005-10-26 06:23:27 -07:00
|
|
|
val objfiles : string list ref
|
|
|
|
val ccobjs : string list ref
|
|
|
|
val dllibs : string list ref
|
|
|
|
val compile_only : bool ref
|
|
|
|
val output_name : string option ref
|
|
|
|
val include_dirs : string list ref
|
|
|
|
val no_std_include : bool ref
|
|
|
|
val print_types : bool ref
|
|
|
|
val make_archive : bool ref
|
|
|
|
val debug : bool ref
|
2018-10-15 04:50:06 -07:00
|
|
|
val debug_full : bool ref
|
2018-07-15 12:01:26 -07:00
|
|
|
val unsafe : bool ref
|
2015-12-24 16:04:43 -08:00
|
|
|
val use_linscan : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val link_everything : bool ref
|
|
|
|
val custom_runtime : bool ref
|
2015-04-22 03:53:47 -07:00
|
|
|
val no_check_prims : bool ref
|
2014-05-10 17:17:05 -07:00
|
|
|
val bytecode_compatible_32 : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val output_c_object : bool ref
|
2015-07-17 07:31:05 -07:00
|
|
|
val output_complete_object : bool ref
|
2019-09-25 00:07:31 -07:00
|
|
|
val output_complete_executable : bool ref
|
2013-06-05 09:34:40 -07:00
|
|
|
val all_ccopts : string list ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val classic : bool ref
|
|
|
|
val nopervasives : bool ref
|
2018-05-18 14:21:01 -07:00
|
|
|
val match_context_rows : int ref
|
2014-08-07 02:46:34 -07:00
|
|
|
val open_modules : string list ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val preprocessor : string option ref
|
2013-06-05 09:34:40 -07:00
|
|
|
val all_ppx : string list ref
|
2018-07-06 05:43:29 -07:00
|
|
|
val absname : bool ref
|
2007-05-16 01:21:41 -07:00
|
|
|
val annotations : bool ref
|
2012-05-30 07:52:37 -07:00
|
|
|
val binary_annotations : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val use_threads : bool ref
|
|
|
|
val noassert : bool ref
|
|
|
|
val verbose : bool ref
|
|
|
|
val noprompt : bool ref
|
2012-01-27 04:48:15 -08:00
|
|
|
val nopromptcont : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val init_file : string option ref
|
2013-08-04 12:58:09 -07:00
|
|
|
val noinit : bool ref
|
2016-05-03 07:45:25 -07:00
|
|
|
val noversion : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val use_prims : string ref
|
|
|
|
val use_runtime : string ref
|
2019-03-13 03:46:37 -07:00
|
|
|
val plugin : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val principal : bool ref
|
2012-01-22 23:59:45 -08:00
|
|
|
val real_paths : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val recursive_types : bool ref
|
2009-12-09 01:17:12 -08:00
|
|
|
val strict_sequence : bool ref
|
2014-08-29 10:14:00 -07:00
|
|
|
val strict_formats : bool ref
|
2009-07-15 07:06:37 -07:00
|
|
|
val applicative_functors : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val make_runtime : bool ref
|
2008-12-03 10:09:09 -08:00
|
|
|
val c_compiler : string option ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val no_auto_link : bool ref
|
|
|
|
val dllpaths : string list ref
|
|
|
|
val make_package : bool ref
|
|
|
|
val for_package : string option ref
|
2011-10-19 22:49:38 -07:00
|
|
|
val error_size : int ref
|
2014-04-25 01:41:13 -07:00
|
|
|
val float_const_prop : bool ref
|
2013-12-19 22:55:26 -08:00
|
|
|
val transparent_modules : bool ref
|
2018-02-19 05:09:49 -08:00
|
|
|
val unique_ids : bool ref
|
2019-12-24 04:35:42 -08:00
|
|
|
val locations : bool ref
|
2012-10-17 09:09:38 -07:00
|
|
|
val dump_source : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dump_parsetree : bool ref
|
2012-12-18 09:19:53 -08:00
|
|
|
val dump_typedtree : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dump_rawlambda : bool ref
|
|
|
|
val dump_lambda : bool ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val dump_rawclambda : bool ref
|
2012-02-21 09:41:02 -08:00
|
|
|
val dump_clambda : bool ref
|
2016-02-09 02:33:57 -08:00
|
|
|
val dump_rawflambda : bool ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val dump_flambda : bool ref
|
|
|
|
val dump_flambda_let : int option ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dump_instr : bool ref
|
2018-06-27 06:56:29 -07:00
|
|
|
val keep_camlprimc_file : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val keep_asm_file : bool ref
|
|
|
|
val optimize_for_speed : bool ref
|
|
|
|
val dump_cmm : bool ref
|
|
|
|
val dump_selection : bool ref
|
2014-04-26 03:40:22 -07:00
|
|
|
val dump_cse : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dump_live : bool ref
|
2017-09-15 03:08:14 -07:00
|
|
|
val dump_avail : bool ref
|
|
|
|
val debug_runavail : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dump_spill : bool ref
|
|
|
|
val dump_split : bool ref
|
|
|
|
val dump_interf : bool ref
|
|
|
|
val dump_prefer : bool ref
|
|
|
|
val dump_regalloc : bool ref
|
|
|
|
val dump_reload : bool ref
|
|
|
|
val dump_scheduling : bool ref
|
|
|
|
val dump_linear : bool ref
|
2015-12-24 16:04:43 -08:00
|
|
|
val dump_interval : bool ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val keep_startup_file : bool ref
|
|
|
|
val dump_combine : bool ref
|
|
|
|
val native_code : bool ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val default_inline_threshold : float
|
|
|
|
val inline_threshold : Float_arg_helper.parsed ref
|
2016-02-10 08:52:07 -08:00
|
|
|
val inlining_report : bool ref
|
|
|
|
val simplify_rounds : int option ref
|
|
|
|
val default_simplify_rounds : int ref
|
|
|
|
val rounds : unit -> int
|
|
|
|
val default_inline_max_unroll : int
|
|
|
|
val inline_max_unroll : Int_arg_helper.parsed ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val default_inline_toplevel_threshold : int
|
|
|
|
val inline_toplevel_threshold : Int_arg_helper.parsed ref
|
|
|
|
val default_inline_call_cost : int
|
|
|
|
val default_inline_alloc_cost : int
|
|
|
|
val default_inline_prim_cost : int
|
|
|
|
val default_inline_branch_cost : int
|
|
|
|
val default_inline_indirect_cost : int
|
|
|
|
val default_inline_lifting_benefit : int
|
|
|
|
val inline_call_cost : Int_arg_helper.parsed ref
|
|
|
|
val inline_alloc_cost : Int_arg_helper.parsed ref
|
|
|
|
val inline_prim_cost : Int_arg_helper.parsed ref
|
|
|
|
val inline_branch_cost : Int_arg_helper.parsed ref
|
|
|
|
val inline_indirect_cost : Int_arg_helper.parsed ref
|
|
|
|
val inline_lifting_benefit : Int_arg_helper.parsed ref
|
2016-02-10 08:52:07 -08:00
|
|
|
val default_inline_branch_factor : float
|
|
|
|
val inline_branch_factor : Float_arg_helper.parsed ref
|
2005-10-26 06:23:27 -07:00
|
|
|
val dont_write_files : bool ref
|
|
|
|
val std_include_flag : string -> string
|
|
|
|
val std_include_dir : unit -> string list
|
2007-11-06 07:16:56 -08:00
|
|
|
val shared : bool ref
|
|
|
|
val dlcode : bool ref
|
2015-01-24 08:35:26 -08:00
|
|
|
val pic_code : bool ref
|
2011-03-17 09:18:05 -07:00
|
|
|
val runtime_variant : string ref
|
2019-03-11 04:45:55 -07:00
|
|
|
val with_runtime : bool ref
|
2013-06-05 09:34:40 -07:00
|
|
|
val force_slash : bool ref
|
2015-06-28 06:11:50 -07:00
|
|
|
val keep_docs : bool ref
|
2013-09-17 05:45:05 -07:00
|
|
|
val keep_locs : bool ref
|
2014-04-29 04:56:17 -07:00
|
|
|
val unsafe_string : bool ref
|
2014-08-18 06:28:34 -07:00
|
|
|
val opaque : bool ref
|
2017-06-09 04:29:21 -07:00
|
|
|
val profile_columns : Profile.column list ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val flambda_invariant_checks : bool ref
|
|
|
|
val unbox_closures : bool ref
|
2016-02-26 08:15:06 -08:00
|
|
|
val unbox_closures_factor : int ref
|
|
|
|
val default_unbox_closures_factor : int
|
2016-02-08 05:05:38 -08:00
|
|
|
val unbox_free_vars_of_closures : bool ref
|
|
|
|
val unbox_specialised_args : bool ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val clambda_checks : bool ref
|
2016-02-10 08:52:07 -08:00
|
|
|
val default_inline_max_depth : int
|
|
|
|
val inline_max_depth : Int_arg_helper.parsed ref
|
2016-01-14 03:27:30 -08:00
|
|
|
val remove_unused_arguments : bool ref
|
|
|
|
val dump_flambda_verbose : bool ref
|
|
|
|
val classic_inlining : bool ref
|
2016-12-06 08:18:04 -08:00
|
|
|
val afl_instrument : bool ref
|
|
|
|
val afl_inst_ratio : int ref
|
2019-06-27 09:07:25 -07:00
|
|
|
val function_sections : bool ref
|
2016-01-14 03:27:30 -08:00
|
|
|
|
|
|
|
val all_passes : string list ref
|
|
|
|
val dumped_pass : string -> bool
|
|
|
|
val set_dumped_pass : string -> bool -> unit
|
2015-08-15 08:57:51 -07:00
|
|
|
|
2018-07-27 00:51:53 -07:00
|
|
|
val dump_into_file : bool ref
|
|
|
|
|
2018-10-19 13:20:30 -07:00
|
|
|
(* Support for flags that can also be set from an environment variable *)
|
|
|
|
type 'a env_reader = {
|
|
|
|
parse : string -> 'a option;
|
2019-02-27 05:28:06 -08:00
|
|
|
print : 'a -> string;
|
2018-10-19 13:20:30 -07:00
|
|
|
usage : string;
|
|
|
|
env_var : string;
|
|
|
|
}
|
|
|
|
|
Respect OCAML_COLOR environment variable for deciding whether to use colors
Since 4.03, OCaml supports coloring its messages to standard output and standard
error, depending on the "-color" argument ({always,never,auto}). This commit
adds support for the environment variable "OCAML_COLOR" (which value can as well
be {always,never,auto}).
The command line argument "-color" takes precedence, "OCAML_COLOR" is only
taken into consideration if no "-color" is provided.
The motivation for this is that the user should have control over coloring
OCaml's output messages. OCamlbuild, a widely used build tool executes OCaml
not under a tty (and OCaml does not colorize errors and warnings), which lead
various packages use `color(always)` in their `_tags` files, which breaks with
other (non-interactive) programs (i.e. editor helpers).
Further discussion was done at https://github.com/ocaml/ocamlbuild/issues/87 and
https://github.com/ocaml/ocaml/pull/1098.
2017-03-11 03:38:59 -08:00
|
|
|
val color : Misc.Color.setting option ref
|
2018-10-19 13:20:30 -07:00
|
|
|
val color_reader : Misc.Color.setting env_reader
|
|
|
|
|
|
|
|
val error_style : Misc.Error_style.setting option ref
|
|
|
|
val error_style_reader : Misc.Error_style.setting env_reader
|
2016-05-25 07:29:05 -07:00
|
|
|
|
|
|
|
val unboxed_types : bool ref
|
2017-01-17 05:34:35 -08:00
|
|
|
|
2019-02-05 09:05:24 -08:00
|
|
|
val insn_sched : bool ref
|
|
|
|
val insn_sched_default : bool
|
|
|
|
|
2015-11-10 03:18:48 -08:00
|
|
|
module Compiler_pass : sig
|
2020-10-13 06:07:13 -07:00
|
|
|
type t = Parsing | Typing | Scheduling | Emit
|
2015-11-10 03:18:48 -08:00
|
|
|
val of_string : string -> t option
|
|
|
|
val to_string : t -> string
|
2019-08-26 09:12:14 -07:00
|
|
|
val is_compilation_pass : t -> bool
|
2020-10-07 03:32:40 -07:00
|
|
|
val available_pass_names : filter:(t -> bool) -> native:bool -> string list
|
|
|
|
val can_save_ir_after : t -> bool
|
2020-10-13 06:07:13 -07:00
|
|
|
val compare : t -> t -> int
|
|
|
|
val to_output_filename: t -> prefix:string -> string
|
|
|
|
val of_input_filename: string -> t option
|
2015-11-10 03:18:48 -08:00
|
|
|
end
|
|
|
|
val stop_after : Compiler_pass.t option ref
|
|
|
|
val should_stop_after : Compiler_pass.t -> bool
|
2020-10-07 03:32:40 -07:00
|
|
|
val set_save_ir_after : Compiler_pass.t -> bool -> unit
|
|
|
|
val should_save_ir_after : Compiler_pass.t -> bool
|
2015-11-10 03:18:48 -08:00
|
|
|
|
2017-01-17 05:34:35 -08:00
|
|
|
val arg_spec : (string * Arg.spec * string) list ref
|
|
|
|
|
|
|
|
(* [add_arguments __LOC__ args] will add the arguments from [args] at
|
|
|
|
the end of [arg_spec], checking that they have not already been
|
|
|
|
added by [add_arguments] before. A warning is printed showing the
|
|
|
|
locations of the function from which the argument was previously
|
|
|
|
added. *)
|
|
|
|
val add_arguments : string -> (string * Arg.spec * string) list -> unit
|
|
|
|
|
2020-06-16 05:32:41 -07:00
|
|
|
(* [parse_arguments argv anon_arg usage] will parse the arguments, using
|
2019-03-13 03:46:37 -07:00
|
|
|
the arguments provided in [Clflags.arg_spec].
|
2017-01-17 05:34:35 -08:00
|
|
|
*)
|
2020-06-16 05:32:41 -07:00
|
|
|
val parse_arguments : string array -> Arg.anon_fun -> string -> unit
|
2017-01-17 05:34:35 -08:00
|
|
|
|
2017-05-14 07:44:42 -07:00
|
|
|
(* [print_arguments usage] print the standard usage message *)
|
2017-01-17 05:34:35 -08:00
|
|
|
val print_arguments : string -> unit
|
2017-05-14 07:44:42 -07:00
|
|
|
|
|
|
|
(* [reset_arguments ()] clear all declared arguments *)
|
|
|
|
val reset_arguments : unit -> unit
|