Fix reproducibility for `-no-alias-deps`

master
Leo White 2020-10-26 12:39:43 +00:00
parent 1abdcac1d7
commit e7dbaeb8ce
2 changed files with 28 additions and 12 deletions

View File

@ -4,7 +4,7 @@
** ocamlc.byte ** ocamlc.byte
compile_only = "true" compile_only = "true"
module = "cmis_on_file_system.ml" module = "cmis_on_file_system.ml"
flags="-bin-annot" flags="-bin-annot -no-alias-deps -w '-49'"
*** script *** script
script= "mv cmis_on_file_system.cmt lone.cmt" script= "mv cmis_on_file_system.cmt lone.cmt"
**** ocamlc.byte **** ocamlc.byte
@ -12,7 +12,7 @@
compile_only="true" compile_only="true"
***** ocamlc.byte ***** ocamlc.byte
compile_only = "true" compile_only = "true"
flags="-bin-annot" flags="-bin-annot -no-alias-deps -w '-49'"
module="cmis_on_file_system.ml" module="cmis_on_file_system.ml"
****** compare-binary-files ****** compare-binary-files
program="cmis_on_file_system.cmt" program="cmis_on_file_system.cmt"
@ -24,3 +24,5 @@
at a given point in time *) at a given point in time *)
type t = int type t = int
let () = () let () = ()
module M = Cmis_on_file_system_companion

View File

@ -707,20 +707,34 @@ let find_name_module ~mark name tbl =
let add_persistent_structure id env = let add_persistent_structure id env =
if not (Ident.persistent id) then invalid_arg "Env.add_persistent_structure"; if not (Ident.persistent id) then invalid_arg "Env.add_persistent_structure";
if not (Current_unit_name.is_ident id) then if Current_unit_name.is_ident id then env
let summary = else begin
let material =
(* This addition only observably changes the environment if it shadows a
non-persistent module already in the environment.
(See PR#9345) *)
match match
IdTbl.find_name wrap_module ~mark:false (Ident.name id) env.modules IdTbl.find_name wrap_module ~mark:false (Ident.name id) env.modules
with with
| exception Not_found | _, Mod_persistent -> env.summary | exception Not_found | _, Mod_persistent -> false
| _ -> Env_persistent (env.summary, id) | _ -> true
in in
{ env with let summary =
modules = IdTbl.add id Mod_persistent env.modules; if material then Env_persistent (env.summary, id)
summary else env.summary
} in
else let modules =
env (* With [-no-alias-deps], non-material additions should not
affect the environment at all. We should only observe the
existence of a cmi when accessing components of the module.
(See #9991). *)
if material || not !Clflags.transparent_modules then
IdTbl.add id Mod_persistent env.modules
else
env.modules
in
{ env with modules; summary }
end
let components_of_module ~alerts ~uid env fs ps path addr mty = let components_of_module ~alerts ~uid env fs ps path addr mty =
{ {