@@ -54,15 +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- (if write_shape
59- then
60- match output_file with
61- | `Stdout -> ()
62- | `Name name ->
63- Shape.Store. save'
64- (Filename. remove_extension name ^ Shape.Store. ext)
65- (StringMap. bindings shapes));
57+ let sm = f ~standalone ~shapes: write_shape ~source_map (k, fmt) in
6658 match source_map, sm with
6759 | None , _ | _ , None -> ()
6860 | Some { output_file = output ; source_map; keep_empty } , Some sm ->
@@ -140,11 +132,6 @@ let sourcemap_of_infos ~base l =
140132
141133let sourcemap_of_info ~base info = sourcemap_of_infos ~base [ info ]
142134
143- let map_fst f (x , y ) = f x, y
144-
145- let merge_shape a b =
146- StringMap. union (fun _name s1 s2 -> if Shape. equal s1 s2 then Some s1 else None ) a b
147-
148135let run
149136 { Cmd_arg. common
150137 ; profile
@@ -170,7 +157,6 @@ let run
170157 ; include_runtime
171158 ; effects
172159 ; shape_files
173- ; write_shape
174160 } =
175161 let source_map_base =
176162 Option. map ~f: (fun spec -> spec.Source_map.Encoding_spec. source_map) source_map
@@ -273,7 +259,7 @@ let run
273259 output_file =
274260 if check_sourcemap then check_debug one;
275261 let init_pseudo_fs = fs_external && standalone in
276- let sm =
262+ let sm, shapes =
277263 match output_file with
278264 | `Stdout , formatter ->
279265 let instr =
@@ -326,6 +312,7 @@ let run
326312 Driver. f' ~standalone ~link: `Needed ?profile ~wrap_with_fun pfs_fmt code));
327313 res
328314 in
315+ StringMap. iter (fun name shape -> Shape.Store. set ~name shape) shapes;
329316 if times () then Format. eprintf " compilation: %a@." Timer. print t;
330317 sm
331318 in
@@ -398,7 +385,7 @@ let run
398385 { code; cmis = StringSet. empty; debug = Parse_bytecode.Debug. default_summary }
399386 in
400387 output_gen
401- ~write_shape
388+ ~write_shape: false
402389 ~standalone: true
403390 ~custom_header
404391 ~build_info: (Build_info. create `Runtime )
@@ -415,7 +402,7 @@ let run
415402 ~shapes
416403 ~link: `All
417404 output_file
418- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
405+ |> sourcemap_of_info ~base: source_map_base)
419406 | (`Stdin | `File _ ) as bytecode ->
420407 let kind, ic, close_ic, include_dirs =
421408 match bytecode with
@@ -448,7 +435,7 @@ let run
448435 in
449436 if times () then Format. eprintf " parsing: %a@." Timer. print t1;
450437 output_gen
451- ~write_shape
438+ ~write_shape: false
452439 ~standalone: true
453440 ~custom_header
454441 ~build_info: (Build_info. create `Exe )
@@ -463,7 +450,7 @@ let run
463450 ~source_map
464451 ~link: (if linkall then `All else `Needed )
465452 output_file
466- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
453+ |> sourcemap_of_info ~base: source_map_base)
467454 | `Cmo cmo ->
468455 let output_file =
469456 match output_file, keep_unit_names with
@@ -488,7 +475,7 @@ let run
488475 in
489476 if times () then Format. eprintf " parsing: %a@." Timer. print t1;
490477 output_gen
491- ~write_shape
478+ ~write_shape: true
492479 ~standalone: false
493480 ~custom_header
494481 ~build_info: (Build_info. create `Cmo )
@@ -497,17 +484,16 @@ let run
497484 (fun ~standalone ~shapes ~source_map output ->
498485 match include_runtime with
499486 | true ->
500- let sm1, sh1 =
487+ let sm1 =
501488 output_partial_runtime ~standalone ~shapes ~source_map output
502489 in
503- let sm2, sh2 =
490+ let sm2 =
504491 output_partial cmo code ~standalone ~shapes ~source_map output
505492 in
506- ( sourcemap_of_infos ~base: source_map_base [ sm1; sm2 ]
507- , merge_shape sh1 sh2 )
493+ sourcemap_of_infos ~base: source_map_base [ sm1; sm2 ]
508494 | false ->
509495 output_partial cmo code ~standalone ~shapes ~source_map output
510- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
496+ |> sourcemap_of_info ~base: source_map_base)
511497 | `Cma cma when keep_unit_names ->
512498 (if include_runtime
513499 then
@@ -523,15 +509,15 @@ let run
523509 failwith " use [-o dirname/] or remove [--keep-unit-names]"
524510 in
525511 output_gen
526- ~write_shape
512+ ~write_shape: false
527513 ~standalone: false
528514 ~custom_header
529515 ~build_info: (Build_info. create `Runtime )
530516 ~source_map
531517 (`Name output_file)
532518 (fun ~standalone ~shapes ~source_map output ->
533519 output_partial_runtime ~standalone ~shapes ~source_map output
534- |> map_fst ( sourcemap_of_info ~base: source_map_base) ));
520+ |> sourcemap_of_info ~base: source_map_base));
535521 List. iter cma.lib_units ~f: (fun cmo ->
536522 let output_file =
537523 match output_file with
@@ -560,15 +546,15 @@ let run
560546 t1
561547 (Ocaml_compiler.Cmo_format. name cmo);
562548 output_gen
563- ~write_shape
549+ ~write_shape: true
564550 ~standalone: false
565551 ~custom_header
566552 ~build_info: (Build_info. create `Cma )
567553 ~source_map
568554 (`Name output_file)
569555 (fun ~standalone ~shapes ~source_map output ->
570556 output_partial ~standalone ~shapes ~source_map cmo code output
571- |> map_fst ( sourcemap_of_info ~base: source_map_base) ))
557+ |> sourcemap_of_info ~base: source_map_base))
572558 | `Cma cma ->
573559 let f ~standalone ~shapes ~source_map output =
574560 (* Always compute shapes because it can be used by other units of the cma *)
@@ -599,20 +585,15 @@ let run
599585 (Ocaml_compiler.Cmo_format. name cmo);
600586 output_partial ~standalone ~shapes ~source_map cmo code output)
601587 in
602- let sm_and_shapes =
588+ let sm =
603589 match runtime with
604590 | None -> units
605591 | Some x -> x :: units
606592 in
607- let shapes =
608- List. fold_left sm_and_shapes ~init: StringMap. empty ~f: (fun acc (_ , s ) ->
609- merge_shape s acc)
610- in
611- ( sourcemap_of_infos ~base: source_map_base (List. map sm_and_shapes ~f: fst)
612- , shapes )
593+ sourcemap_of_infos ~base: source_map_base sm
613594 in
614595 output_gen
615- ~write_shape
596+ ~write_shape: true
616597 ~standalone: false
617598 ~custom_header
618599 ~build_info: (Build_info. create `Cma )
0 commit comments