@@ -346,6 +346,11 @@ let check_fdo_support has_native ocfg ~name =
346
346
version_string
347
347
]
348
348
349
+ type instance =
350
+ { native : t
351
+ ; targets : t list
352
+ }
353
+
349
354
let create ~(kind : Kind.t ) ~path ~env ~env_nodes ~name ~merlin ~targets
350
355
~host_context ~host_toolchain ~profile ~fdo_target_exe
351
356
~dynamically_linked_foreign_archives ~instrument_with =
@@ -680,7 +685,7 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
680
685
~findlib_toolchain: (Some findlib_toolchain)
681
686
>> | Option. some)
682
687
in
683
- native :: List. filter_opt others
688
+ { native; targets = List. filter_opt others }
684
689
685
690
let which t fname = Program. which ~path: t.path fname
686
691
@@ -735,9 +740,9 @@ let create_for_opam ~loc ~root ~env ~env_nodes ~targets ~profile ~switch ~name
735
740
~instrument_with
736
741
737
742
module rec Instantiate : sig
738
- val instantiate : Context_name .t -> t list Memo .t
743
+ val instantiate : Context_name .t -> instance Memo .t
739
744
end = struct
740
- let instantiate_impl name : t list Memo.t =
745
+ let instantiate_impl name : instance Memo.t =
741
746
let env = Global. env () in
742
747
let * workspace = Workspace. workspace () in
743
748
let context =
@@ -747,13 +752,9 @@ end = struct
747
752
let * host_context =
748
753
match Workspace.Context. host_context context with
749
754
| None -> Memo. return None
750
- | Some context_name -> (
751
- let + contexts = Instantiate. instantiate context_name in
752
- match contexts with
753
- | [ x ] -> Some x
754
- | [] -> assert false (* checked by workspace *)
755
- | _ :: _ -> assert false )
756
- (* target cannot be host *)
755
+ | Some context_name ->
756
+ let + { native; targets = _ } = Instantiate. instantiate context_name in
757
+ Some native
757
758
in
758
759
let env_nodes =
759
760
let context = Workspace.Context. env context in
@@ -826,7 +827,10 @@ module DB = struct
826
827
let * workspace = Workspace. workspace () in
827
828
let + contexts =
828
829
Memo. parallel_map workspace.contexts ~f: (fun c ->
829
- Instantiate. instantiate (Workspace.Context. name c))
830
+ let + { native; targets } =
831
+ Instantiate. instantiate (Workspace.Context. name c)
832
+ in
833
+ native :: targets)
830
834
in
831
835
let all = List. concat contexts in
832
836
List. iter all ~f: (fun t ->
0 commit comments