Skip to content

Commit

Permalink
refactor: do not pass [default_cxx_link_flags] (ocaml#8279)
Browse files Browse the repository at this point in the history
It's the same for every node

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored and Philip White committed Aug 10, 2023
1 parent ab1975c commit 0ab223a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
13 changes: 9 additions & 4 deletions src/dune_rules/env_node.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ let expand_str_lazy expander sw =
let* expander = Memo.Lazy.force expander in
Expander.No_deps.expand_str expander sw

let make ~dir ~inherit_from ~scope ~config_stanza ~profile ~expander
~expander_for_artifacts ~default_context_flags ~default_env
~default_bin_artifacts ~default_cxx_link_flags ~default_bin_annot =
let make build_context ~dir ~inherit_from ~scope ~config_stanza ~profile
~expander ~expander_for_artifacts ~default_context_flags ~default_env
~default_bin_artifacts ~default_bin_annot =
let open Memo.O in
let config = Dune_env.Stanza.find config_stanza ~profile in
let inherited ~field ~root extend =
Expand Down Expand Up @@ -170,7 +170,12 @@ let make ~dir ~inherit_from ~scope ~config_stanza ~profile ~expander
Foreign_language.Dict.make ~c:(foreign_flags C) ~cxx:(foreign_flags Cxx)
in
let link_flags =
let default_link_flags = Link_flags.default ~default_cxx_link_flags in
let default_link_flags =
let default_cxx_link_flags =
Cxx_flags.get_flags ~for_:Link build_context
in
Link_flags.default ~default_cxx_link_flags
in
inherited ~field:link_flags ~root:default_link_flags (fun link_flags ->
let+ expander = Memo.Lazy.force expander in
Link_flags.make ~spec:config.link_flags ~default:link_flags
Expand Down
4 changes: 2 additions & 2 deletions src/dune_rules/env_node.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ end
type t

val make :
dir:Path.Build.t
Build_context.t
-> dir:Path.Build.t
-> inherit_from:t Memo.Lazy.t option
-> scope:Scope.t
-> config_stanza:Dune_env.Stanza.t
Expand All @@ -27,7 +28,6 @@ val make :
-> default_context_flags:string list Action_builder.t Foreign_language.Dict.t
-> default_env:Env.t
-> default_bin_artifacts:Artifacts.Bin.t
-> default_cxx_link_flags:string list Action_builder.t
-> default_bin_annot:bool
-> t

Expand Down
23 changes: 8 additions & 15 deletions src/dune_rules/super_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,10 @@ end = struct
extend_expander t ~dir ~expander_for_artifacts
>>| Expander.set_dir ~dir)
in
let default_cxx_link_flags =
Cxx_flags.get_flags ~for_:Link t.context.build_context
in
Env_node.make ~dir ~scope ~config_stanza ~inherit_from:(Some inherit_from)
~profile:t.context.profile ~expander ~expander_for_artifacts
~default_context_flags ~default_env:t.context_env
~default_bin_artifacts:t.bin_artifacts ~default_cxx_link_flags
~default_bin_annot:true
Env_node.make t.context.build_context ~dir ~scope ~config_stanza
~inherit_from:(Some inherit_from) ~profile:t.context.profile ~expander
~expander_for_artifacts ~default_context_flags ~default_env:t.context_env
~default_bin_artifacts:t.bin_artifacts ~default_bin_annot:true

(* Here we jump through some hoops to construct [t] as well as create a
memoization table that has access to [t] and is used in [t.get_node].
Expand Down Expand Up @@ -504,16 +500,13 @@ let create ~(context : Context.t) ~host ~packages ~stanzas =
in
let profile = context.profile in
Dune_env.Stanza.fire_hooks config_stanza ~profile;
let default_cxx_link_flags =
Cxx_flags.get_flags ~for_:Link context.build_context
in
let expander =
Memo.Lazy.of_val (Expander.set_dir ~dir root_expander)
in
Env_node.make ~dir ~scope ~inherit_from ~config_stanza ~profile
~expander ~expander_for_artifacts ~default_context_flags
~default_env:context_env ~default_bin_artifacts:artifacts.bin
~default_cxx_link_flags ~default_bin_annot:true
Env_node.make context.build_context ~dir ~scope ~inherit_from
~config_stanza ~profile ~expander ~expander_for_artifacts
~default_context_flags ~default_env:context_env
~default_bin_artifacts:artifacts.bin ~default_bin_annot:true
in
make ~config_stanza:context.env_nodes.context
~inherit_from:
Expand Down

0 comments on commit 0ab223a

Please sign in to comment.