diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2006-10-17 12:33:58 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2006-10-17 12:33:58 +0000 |
commit | 5901580fe95106dfd49d9e25ff53fff578db8eb6 (patch) | |
tree | 422a2e224014a8fcb2b3ba22070cdedab3238a4f | |
parent | f2027274dd75aedfa30a60ec7c68331bd6759854 (diff) | |
download | ocaml-5901580fe95106dfd49d9e25ff53fff578db8eb6.tar.gz |
Better handling of .cmx files in combination with -for-pack (PR#4124)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7693 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | asmcomp/asmlink.ml | 22 | ||||
-rw-r--r-- | asmcomp/asmlink.mli | 1 | ||||
-rw-r--r-- | asmcomp/asmpackager.ml | 1 | ||||
-rw-r--r-- | asmcomp/compilenv.ml | 3 | ||||
-rw-r--r-- | asmcomp/compilenv.mli | 4 |
5 files changed, 27 insertions, 4 deletions
diff --git a/asmcomp/asmlink.ml b/asmcomp/asmlink.ml index f0b297c9a8..0b79aa3983 100644 --- a/asmcomp/asmlink.ml +++ b/asmcomp/asmlink.ml @@ -28,6 +28,7 @@ type error = | Assembler_error of string | Linking_error | Multiple_definition of string * string * string + | Missing_cmx of string * string exception Error of error @@ -37,6 +38,7 @@ let crc_interfaces = Consistbl.create () let crc_implementations = Consistbl.create () let extra_implementations = ref ([] : string list) let implementations_defined = ref ([] : (string * string) list) +let cmx_required = ref ([] : string list) let check_consistency file_name unit crc = begin try @@ -52,10 +54,12 @@ let check_consistency file_name unit crc = begin try List.iter (fun (name, crc) -> - if crc = cmx_not_found_crc then - extra_implementations := name :: !extra_implementations + 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))) else - Consistbl.check crc_implementations name crc file_name) + extra_implementations := name :: !extra_implementations) unit.ui_imports_cmx with Consistbl.Inconsistency(name, user, auth) -> raise(Error(Inconsistent_implementation(name, user, auth))) @@ -67,7 +71,9 @@ let check_consistency file_name unit crc = end; Consistbl.set crc_implementations unit.ui_name crc file_name; implementations_defined := - (unit.ui_name, file_name) :: !implementations_defined + (unit.ui_name, file_name) :: !implementations_defined; + if unit.ui_symbol <> unit.ui_name then + cmx_required := unit.ui_name :: !cmx_required let extract_crc_interfaces () = Consistbl.extract crc_interfaces @@ -370,3 +376,11 @@ let report_error ppf = function fprintf ppf "@[<hov>Files %s@ and %s@ both define a module named %s@]" file1 file2 modname + | Missing_cmx(filename, name) -> + fprintf ppf + "@[<hov>File %s@ was compiled without access@ \ + to the .cmx file@ for module %s,@ \ + which was produced by `ocamlopt -for-pack'.@ \ + Please recompile %s@ with the correct `-I' option@ \ + so that %s.cmx@ is found.@]" + filename name filename name diff --git a/asmcomp/asmlink.mli b/asmcomp/asmlink.mli index 9ae9f9ead6..28c5287daf 100644 --- a/asmcomp/asmlink.mli +++ b/asmcomp/asmlink.mli @@ -31,6 +31,7 @@ type error = | Assembler_error of string | Linking_error | Multiple_definition of string * string * string + | Missing_cmx of string * string exception Error of error diff --git a/asmcomp/asmpackager.ml b/asmcomp/asmpackager.ml index abc8b5b051..87f26e0a8d 100644 --- a/asmcomp/asmpackager.ml +++ b/asmcomp/asmpackager.ml @@ -53,6 +53,7 @@ let read_member_info pack_path file = (Compilenv.current_unit_infos()).ui_symbol ^ "__" ^ info.ui_name then raise(Error(Wrong_for_pack(file, pack_path))); Asmlink.check_consistency file info crc; + Compilenv.cache_unit_info info; PM_impl info end else PM_intf in diff --git a/asmcomp/compilenv.ml b/asmcomp/compilenv.ml index 85c12d2662..9f4288821c 100644 --- a/asmcomp/compilenv.ml +++ b/asmcomp/compilenv.ml @@ -155,6 +155,9 @@ let get_global_info global_ident = infos end +let cache_unit_info ui = + Hashtbl.add global_infos_table ui.ui_name (Some ui) + (* Return the approximation of a global identifier *) let global_approx id = diff --git a/asmcomp/compilenv.mli b/asmcomp/compilenv.mli index 42136060f6..3b547872a1 100644 --- a/asmcomp/compilenv.mli +++ b/asmcomp/compilenv.mli @@ -83,6 +83,10 @@ val write_unit_info: unit_infos -> string -> unit (* Save the given infos in the given file *) val save_unit_info: string -> unit (* Save the infos for the current unit in the given file *) +val cache_unit_info: unit_infos -> unit + (* Enter the given infos in the cache. The infos will be + honored by [symbol_for_global] and [global_approx] + without looking at the corresponding .cmx file. *) val cmx_not_found_crc: Digest.t (* Special digest used in the [ui_imports_cmx] list to signal |