Skip to content

Commit

Permalink
No config flags in :standard. Always prepend to cc.
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysse Gérard <[email protected]>
  • Loading branch information
voodoos committed Jun 30, 2020
1 parent dbd4b78 commit c6ca2db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/dune/foreign_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,18 @@ let build_c_or_cxx_file ~language ~sctx ~dir ~expander ~include_flags
let flags =
let ctx_flags =
match language with
| Foreign.Language.C -> Fdo.c_flags ctx
| Foreign.Language.C ->
let cfg = ctx.ocaml_config in
List.concat
[ Ocaml_config.ocamlc_cflags cfg
; Ocaml_config.ocamlc_cppflags cfg
; Fdo.c_flags ctx
]
| Foreign.Language.Cxx -> Fdo.cxx_flags ctx
in
let flags = Foreign.Source.flags src in
Super_context.foreign_flags sctx ~dir ~expander ~flags ~language
|> Build.map ~f:(List.append ctx_flags)
|> Build.map ~f:List.(rev_append (rev ctx_flags))
in
let output_param =
match ctx.lib_config.ccomp_type with
Expand Down
11 changes: 9 additions & 2 deletions src/dune/super_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ open! Stdune
open Import

let default_context_flags (ctx : Context.t) =
let c = Ocaml_config.ocamlc_cflags ctx.ocaml_config in
(* TODO (v3) Current flag behavior is different when calling the C compiler or
the C++ compiler: 1.[ocamlc_cflags] and [ocamlc_cppflags] are always
prenpended to the C compiler arguments to reproduce [ocamlc]'s behavior, 2.
[ocamlc_cflags] are present in [:standard] and prepended to the C++
compiler arguments only if the user didn't redefined them (or used
[:standard] to extend them) *)
let c = [] in
let cxx =
List.filter c ~f:(fun s -> not (String.is_prefix s ~prefix:"-std="))
Ocaml_config.ocamlc_cflags ctx.ocaml_config
|> List.filter ~f:(fun s -> not (String.is_prefix s ~prefix:"-std="))
in
Foreign.Language.Dict.make ~c ~cxx

Expand Down

0 comments on commit c6ca2db

Please sign in to comment.