@@ -793,14 +793,12 @@ module Persistent_signature = {
793793 };
794794
795795 let load =
796- ref ((~loc= Location . dummy_loc, unit_name) => {
797- switch (Module_resolution . locate_object_file(~loc, unit_name)) {
798- | filename =>
799- let ret = {filename, cmi: Module_resolution . read_file_cmi(filename)};
800- Some (ret);
801- | exception Not_found => None
796+ ref (obj_filename =>
797+ {
798+ filename: obj_filename,
799+ cmi: Module_resolution . read_file_cmi(obj_filename),
802800 }
803- } );
801+ );
804802};
805803
806804let acknowledge_pers_struct = (check, {Persistent_signature . filename, cmi}) => {
@@ -846,24 +844,21 @@ let acknowledge_pers_struct = (check, {Persistent_signature.filename, cmi}) => {
846844 ps;
847845};
848846
849- let find_pers_struct = (~loc, check, filepath) => {
850- switch (Hashtbl . find(persistent_structures, filepath)) {
851- | Some (ps ) => ps
847+ let find_pers_struct = (~loc, check, src_filepath) => {
848+ let obj_filepath = Module_resolution . locate_object_file(~loc, src_filepath);
849+
850+ switch (Hashtbl . find(persistent_structures, obj_filepath)) {
851+ | Some (ps ) =>
852+ add_import(src_filepath);
853+ ps;
852854 | None => raise (Not_found )
853855 | exception Not_found =>
854856 switch (can_load_modules^ ) {
855857 | Cannot_load_modules (_ ) => raise (Not_found )
856858 | Can_load_modules =>
857- let ps = {
858- switch (Persistent_signature . load^ (~loc, filepath)) {
859- | Some (ps ) => ps
860- | None =>
861- Hashtbl . add(persistent_structures, filepath, None );
862- raise (Not_found );
863- };
864- };
859+ let ps = Persistent_signature . load^ (obj_filepath);
865860
866- add_import(filepath );
861+ add_import(src_filepath );
867862 acknowledge_pers_struct(check, ps);
868863 }
869864 };
@@ -873,62 +868,8 @@ let load_pers_struct = (~loc, filepath) => {
873868 find_pers_struct(~loc, false , filepath).ps_name;
874869};
875870
876- /* Emits a warning if there is no valid cmi for name */
877- let check_pers_struct = (~loc, name, filename) =>
878- try (ignore (find_pers_struct(~loc, false , filename))) {
879- | Not_found =>
880- let err = No_module_file (name, None );
881- error(err);
882- | Cmi_format . Error (err ) =>
883- let msg = Format . asprintf("% a " , Cmi_format . report_error, err);
884- let err = No_module_file (name, Some (msg));
885- error(err);
886- | Error (err ) =>
887- let msg =
888- switch (err) {
889- | Illegal_renaming (name , ps_name , filename ) =>
890- Format . asprintf(
891- " % a @ contains the compiled interface for @ % s when % s was expected" ,
892- Location . print_filename,
893- filename,
894- ps_name,
895- name,
896- )
897- | Inconsistent_import (_ ) => assert (false )
898- | Depend_on_unsafe_string_unit (name , _ ) =>
899- Printf . sprintf("% s uses -unsafe-string" , name)
900- | Unbound_label (_ ) => assert (false )
901- | Unbound_label_with_alt (_ ) => assert (false )
902- | Unbound_module (_ ) => assert (false )
903- | Missing_module (_ ) => assert (false )
904- | No_module_file (_ ) => assert (false )
905- | Value_not_found_in_module (_ ) => assert (false )
906- | Module_not_found_in_module (_ ) => assert (false )
907- | Type_not_found_in_module (_ ) => assert (false )
908- | Exception_not_found_in_module (_ ) => assert (false )
909- | Illegal_value_name (_ ) => assert (false )
910- | Cyclic_dependencies (_ ) => assert (false )
911- };
912-
913- let err = No_module_file (name, Some (msg));
914- error(err);
915- };
916-
917871let find_pers_struct = filename => find_pers_struct(true , filename);
918872
919- let check_pers_struct = (~loc, name, filename) =>
920- if (! Hashtbl . mem(persistent_structures, filename)) {
921- /* PR#6843: record the weak dependency ([add_import]) regardless of
922- whether the check succeeds, to help make builds more
923- deterministic. */
924- add_import(filename);
925- if (Warnings . is_active(Warnings . NoCmiFile ("" , None ))) {
926- add_delayed_check_forward^ (() =>
927- check_pers_struct(~loc, name, filename)
928- );
929- };
930- };
931-
932873let rec find_module_descr = (path, filename, env) => {
933874 switch (path) {
934875 | PIdent (id ) =>
@@ -2245,16 +2186,7 @@ let crc_of_unit = filename => {
22452186
22462187let imports = () => {
22472188 let imported_units = StringSet . elements(imported_units^ );
2248- let resolved_units =
2249- List . map(
2250- unit => Module_resolution . locate_unit_object_file(unit),
2251- imported_units,
2252- );
2253- List . map2(
2254- (unit, resolved_unit) => (unit, crc_of_unit(resolved_unit)),
2255- imported_units,
2256- resolved_units,
2257- );
2189+ List . map(unit => (unit, crc_of_unit(unit)), imported_units);
22582190};
22592191
22602192/* Build a module signature */
@@ -2269,7 +2201,7 @@ let build_signature_with_imports =
22692201 let flags = [] ;
22702202 let crc = Cmi_format . build_crc(~name= modname, sg);
22712203
2272- let cmi = {
2204+ {
22732205 cmi_name: modname,
22742206 cmi_sign: sg,
22752207 cmi_crcs: imports,
@@ -2278,30 +2210,33 @@ let build_signature_with_imports =
22782210 cmi_type_metadata: type_metadata,
22792211 cmi_config_sum: Cmi_format . config_sum() ,
22802212 };
2213+ };
22812214
2215+ let add_cmi_to_persistent_structures = (filename, cmi) => {
22822216 let comps =
22832217 components_of_module(
2284- ~deprecated,
2218+ ~deprecated= None ,
22852219 ~loc= Location . dummy_loc,
22862220 empty,
22872221 Subst . identity,
2288- PIdent (Ident . create_persistent(modname )),
2289- TModSignature (sg ),
2222+ PIdent (Ident . create_persistent(cmi . cmi_name )),
2223+ TModSignature (cmi . cmi_sign ),
22902224 );
22912225
22922226 let ps = {
2293- ps_name: modname ,
2294- ps_sig: lazy (Subst . signature(Subst . identity, sg )),
2227+ ps_name: cmi . cmi_name ,
2228+ ps_sig: lazy (Subst . signature(Subst . identity, cmi . cmi_sign )),
22952229 ps_comps: comps,
22962230 ps_crcs: cmi. cmi_crcs,
22972231 ps_crc: cmi. cmi_crc,
2298- ps_filename: Module_resolution . get_object_name(filename),
2232+ ps_filename:
2233+ Module_resolution . get_object_name(
2234+ Filepath . to_string(Filepath . String . derelativize(filename)),
2235+ ),
22992236 ps_flags: cmi. cmi_flags,
23002237 };
23012238
23022239 save_pers_struct(ps);
2303-
2304- cmi;
23052240};
23062241
23072242let build_signature = (~deprecated=?, sg, modname, filename, type_metadata) =>
0 commit comments