aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Driver.ml
diff options
context:
space:
mode:
Diffstat (limited to 'driver/Driver.ml')
-rw-r--r--driver/Driver.ml17
1 files changed, 14 insertions, 3 deletions
diff --git a/driver/Driver.ml b/driver/Driver.ml
index 27115f3f..81f28309 100644
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -14,13 +14,14 @@ open Printf
open Commandline
open Camlcoq
open Clflags
-open Optionsprinter
open Timing
(* Location of the compatibility library *)
let stdlib_path = ref Configuration.stdlib_path
+let dump_options = ref false
+
(* Optional sdump suffix *)
let sdump_suffix = ref ".json"
@@ -311,6 +312,8 @@ let process_c_file sourcename =
end in
if not !option_dprepro then
safe_remove preproname;
+ if !dump_options then
+ Optionsprinter.print (output_filename sourcename ".c" ".opt.json") !stdlib_path;
name
end
@@ -323,7 +326,9 @@ let process_i_file sourcename =
""
end else if !option_S then begin
compile_c_file sourcename sourcename
- (output_filename ~final:true sourcename ".c" ".s");
+ (output_filename ~final:true sourcename ".c" ".s");
+ if !dump_options then
+ Optionsprinter.print (output_filename sourcename ".c" ".opt.json") !stdlib_path;
""
end else begin
let asmname =
@@ -334,6 +339,8 @@ let process_i_file sourcename =
let objname = output_filename ~final: !option_c sourcename ".c" ".o" in
assemble asmname objname;
if not !option_dasm then safe_remove asmname;
+ if !dump_options then
+ Optionsprinter.print (output_filename sourcename ".c" ".opt.json") !stdlib_path;
objname
end
@@ -353,6 +360,8 @@ let process_cminor_file sourcename =
let objname = output_filename ~final: !option_c sourcename ".cm" ".o" in
assemble asmname objname;
if not !option_dasm then safe_remove asmname;
+ if !dump_options then
+ Optionsprinter.print (output_filename sourcename ".cm" ".opt.json") !stdlib_path;
objname
end
@@ -495,6 +504,7 @@ Tracing options:
-dmach Save generated Mach code in <file>.mach
-dasm Save generated assembly in <file>.s
-sdump Save info for post-linking validation in <file>.json
+ -doptions Save the compiler configurations in <file>.opt.json
General options:
-stdlib <dir> Set the path of the Compcert run-time library
-v Print external commands before invoking them
@@ -620,6 +630,7 @@ let cmdline_actions =
Exact "-dasm", Set option_dasm;
Exact "-sdump", Set option_sdump;
Exact "-sdump-suffix", String (fun s -> option_sdump := true; sdump_suffix:= s);
+ Exact "-doptions", Set dump_options;
(* General options *)
Exact "-v", Set option_v;
Exact "-stdlib", String(fun s -> stdlib_path := s);
@@ -711,6 +722,6 @@ let _ =
let linker_args = time "Total compilation time" perform_actions () in
if (not nolink) && linker_args <> [] then begin
linker (output_filename_default "a.out") linker_args
- end
+ end;
with Sys_error msg ->
eprintf "I/O error: %s.\n" msg; exit 2