@@ -54,15 +54,7 @@ let output_gen
54
54
Driver. configure fmt;
55
55
if standalone then header ~custom_header fmt;
56
56
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
66
58
match source_map, sm with
67
59
| None , _ | _ , None -> ()
68
60
| Some { output_file = output ; source_map; keep_empty } , Some sm ->
@@ -140,11 +132,6 @@ let sourcemap_of_infos ~base l =
140
132
141
133
let sourcemap_of_info ~base info = sourcemap_of_infos ~base [ info ]
142
134
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
-
148
135
let run
149
136
{ Cmd_arg. common
150
137
; profile
@@ -170,7 +157,6 @@ let run
170
157
; include_runtime
171
158
; effects
172
159
; shape_files
173
- ; write_shape
174
160
} =
175
161
let source_map_base =
176
162
Option. map ~f: (fun spec -> spec.Source_map.Encoding_spec. source_map) source_map
@@ -273,7 +259,7 @@ let run
273
259
output_file =
274
260
if check_sourcemap then check_debug one;
275
261
let init_pseudo_fs = fs_external && standalone in
276
- let sm =
262
+ let sm, shapes =
277
263
match output_file with
278
264
| `Stdout , formatter ->
279
265
let instr =
@@ -326,6 +312,7 @@ let run
326
312
Driver. f' ~standalone ~link: `Needed ?profile ~wrap_with_fun pfs_fmt code));
327
313
res
328
314
in
315
+ StringMap. iter (fun name shape -> Shape.Store. set ~name shape) shapes;
329
316
if times () then Format. eprintf " compilation: %a@." Timer. print t;
330
317
sm
331
318
in
@@ -398,7 +385,7 @@ let run
398
385
{ code; cmis = StringSet. empty; debug = Parse_bytecode.Debug. default_summary }
399
386
in
400
387
output_gen
401
- ~write_shape
388
+ ~write_shape: false
402
389
~standalone: true
403
390
~custom_header
404
391
~build_info: (Build_info. create `Runtime )
@@ -415,7 +402,7 @@ let run
415
402
~shapes
416
403
~link: `All
417
404
output_file
418
- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
405
+ |> sourcemap_of_info ~base: source_map_base)
419
406
| (`Stdin | `File _ ) as bytecode ->
420
407
let kind, ic, close_ic, include_dirs =
421
408
match bytecode with
@@ -448,7 +435,7 @@ let run
448
435
in
449
436
if times () then Format. eprintf " parsing: %a@." Timer. print t1;
450
437
output_gen
451
- ~write_shape
438
+ ~write_shape: false
452
439
~standalone: true
453
440
~custom_header
454
441
~build_info: (Build_info. create `Exe )
@@ -463,7 +450,7 @@ let run
463
450
~source_map
464
451
~link: (if linkall then `All else `Needed )
465
452
output_file
466
- |> map_fst ( sourcemap_of_info ~base: source_map_base) )
453
+ |> sourcemap_of_info ~base: source_map_base)
467
454
| `Cmo cmo ->
468
455
let output_file =
469
456
match output_file, keep_unit_names with
@@ -488,7 +475,7 @@ let run
488
475
in
489
476
if times () then Format. eprintf " parsing: %a@." Timer. print t1;
490
477
output_gen
491
- ~write_shape
478
+ ~write_shape: true
492
479
~standalone: false
493
480
~custom_header
494
481
~build_info: (Build_info. create `Cmo )
@@ -497,17 +484,16 @@ let run
497
484
(fun ~standalone ~shapes ~source_map output ->
498
485
match include_runtime with
499
486
| true ->
500
- let sm1, sh1 =
487
+ let sm1 =
501
488
output_partial_runtime ~standalone ~shapes ~source_map output
502
489
in
503
- let sm2, sh2 =
490
+ let sm2 =
504
491
output_partial cmo code ~standalone ~shapes ~source_map output
505
492
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 ]
508
494
| false ->
509
495
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)
511
497
| `Cma cma when keep_unit_names ->
512
498
(if include_runtime
513
499
then
@@ -523,15 +509,15 @@ let run
523
509
failwith " use [-o dirname/] or remove [--keep-unit-names]"
524
510
in
525
511
output_gen
526
- ~write_shape
512
+ ~write_shape: false
527
513
~standalone: false
528
514
~custom_header
529
515
~build_info: (Build_info. create `Runtime )
530
516
~source_map
531
517
(`Name output_file)
532
518
(fun ~standalone ~shapes ~source_map output ->
533
519
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));
535
521
List. iter cma.lib_units ~f: (fun cmo ->
536
522
let output_file =
537
523
match output_file with
@@ -560,15 +546,15 @@ let run
560
546
t1
561
547
(Ocaml_compiler.Cmo_format. name cmo);
562
548
output_gen
563
- ~write_shape
549
+ ~write_shape: true
564
550
~standalone: false
565
551
~custom_header
566
552
~build_info: (Build_info. create `Cma )
567
553
~source_map
568
554
(`Name output_file)
569
555
(fun ~standalone ~shapes ~source_map output ->
570
556
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))
572
558
| `Cma cma ->
573
559
let f ~standalone ~shapes ~source_map output =
574
560
(* Always compute shapes because it can be used by other units of the cma *)
@@ -599,20 +585,15 @@ let run
599
585
(Ocaml_compiler.Cmo_format. name cmo);
600
586
output_partial ~standalone ~shapes ~source_map cmo code output)
601
587
in
602
- let sm_and_shapes =
588
+ let sm =
603
589
match runtime with
604
590
| None -> units
605
591
| Some x -> x :: units
606
592
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
613
594
in
614
595
output_gen
615
- ~write_shape
596
+ ~write_shape: true
616
597
~standalone: false
617
598
~custom_header
618
599
~build_info: (Build_info. create `Cma )
0 commit comments