Merge pull request #9991 from lpw25/reproducible-no-alias-deps

Fix reproducibility for `-no-alias-deps`
master
Leo White 2020-11-22 18:22:48 +00:00 committed by GitHub
commit d0ddf25f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 12 deletions

View File

@ -31,6 +31,9 @@ Working version
### Bug fixes: ### Bug fixes:
- #9991: Fix reproducibility for `-no-alias-deps`
(Leo White, review by Gabriel Scherer and Florian Angeletti)
- #10005: Try expanding aliases in Ctype.nondep_type_rec - #10005: Try expanding aliases in Ctype.nondep_type_rec
(Stephen Dolan, review by Gabriel Scherer, Leo White and Xavier Leroy) (Stephen Dolan, review by Gabriel Scherer, Leo White and Xavier Leroy)

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 =
{ {