1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
1995-07-02 09:41:48 -07:00
|
|
|
(* Link a set of .cmx/.o files and produce an executable *)
|
|
|
|
|
|
|
|
open Misc
|
|
|
|
open Config
|
2010-05-19 04:29:38 -07:00
|
|
|
open Cmx_format
|
1995-07-02 09:41:48 -07:00
|
|
|
open Compilenv
|
|
|
|
|
|
|
|
type error =
|
|
|
|
File_not_found of string
|
|
|
|
| Not_an_object_file of string
|
2000-04-10 08:01:30 -07:00
|
|
|
| Missing_implementations of (string * string list) list
|
1995-07-02 09:41:48 -07:00
|
|
|
| Inconsistent_interface of string * string * string
|
|
|
|
| Inconsistent_implementation of string * string * string
|
|
|
|
| Assembler_error of string
|
|
|
|
| Linking_error
|
2002-01-04 07:57:19 -08:00
|
|
|
| Multiple_definition of string * string * string
|
2006-10-17 05:33:58 -07:00
|
|
|
| Missing_cmx of string * string
|
1995-07-02 09:41:48 -07:00
|
|
|
|
|
|
|
exception Error of error
|
|
|
|
|
|
|
|
(* Consistency check between interfaces and implementations *)
|
|
|
|
|
2002-11-17 08:42:12 -08:00
|
|
|
let crc_interfaces = Consistbl.create ()
|
|
|
|
let crc_implementations = Consistbl.create ()
|
2003-06-27 01:49:22 -07:00
|
|
|
let extra_implementations = ref ([] : string list)
|
|
|
|
let implementations_defined = ref ([] : (string * string) list)
|
2006-10-17 05:33:58 -07:00
|
|
|
let cmx_required = ref ([] : string list)
|
1995-07-02 09:41:48 -07:00
|
|
|
|
|
|
|
let check_consistency file_name unit crc =
|
2002-11-17 08:42:12 -08:00
|
|
|
begin try
|
|
|
|
List.iter
|
|
|
|
(fun (name, crc) ->
|
|
|
|
if name = unit.ui_name
|
|
|
|
then Consistbl.set crc_interfaces name crc file_name
|
|
|
|
else Consistbl.check crc_interfaces name crc file_name)
|
|
|
|
unit.ui_imports_cmi
|
|
|
|
with Consistbl.Inconsistency(name, user, auth) ->
|
|
|
|
raise(Error(Inconsistent_interface(name, user, auth)))
|
|
|
|
end;
|
|
|
|
begin try
|
|
|
|
List.iter
|
|
|
|
(fun (name, crc) ->
|
2006-10-17 05:33:58 -07:00
|
|
|
if crc <> cmx_not_found_crc then
|
|
|
|
Consistbl.check crc_implementations name crc file_name
|
|
|
|
else if List.mem name !cmx_required then
|
|
|
|
raise(Error(Missing_cmx(file_name, name)))
|
2002-12-02 06:50:08 -08:00
|
|
|
else
|
2006-10-17 05:33:58 -07:00
|
|
|
extra_implementations := name :: !extra_implementations)
|
2002-11-17 08:42:12 -08:00
|
|
|
unit.ui_imports_cmx
|
|
|
|
with Consistbl.Inconsistency(name, user, auth) ->
|
2002-11-18 02:41:51 -08:00
|
|
|
raise(Error(Inconsistent_implementation(name, user, auth)))
|
|
|
|
end;
|
|
|
|
begin try
|
2003-06-27 01:49:22 -07:00
|
|
|
let source = List.assoc unit.ui_name !implementations_defined in
|
2002-11-18 02:41:51 -08:00
|
|
|
raise (Error(Multiple_definition(unit.ui_name, file_name, source)))
|
|
|
|
with Not_found -> ()
|
2002-11-17 08:42:12 -08:00
|
|
|
end;
|
2003-06-27 01:49:22 -07:00
|
|
|
Consistbl.set crc_implementations unit.ui_name crc file_name;
|
2007-11-08 10:03:15 -08:00
|
|
|
implementations_defined :=
|
2006-10-17 05:33:58 -07:00
|
|
|
(unit.ui_name, file_name) :: !implementations_defined;
|
|
|
|
if unit.ui_symbol <> unit.ui_name then
|
|
|
|
cmx_required := unit.ui_name :: !cmx_required
|
2002-11-17 08:42:12 -08:00
|
|
|
|
|
|
|
let extract_crc_interfaces () =
|
|
|
|
Consistbl.extract crc_interfaces
|
2007-11-08 10:03:15 -08:00
|
|
|
let extract_crc_implementations () =
|
2002-12-02 06:50:08 -08:00
|
|
|
List.fold_left
|
|
|
|
(fun ncl n ->
|
|
|
|
if List.mem_assoc n ncl then ncl else (n, cmx_not_found_crc) :: ncl)
|
|
|
|
(Consistbl.extract crc_implementations)
|
|
|
|
!extra_implementations
|
2002-02-08 08:55:44 -08:00
|
|
|
|
2000-03-09 01:12:28 -08:00
|
|
|
(* Add C objects and options and "custom" info from a library descriptor.
|
|
|
|
See bytecomp/bytelink.ml for comments on the order of C objects. *)
|
|
|
|
|
|
|
|
let lib_ccobjs = ref []
|
|
|
|
let lib_ccopts = ref []
|
|
|
|
|
|
|
|
let add_ccobjs l =
|
|
|
|
if not !Clflags.no_auto_link then begin
|
|
|
|
lib_ccobjs := l.lib_ccobjs @ !lib_ccobjs;
|
|
|
|
lib_ccopts := l.lib_ccopts @ !lib_ccopts
|
|
|
|
end
|
|
|
|
|
2007-11-08 10:03:15 -08:00
|
|
|
let runtime_lib () =
|
2007-11-06 07:16:56 -08:00
|
|
|
let libname =
|
|
|
|
if !Clflags.gprofile
|
|
|
|
then "libasmrunp" ^ ext_lib
|
2011-03-17 09:18:05 -07:00
|
|
|
else "libasmrun" ^ !Clflags.runtime_variant ^ ext_lib in
|
2007-11-06 07:16:56 -08:00
|
|
|
try
|
2007-11-15 08:09:57 -08:00
|
|
|
if !Clflags.nopervasives then []
|
|
|
|
else [ find_in_path !load_path libname ]
|
2007-11-06 07:16:56 -08:00
|
|
|
with Not_found ->
|
|
|
|
raise(Error(File_not_found libname))
|
|
|
|
|
|
|
|
let object_file_name name =
|
|
|
|
let file_name =
|
|
|
|
try
|
|
|
|
find_in_path !load_path name
|
|
|
|
with Not_found ->
|
|
|
|
fatal_error "Asmlink.object_file_name: not found" in
|
|
|
|
if Filename.check_suffix file_name ".cmx" then
|
|
|
|
Filename.chop_suffix file_name ".cmx" ^ ext_obj
|
|
|
|
else if Filename.check_suffix file_name ".cmxa" then
|
|
|
|
Filename.chop_suffix file_name ".cmxa" ^ ext_lib
|
|
|
|
else
|
|
|
|
fatal_error "Asmlink.object_file_name: bad ext"
|
|
|
|
|
1995-07-02 09:41:48 -07:00
|
|
|
(* First pass: determine which units are needed *)
|
|
|
|
|
2000-04-10 08:01:30 -07:00
|
|
|
let missing_globals = (Hashtbl.create 17 : (string, string list ref) Hashtbl.t)
|
1995-07-02 09:41:48 -07:00
|
|
|
|
|
|
|
let is_required name =
|
2000-04-10 08:01:30 -07:00
|
|
|
try ignore (Hashtbl.find missing_globals name); true
|
|
|
|
with Not_found -> false
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2000-04-10 08:01:30 -07:00
|
|
|
let add_required by (name, crc) =
|
|
|
|
try
|
|
|
|
let rq = Hashtbl.find missing_globals name in
|
|
|
|
rq := by :: !rq
|
|
|
|
with Not_found ->
|
|
|
|
Hashtbl.add missing_globals name (ref [by])
|
1995-07-02 09:41:48 -07:00
|
|
|
|
|
|
|
let remove_required name =
|
2000-04-10 08:01:30 -07:00
|
|
|
Hashtbl.remove missing_globals name
|
|
|
|
|
|
|
|
let extract_missing_globals () =
|
|
|
|
let mg = ref [] in
|
|
|
|
Hashtbl.iter (fun md rq -> mg := (md, !rq) :: !mg) missing_globals;
|
|
|
|
!mg
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2007-11-08 10:03:15 -08:00
|
|
|
type file =
|
2010-05-19 04:29:38 -07:00
|
|
|
| Unit of string * unit_infos * Digest.t
|
|
|
|
| Library of string * library_infos
|
2007-11-06 07:16:56 -08:00
|
|
|
|
|
|
|
let read_file obj_name =
|
1995-07-02 09:41:48 -07:00
|
|
|
let file_name =
|
|
|
|
try
|
|
|
|
find_in_path !load_path obj_name
|
|
|
|
with Not_found ->
|
|
|
|
raise(Error(File_not_found obj_name)) in
|
1995-07-11 11:03:29 -07:00
|
|
|
if Filename.check_suffix file_name ".cmx" then begin
|
|
|
|
(* This is a .cmx file. It must be linked in any case.
|
|
|
|
Read the infos to see which modules it requires. *)
|
2010-05-19 04:29:38 -07:00
|
|
|
let (info, crc) = read_unit_info file_name in
|
2007-11-06 07:16:56 -08:00
|
|
|
Unit (file_name,info,crc)
|
1995-07-11 11:03:29 -07:00
|
|
|
end
|
|
|
|
else if Filename.check_suffix file_name ".cmxa" then begin
|
2007-11-08 10:03:15 -08:00
|
|
|
let infos =
|
2010-05-19 04:29:38 -07:00
|
|
|
try read_library_info file_name
|
2007-11-06 07:16:56 -08:00
|
|
|
with Compilenv.Error(Not_a_unit_info _) ->
|
2008-01-11 08:13:18 -08:00
|
|
|
raise(Error(Not_an_object_file file_name))
|
2007-11-06 07:16:56 -08:00
|
|
|
in
|
|
|
|
Library (file_name,infos)
|
1995-07-11 11:03:29 -07:00
|
|
|
end
|
|
|
|
else raise(Error(Not_an_object_file file_name))
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2007-11-06 07:16:56 -08:00
|
|
|
let scan_file obj_name tolink = match read_file obj_name with
|
|
|
|
| Unit (file_name,info,crc) ->
|
2008-01-31 01:13:19 -08:00
|
|
|
(* This is a .cmx file. It must be linked in any case. *)
|
2007-11-06 07:16:56 -08:00
|
|
|
remove_required info.ui_name;
|
|
|
|
List.iter (add_required file_name) info.ui_imports_cmx;
|
|
|
|
(info, file_name, crc) :: tolink
|
|
|
|
| Library (file_name,infos) ->
|
|
|
|
(* This is an archive file. Each unit contained in it will be linked
|
2008-01-11 08:13:18 -08:00
|
|
|
in only if needed. *)
|
2007-11-06 07:16:56 -08:00
|
|
|
add_ccobjs infos;
|
|
|
|
List.fold_right
|
2008-01-11 08:13:18 -08:00
|
|
|
(fun (info, crc) reqd ->
|
2007-11-06 07:16:56 -08:00
|
|
|
if info.ui_force_link
|
|
|
|
|| !Clflags.link_everything
|
|
|
|
|| is_required info.ui_name
|
|
|
|
then begin
|
|
|
|
remove_required info.ui_name;
|
|
|
|
List.iter (add_required (Printf.sprintf "%s(%s)"
|
|
|
|
file_name info.ui_name))
|
|
|
|
info.ui_imports_cmx;
|
|
|
|
(info, file_name, crc) :: reqd
|
|
|
|
end else
|
|
|
|
reqd)
|
2008-01-11 08:13:18 -08:00
|
|
|
infos.lib_units tolink
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2007-11-06 07:16:56 -08:00
|
|
|
(* Second pass: generate the startup file and link it with everything else *)
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2012-01-20 06:23:34 -08:00
|
|
|
let make_startup_file ppf filename units_list =
|
|
|
|
let compile_phrase p = Asmgen.compile_phrase ppf p in
|
1995-07-02 09:41:48 -07:00
|
|
|
let oc = open_out filename in
|
|
|
|
Emitaux.output_channel := oc;
|
2004-01-03 04:51:20 -08:00
|
|
|
Location.input_name := "caml_startup"; (* set name of "current" input *)
|
2004-01-04 06:32:34 -08:00
|
|
|
Compilenv.reset "_startup"; (* set the name of the "current" compunit *)
|
1995-07-02 09:41:48 -07:00
|
|
|
Emit.begin_assembly();
|
2002-02-08 08:55:44 -08:00
|
|
|
let name_list =
|
|
|
|
List.flatten (List.map (fun (info,_,_) -> info.ui_defines) units_list) in
|
2000-04-21 01:13:22 -07:00
|
|
|
compile_phrase (Cmmgen.entry_point name_list);
|
2007-11-06 07:16:56 -08:00
|
|
|
let units = List.map (fun (info,_,_) -> info) units_list in
|
|
|
|
List.iter compile_phrase (Cmmgen.generic_functions false units);
|
1995-07-18 01:40:44 -07:00
|
|
|
Array.iter
|
2000-04-21 01:13:22 -07:00
|
|
|
(fun name -> compile_phrase (Cmmgen.predef_exception name))
|
1995-07-18 01:40:44 -07:00
|
|
|
Runtimedef.builtin_exceptions;
|
2000-04-21 01:13:22 -07:00
|
|
|
compile_phrase (Cmmgen.global_table name_list);
|
|
|
|
compile_phrase
|
1998-11-20 07:35:04 -08:00
|
|
|
(Cmmgen.globals_map
|
2007-11-06 07:16:56 -08:00
|
|
|
(List.map
|
|
|
|
(fun (unit,_,crc) ->
|
2007-11-08 10:03:15 -08:00
|
|
|
try (unit.ui_name, List.assoc unit.ui_name unit.ui_imports_cmi,
|
2008-01-11 08:13:18 -08:00
|
|
|
crc,
|
|
|
|
unit.ui_defines)
|
2007-11-06 07:16:56 -08:00
|
|
|
with Not_found -> assert false)
|
|
|
|
units_list));
|
2004-01-04 06:32:34 -08:00
|
|
|
compile_phrase(Cmmgen.data_segment_table ("_startup" :: name_list));
|
|
|
|
compile_phrase(Cmmgen.code_segment_table ("_startup" :: name_list));
|
2000-04-21 01:13:22 -07:00
|
|
|
compile_phrase
|
2004-01-04 06:32:34 -08:00
|
|
|
(Cmmgen.frame_table("_startup" :: "_system" :: name_list));
|
2007-11-06 07:16:56 -08:00
|
|
|
|
1995-07-02 09:41:48 -07:00
|
|
|
Emit.end_assembly();
|
|
|
|
close_out oc
|
|
|
|
|
2012-01-20 06:23:34 -08:00
|
|
|
let make_shared_startup_file ppf units filename =
|
|
|
|
let compile_phrase p = Asmgen.compile_phrase ppf p in
|
2007-11-06 07:16:56 -08:00
|
|
|
let oc = open_out filename in
|
|
|
|
Emitaux.output_channel := oc;
|
|
|
|
Location.input_name := "caml_startup";
|
2007-11-08 10:03:15 -08:00
|
|
|
Compilenv.reset "_shared_startup";
|
2007-11-06 07:16:56 -08:00
|
|
|
Emit.begin_assembly();
|
2007-11-08 10:03:15 -08:00
|
|
|
List.iter compile_phrase
|
2007-11-06 07:16:56 -08:00
|
|
|
(Cmmgen.generic_functions true (List.map fst units));
|
|
|
|
compile_phrase (Cmmgen.plugin_header units);
|
|
|
|
compile_phrase
|
2007-11-08 10:03:15 -08:00
|
|
|
(Cmmgen.global_table
|
2010-05-19 04:29:38 -07:00
|
|
|
(List.map (fun (ui,_) -> ui.ui_symbol) units));
|
2007-11-06 07:16:56 -08:00
|
|
|
(* this is to force a reference to all units, otherwise the linker
|
|
|
|
might drop some of them (in case of libraries) *)
|
|
|
|
|
|
|
|
Emit.end_assembly();
|
|
|
|
close_out oc
|
|
|
|
|
|
|
|
|
|
|
|
let call_linker_shared file_list output_name =
|
2007-11-15 05:21:15 -08:00
|
|
|
if not (Ccomp.call_linker Ccomp.Dll output_name file_list "")
|
|
|
|
then raise(Error Linking_error)
|
2007-11-06 07:16:56 -08:00
|
|
|
|
2012-01-20 06:23:34 -08:00
|
|
|
let link_shared ppf objfiles output_name =
|
2007-11-06 07:16:56 -08:00
|
|
|
let units_tolink = List.fold_right scan_file objfiles [] in
|
|
|
|
List.iter
|
|
|
|
(fun (info, file_name, crc) -> check_consistency file_name info crc)
|
|
|
|
units_tolink;
|
|
|
|
Clflags.ccobjs := !Clflags.ccobjs @ !lib_ccobjs;
|
2013-06-05 09:34:40 -07:00
|
|
|
Clflags.all_ccopts := !lib_ccopts @ !Clflags.all_ccopts;
|
2007-11-08 10:03:15 -08:00
|
|
|
let objfiles = List.rev (List.map object_file_name objfiles) @
|
2011-07-20 02:17:07 -07:00
|
|
|
(List.rev !Clflags.ccobjs) in
|
2007-11-06 07:16:56 -08:00
|
|
|
|
|
|
|
let startup =
|
|
|
|
if !Clflags.keep_startup_file
|
|
|
|
then output_name ^ ".startup" ^ ext_asm
|
|
|
|
else Filename.temp_file "camlstartup" ext_asm in
|
2012-01-20 06:23:34 -08:00
|
|
|
make_shared_startup_file ppf
|
2007-11-06 07:16:56 -08:00
|
|
|
(List.map (fun (ui,_,crc) -> (ui,crc)) units_tolink) startup;
|
|
|
|
let startup_obj = output_name ^ ".startup" ^ ext_obj in
|
|
|
|
if Proc.assemble_file startup startup_obj <> 0
|
|
|
|
then raise(Error(Assembler_error startup));
|
|
|
|
if not !Clflags.keep_startup_file then remove_file startup;
|
|
|
|
call_linker_shared (startup_obj :: objfiles) output_name;
|
|
|
|
remove_file startup_obj
|
|
|
|
|
2002-06-11 07:15:12 -07:00
|
|
|
let call_linker file_list startup_file output_name =
|
2008-01-11 08:13:18 -08:00
|
|
|
let main_dll = !Clflags.output_c_object
|
|
|
|
&& Filename.check_suffix output_name Config.ext_dll
|
|
|
|
in
|
2007-11-15 08:09:57 -08:00
|
|
|
let files = startup_file :: (List.rev file_list) in
|
|
|
|
let files, c_lib =
|
|
|
|
if (not !Clflags.output_c_object) || main_dll then
|
|
|
|
files @ (List.rev !Clflags.ccobjs) @ runtime_lib (),
|
|
|
|
(if !Clflags.nopervasives then "" else Config.native_c_libraries)
|
|
|
|
else
|
|
|
|
files, ""
|
|
|
|
in
|
|
|
|
let mode =
|
|
|
|
if main_dll then Ccomp.MainDll
|
|
|
|
else if !Clflags.output_c_object then Ccomp.Partial
|
|
|
|
else Ccomp.Exe
|
|
|
|
in
|
|
|
|
if not (Ccomp.call_linker mode output_name files c_lib)
|
|
|
|
then raise(Error Linking_error)
|
1995-07-02 09:41:48 -07:00
|
|
|
|
|
|
|
(* Main entry point *)
|
|
|
|
|
2012-01-20 06:23:34 -08:00
|
|
|
let link ppf objfiles output_name =
|
2001-11-27 05:47:13 -08:00
|
|
|
let stdlib =
|
|
|
|
if !Clflags.gprofile then "stdlib.p.cmxa" else "stdlib.cmxa" in
|
|
|
|
let stdexit =
|
|
|
|
if !Clflags.gprofile then "std_exit.p.cmx" else "std_exit.cmx" in
|
1998-08-06 06:27:38 -07:00
|
|
|
let objfiles =
|
2001-11-27 05:47:13 -08:00
|
|
|
if !Clflags.nopervasives then objfiles
|
|
|
|
else if !Clflags.output_c_object then stdlib :: objfiles
|
|
|
|
else stdlib :: (objfiles @ [stdexit]) in
|
1995-11-06 03:04:55 -08:00
|
|
|
let units_tolink = List.fold_right scan_file objfiles [] in
|
1995-11-09 05:21:49 -08:00
|
|
|
Array.iter remove_required Runtimedef.builtin_exceptions;
|
2000-04-10 08:01:30 -07:00
|
|
|
begin match extract_missing_globals() with
|
|
|
|
[] -> ()
|
|
|
|
| mg -> raise(Error(Missing_implementations mg))
|
|
|
|
end;
|
2001-11-29 01:55:06 -08:00
|
|
|
List.iter
|
|
|
|
(fun (info, file_name, crc) -> check_consistency file_name info crc)
|
|
|
|
units_tolink;
|
2000-03-09 01:12:28 -08:00
|
|
|
Clflags.ccobjs := !Clflags.ccobjs @ !lib_ccobjs;
|
2013-09-04 08:12:37 -07:00
|
|
|
Clflags.all_ccopts := !lib_ccopts @ !Clflags.all_ccopts;
|
|
|
|
(* put user's opts first *)
|
2007-11-08 10:03:15 -08:00
|
|
|
let startup =
|
2007-11-06 07:16:56 -08:00
|
|
|
if !Clflags.keep_startup_file then output_name ^ ".startup" ^ ext_asm
|
|
|
|
else Filename.temp_file "camlstartup" ext_asm in
|
2012-01-20 06:23:34 -08:00
|
|
|
make_startup_file ppf startup units_tolink;
|
1996-02-15 08:19:09 -08:00
|
|
|
let startup_obj = Filename.temp_file "camlstartup" ext_obj in
|
1995-07-02 09:41:48 -07:00
|
|
|
if Proc.assemble_file startup startup_obj <> 0 then
|
|
|
|
raise(Error(Assembler_error startup));
|
|
|
|
try
|
2002-06-11 07:15:12 -07:00
|
|
|
call_linker (List.map object_file_name objfiles) startup_obj output_name;
|
1995-07-10 02:48:27 -07:00
|
|
|
if not !Clflags.keep_startup_file then remove_file startup;
|
1995-07-02 09:41:48 -07:00
|
|
|
remove_file startup_obj
|
|
|
|
with x ->
|
|
|
|
remove_file startup_obj;
|
|
|
|
raise x
|
|
|
|
|
|
|
|
(* Error report *)
|
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
open Format
|
1995-07-02 09:41:48 -07:00
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
let report_error ppf = function
|
|
|
|
| File_not_found name ->
|
|
|
|
fprintf ppf "Cannot find file %s" name
|
1995-07-02 09:41:48 -07:00
|
|
|
| Not_an_object_file name ->
|
2012-03-07 09:40:17 -08:00
|
|
|
fprintf ppf "The file %a is not a compilation unit description"
|
|
|
|
Location.print_filename name
|
1995-07-11 11:03:29 -07:00
|
|
|
| Missing_implementations l ->
|
2000-04-21 01:13:22 -07:00
|
|
|
let print_references ppf = function
|
|
|
|
| [] -> ()
|
|
|
|
| r1 :: rl ->
|
|
|
|
fprintf ppf "%s" r1;
|
|
|
|
List.iter (fun r -> fprintf ppf ",@ %s" r) rl in
|
|
|
|
let print_modules ppf =
|
|
|
|
List.iter
|
|
|
|
(fun (md, rq) ->
|
|
|
|
fprintf ppf "@ @[<hov 2>%s referenced from %a@]" md
|
|
|
|
print_references rq) in
|
|
|
|
fprintf ppf
|
|
|
|
"@[<v 2>No implementations provided for the following modules:%a@]"
|
|
|
|
print_modules l
|
1995-07-02 09:41:48 -07:00
|
|
|
| Inconsistent_interface(intf, file1, file2) ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf
|
2012-03-07 09:40:17 -08:00
|
|
|
"@[<hov>Files %a@ and %a@ make inconsistent assumptions \
|
2000-02-08 12:00:06 -08:00
|
|
|
over interface %s@]"
|
2012-03-07 09:40:17 -08:00
|
|
|
Location.print_filename file1
|
|
|
|
Location.print_filename file2
|
|
|
|
intf
|
1995-07-02 09:41:48 -07:00
|
|
|
| Inconsistent_implementation(intf, file1, file2) ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf
|
2012-03-07 09:40:17 -08:00
|
|
|
"@[<hov>Files %a@ and %a@ make inconsistent assumptions \
|
2000-02-08 12:00:06 -08:00
|
|
|
over implementation %s@]"
|
2012-03-07 09:40:17 -08:00
|
|
|
Location.print_filename file1
|
|
|
|
Location.print_filename file2
|
|
|
|
intf
|
1995-07-02 09:41:48 -07:00
|
|
|
| Assembler_error file ->
|
2012-03-07 09:40:17 -08:00
|
|
|
fprintf ppf "Error while assembling %a" Location.print_filename file
|
1995-07-02 09:41:48 -07:00
|
|
|
| Linking_error ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf "Error during linking"
|
2002-01-04 07:57:19 -08:00
|
|
|
| Multiple_definition(modname, file1, file2) ->
|
|
|
|
fprintf ppf
|
2012-03-07 09:40:17 -08:00
|
|
|
"@[<hov>Files %a@ and %a@ both define a module named %s@]"
|
|
|
|
Location.print_filename file1
|
|
|
|
Location.print_filename file2
|
|
|
|
modname
|
2006-10-17 05:33:58 -07:00
|
|
|
| Missing_cmx(filename, name) ->
|
|
|
|
fprintf ppf
|
2012-03-07 09:40:17 -08:00
|
|
|
"@[<hov>File %a@ was compiled without access@ \
|
2006-10-17 05:33:58 -07:00
|
|
|
to the .cmx file@ for module %s,@ \
|
|
|
|
which was produced by `ocamlopt -for-pack'.@ \
|
2012-03-07 09:40:17 -08:00
|
|
|
Please recompile %a@ with the correct `-I' option@ \
|
2006-10-17 05:33:58 -07:00
|
|
|
so that %s.cmx@ is found.@]"
|
2012-03-07 09:40:17 -08:00
|
|
|
Location.print_filename filename name
|
|
|
|
Location.print_filename filename
|
|
|
|
name
|
2013-09-12 08:50:47 -07:00
|
|
|
|
|
|
|
let () =
|
|
|
|
Location.register_error_of_exn
|
|
|
|
(function
|
|
|
|
| Error err -> Some (Location.error_of_printer_file report_error err)
|
|
|
|
| _ -> None
|
|
|
|
)
|