From c879cd9abb6e5dac1bc303da1b0c11e551d8528e Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Sun, 23 Aug 2015 19:43:14 +0200 Subject: Added the directory ../share/compcert to the search path for .ini files and replaced the if else for the different possibilities by a List.find. --- driver/Configuration.ml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'driver') diff --git a/driver/Configuration.ml b/driver/Configuration.ml index 64f24820..41325368 100644 --- a/driver/Configuration.ml +++ b/driver/Configuration.ml @@ -20,17 +20,20 @@ let ini_file_name = Sys.getenv "COMPCERT_CONFIG" with Not_found -> let exe_dir = Filename.dirname Sys.executable_name in - let exe_ini = Filename.concat exe_dir "compcert.ini" in let share_dir = Filename.concat (Filename.concat exe_dir Filename.parent_dir_name) - "share" in - let share_ini = Filename.concat share_dir "compcert.ini" in - if Sys.file_exists exe_ini then exe_ini - else if Sys.file_exists share_ini then share_ini - else begin - eprintf "Cannot find compcert.ini configuration file.\n"; - exit 2 - end + "share" in + let share_compcert_dir = + Filename.concat share_dir "compcert" in + let search_path = [exe_dir;share_dir;share_compcert_dir] in + let files = List.map (fun s -> Filename.concat s "compcert.ini") search_path in + try + List.find Sys.file_exists files + with Not_found -> + begin + eprintf "Cannot find compcert.ini configuration file.\n"; + exit 2 + end (* Read in the .ini file *) -- cgit From 25508b2953ff8d0941c257ee1cb887278cfebd79 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Sun, 23 Aug 2015 20:25:46 +0200 Subject: Added error message when no input file is specified. --- driver/Driver.ml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'driver') diff --git a/driver/Driver.ml b/driver/Driver.ml index 37e3b44c..e787b935 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -683,6 +683,11 @@ let _ = eprintf "Ambiguous '-o' option (multiple source files)\n"; exit 2 end; + if !num_source_files = 0 then + begin + eprintf "ccomp: error: no input file\n"; + exit 2 + end; 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 -- cgit From 448477ec6be14c0217f7ff74d90fb53d78fdf5c9 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 24 Aug 2015 08:20:19 +0200 Subject: Count number of input files and do not use number of source files for warning about no input. --- driver/Driver.ml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'driver') diff --git a/driver/Driver.ml b/driver/Driver.ml index e787b935..d628e283 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -514,6 +514,8 @@ let unset_all opts = List.iter (fun r -> r := false) opts let num_source_files = ref 0 +let num_input_files = ref 0 + let cmdline_actions = let f_opt name ref = [Exact("-f" ^ name), Set ref; Exact("-fno-" ^ name), Unset ref] in @@ -636,25 +638,25 @@ let cmdline_actions = eprintf "Unknown option `%s'\n" s; exit 2); (* File arguments *) Suffix ".c", Self (fun s -> - push_action process_c_file s; incr num_source_files); + push_action process_c_file s; incr num_source_files; incr num_input_files); Suffix ".i", Self (fun s -> - push_action process_i_file s; incr num_source_files); + push_action process_i_file s; incr num_source_files; incr num_input_files); Suffix ".p", Self (fun s -> - push_action process_i_file s; incr num_source_files); + push_action process_i_file s; incr num_source_files; incr num_input_files); Suffix ".cm", Self (fun s -> - push_action process_cminor_file s; incr num_source_files); + push_action process_cminor_file s; incr num_source_files; incr num_input_files); Suffix ".s", Self (fun s -> - push_action process_s_file s; incr num_source_files); + push_action process_s_file s; incr num_source_files; incr num_input_files); Suffix ".S", Self (fun s -> - push_action process_S_file s; incr num_source_files); - Suffix ".o", Self push_linker_arg; - Suffix ".a", Self push_linker_arg; + push_action process_S_file s; incr num_source_files; incr num_input_files); + Suffix ".o", Self (fun s -> push_linker_arg s; incr num_input_files); + Suffix ".a", Self (fun s -> push_linker_arg s; incr num_input_files); (* GCC compatibility: .o.ext files and .so files are also object files *) - _Regexp ".*\\.o\\.", Self push_linker_arg; - Suffix ".so", Self push_linker_arg; + _Regexp ".*\\.o\\.", Self (fun s -> push_linker_arg s; incr num_input_files); + Suffix ".so", Self (fun s -> push_linker_arg s; incr num_input_files); (* GCC compatibility: .h files can be preprocessed with -E *) Suffix ".h", Self (fun s -> - push_action process_h_file s; incr num_source_files); + push_action process_h_file s; incr num_source_files; incr num_input_files); ] let _ = @@ -683,7 +685,7 @@ let _ = eprintf "Ambiguous '-o' option (multiple source files)\n"; exit 2 end; - if !num_source_files = 0 then + if !num_input_files = 0 then begin eprintf "ccomp: error: no input file\n"; exit 2 -- cgit From c642e761fa8943584343c3097a53019244cd74cf Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 25 Aug 2015 12:51:31 +0200 Subject: Fixed the -T option. The diab compiler expected -Wm without whitespace. --- driver/Driver.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'driver') diff --git a/driver/Driver.ml b/driver/Driver.ml index d628e283..7832e6d2 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -568,7 +568,7 @@ let cmdline_actions = Prefix "-l", Self push_linker_arg; Prefix "-L", Self push_linker_arg; Exact "-T", String (fun s -> if Configuration.system = "diab" then - push_linker_arg ("-Wm "^s) + push_linker_arg ("-Wm"^s) else push_linker_arg ("-T "^s)); Prefix "-Wl,", Self push_linker_arg; -- cgit From 7cfaf10b604372044f53cb65b03df33c23f8b26d Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Tue, 25 Aug 2015 14:00:14 +0200 Subject: Improve printing of internal compiler errors. --- driver/Driver.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'driver') diff --git a/driver/Driver.ml b/driver/Driver.ml index 7832e6d2..b646dc83 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -183,7 +183,7 @@ let compile_c_ast sourcename csyntax ofile debug = | Errors.OK asm -> Asmexpand.expand_program asm | Errors.Error msg -> - print_error stderr msg; + eprintf "%s: %a" sourcename print_error msg; exit 2 in (* Dump Asm in binary and JSON format *) if !option_sdump then @@ -221,7 +221,7 @@ let compile_cminor_file ifile ofile = (CMtypecheck.type_program (CMparser.prog CMlexer.token lb)) with | Errors.Error msg -> - print_error stderr msg; + eprintf "%s: %a" ifile print_error msg; exit 2 | Errors.OK p -> let oc = open_out ofile in -- cgit