diff --git a/Changes b/Changes index 84e8cabed..f982cc980 100644 --- a/Changes +++ b/Changes @@ -534,6 +534,10 @@ Working version - #9927: Restore Cygwin64 support. (David Allsopp, review by Xavier Leroy) +- #9940: Fix unboxing of allocated constants from other compilation units + (Vincent Laviron, report by Stephen Dolan, review by Xavier Leroy and + Stephen Dolan) + OCaml 4.11.1 ------------ diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml index bda1ee982..77d29951c 100644 --- a/asmcomp/cmmgen.ml +++ b/asmcomp/cmmgen.ml @@ -178,7 +178,10 @@ let rec expr_size env = function let transl_constant dbg = function | Uconst_int n -> int_const dbg n - | Uconst_ref (label, _) -> + | Uconst_ref (label, def_opt) -> + Option.iter + (fun def -> Cmmgen_state.add_structured_constant label def) + def_opt; Cconst_symbol (label, dbg) let emit_constant cst cont = diff --git a/asmcomp/cmmgen_state.ml b/asmcomp/cmmgen_state.ml index 595aba4d9..9d6622352 100644 --- a/asmcomp/cmmgen_state.ml +++ b/asmcomp/cmmgen_state.ml @@ -76,6 +76,9 @@ let set_structured_constants l = ) l +let add_structured_constant sym cst = + Hashtbl.replace state.structured_constants sym cst + let get_structured_constant s = Hashtbl.find_opt state.structured_constants s diff --git a/asmcomp/cmmgen_state.mli b/asmcomp/cmmgen_state.mli index 306f55d5c..f10073924 100644 --- a/asmcomp/cmmgen_state.mli +++ b/asmcomp/cmmgen_state.mli @@ -41,5 +41,7 @@ val no_more_functions : unit -> bool val set_structured_constants : Clambda.preallocated_constant list -> unit +val add_structured_constant : string -> Clambda.ustructured_constant -> unit + (* Also looks up using Compilenv.structured_constant_of_symbol *) val structured_constant_of_sym : string -> Clambda.ustructured_constant option