Skip to content

Commit

Permalink
refactor: delay flags/prog in fdo rules (#9171)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg authored Nov 14, 2023
1 parent 34a67ff commit 159db03
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/dune_rules/fdo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let ocamlfdo_binary sctx dir =
~loc:None
"ocamlfdo"
~hint:"opam install ocamlfdo"
|> Action_builder.of_memo
;;

(* FDO flags are context dependent. *)
Expand Down Expand Up @@ -126,19 +127,18 @@ let opt_rule cctx m =
; As [ "-md5-unit"; "-reorder-blocks"; "opt"; "-q" ]
]
in
let open Memo.O in
let* ocamlfdo_binary = ocamlfdo_binary sctx dir
and* ocamlfdo_flags = ocamlfdo_flags ctx in
let ocamlfdo_binary = ocamlfdo_binary sctx dir in
let ocamlfdo_flags = ocamlfdo_flags ctx |> Action_builder.of_memo in
Super_context.add_rule
sctx
~dir
(Command.run
(Command.run_dyn_prog
~dir:(Path.build dir)
ocamlfdo_binary
[ A "opt"
; Hidden_targets [ linear_fdo ]
; Dep (Path.build linear)
; As ocamlfdo_flags
; Command.Args.dyn ocamlfdo_flags
; Dyn flags
])
;;
Expand All @@ -164,21 +164,23 @@ module Linker_script = struct
| None -> As []
in
let open Memo.O in
let* ocamlfdo_binary = ocamlfdo_binary sctx dir
and* ocamlfdo_linker_script_flags = ocamlfdo_linker_script_flags ctx in
let ocamlfdo_binary = ocamlfdo_binary sctx dir in
let ocamlfdo_linker_script_flags =
Action_builder.of_memo @@ ocamlfdo_linker_script_flags ctx
in
let+ () =
Super_context.add_rule
sctx
~dir
(Command.run
(Command.run_dyn_prog
~dir:(Path.build (Context.build_dir ctx))
ocamlfdo_binary
[ A "linker-script"
; A "-o"
; Target linker_script_path
; Dyn flags
; A "-q"
; As ocamlfdo_linker_script_flags
; Command.Args.dyn ocamlfdo_linker_script_flags
])
in
linker_script
Expand Down

0 comments on commit 159db03

Please sign in to comment.