@@ -54,8 +54,7 @@ let output_gen
5454 Driver. configure fmt;
5555 if standalone then header ~custom_header fmt;
5656 if Config.Flag. header () then jsoo_header fmt build_info;
57- let sm, shapes = f ~standalone ~shapes: write_shape ~source_map (k, fmt) in
58- StringMap. iter (fun name shape -> Shape.Store. set ~name shape) shapes;
57+ let sm = f ~standalone ~shapes: write_shape ~source_map (k, fmt) in
5958 match source_map, sm with
6059 | None , _ | _ , None -> ()
6160 | Some { output_file = output ; source_map; keep_empty } , Some sm ->
@@ -133,11 +132,6 @@ let sourcemap_of_infos ~base l =
133132
134133let sourcemap_of_info ~base info = sourcemap_of_infos ~base [ info ]
135134
136- let map_fst f (x , y ) = f x, y
137-
138- let merge_shape a b =
139- StringMap. union (fun _name s1 s2 -> if Shape. equal s1 s2 then Some s1 else None ) a b
140-
141135let run
142136 { Cmd_arg. common
143137 ; profile
@@ -265,7 +259,7 @@ let run
265259 output_file =
266260 if check_sourcemap then check_debug one;
267261 let init_pseudo_fs = fs_external && standalone in
268- let sm =
262+ let sm, shapes =
269263 match output_file with
270264 | `Stdout , formatter ->
271265 let instr =
@@ -318,6 +312,7 @@ let run
318312 Driver. f' ~standalone ~link: `Needed ?profile ~wrap_with_fun pfs_fmt code));
319313 res
320314 in
315+ StringMap. iter (fun name shape -> Shape.Store. set ~name shape) shapes;
321316 if times () then Format. eprintf " compilation: %a@." Timer. print t;
322317 sm
323318 in
@@ -407,7 +402,7 @@ let run
407402 ~shapes
408403 ~link: `All
409404 output_file
410- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
405+ |> sourcemap_of_info ~base: source_map_base)
411406 | (`Stdin | `File _ ) as bytecode ->
412407 let kind, ic, close_ic, include_dirs =
413408 match bytecode with
@@ -455,7 +450,7 @@ let run
455450 ~source_map
456451 ~link: (if linkall then `All else `Needed )
457452 output_file
458- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
453+ |> sourcemap_of_info ~base: source_map_base)
459454 | `Cmo cmo ->
460455 let output_file =
461456 match output_file, keep_unit_names with
@@ -489,17 +484,16 @@ let run
489484 (fun ~standalone ~shapes ~source_map output ->
490485 match include_runtime with
491486 | true ->
492- let sm1, sh1 =
487+ let sm1 =
493488 output_partial_runtime ~standalone ~shapes ~source_map output
494489 in
495- let sm2, sh2 =
490+ let sm2 =
496491 output_partial cmo code ~standalone ~shapes ~source_map output
497492 in
498- ( sourcemap_of_infos ~base: source_map_base [ sm1; sm2 ]
499- , merge_shape sh1 sh2 )
493+ sourcemap_of_infos ~base: source_map_base [ sm1; sm2 ]
500494 | false ->
501495 output_partial cmo code ~standalone ~shapes ~source_map output
502- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
496+ |> sourcemap_of_info ~base: source_map_base)
503497 | `Cma cma when keep_unit_names ->
504498 (if include_runtime
505499 then
@@ -523,7 +517,7 @@ let run
523517 (`Name output_file)
524518 (fun ~standalone ~shapes ~source_map output ->
525519 output_partial_runtime ~standalone ~shapes ~source_map output
526- |> map_fst ( sourcemap_of_info ~base: source_map_base) ));
520+ |> sourcemap_of_info ~base: source_map_base));
527521 List. iter cma.lib_units ~f: (fun cmo ->
528522 let output_file =
529523 match output_file with
@@ -560,7 +554,7 @@ let run
560554 (`Name output_file)
561555 (fun ~standalone ~shapes ~source_map output ->
562556 output_partial ~standalone ~shapes ~source_map cmo code output
563- |> map_fst ( sourcemap_of_info ~base: source_map_base) ))
557+ |> sourcemap_of_info ~base: source_map_base))
564558 | `Cma cma ->
565559 let f ~standalone ~shapes ~source_map output =
566560 (* Always compute shapes because it can be used by other units of the cma *)
@@ -591,17 +585,12 @@ let run
591585 (Ocaml_compiler.Cmo_format. name cmo);
592586 output_partial ~standalone ~shapes ~source_map cmo code output)
593587 in
594- let sm_and_shapes =
588+ let sm =
595589 match runtime with
596590 | None -> units
597591 | Some x -> x :: units
598592 in
599- let shapes =
600- List. fold_left sm_and_shapes ~init: StringMap. empty ~f: (fun acc (_ , s ) ->
601- merge_shape s acc)
602- in
603- ( sourcemap_of_infos ~base: source_map_base (List. map sm_and_shapes ~f: fst)
604- , shapes )
593+ sourcemap_of_infos ~base: source_map_base sm
605594 in
606595 output_gen
607596 ~write_shape: true
0 commit comments