From 7ec081419c2cf5d108ca1e4f8bf8b9475e4b5438 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Mon, 5 Jun 2017 11:40:27 +0100 Subject: [PATCH] Don't pass -g to cl; it doesn't like it! (#120) The Microsoft C compiler doesn't recognise -g. For now, easier just not to compile with any debugging information on MSVC. Signed-off-by: David Allsopp --- src/context.ml | 6 ++++++ src/context.mli | 3 +++ src/gen_rules.ml | 4 ++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/context.ml b/src/context.ml index 5bfcf7b0..043c6762 100644 --- a/src/context.ml +++ b/src/context.ml @@ -459,3 +459,9 @@ let best_mode t : Mode.t = match t.ocamlopt with | Some _ -> Native | None -> Byte + +let cc_g (ctx : t) = + if !Clflags.g && ctx.ccomp_type <> "msvc" then + ["-g"] + else + [] diff --git a/src/context.mli b/src/context.mli index 102b9d03..0602bbc2 100644 --- a/src/context.mli +++ b/src/context.mli @@ -154,3 +154,6 @@ val compiler : t -> Mode.t -> Path.t option (** The best compilation mode for this context *) val best_mode : t -> Mode.t + +(** [\["-g"\]] if [!Clflags.g] and [\[\]] otherwise *) +val cc_g : t -> string list diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 64beb1a4..637f0d6e 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -100,7 +100,7 @@ module Gen(P : Params) = struct (Build.paths h_files >>> Build.fanout - (SC.expand_and_eval_set ~dir lib.c_flags ~standard:(Utils.g ())) + (SC.expand_and_eval_set ~dir lib.c_flags ~standard:(Context.cc_g ctx)) requires >>> Build.run ~context:ctx @@ -125,7 +125,7 @@ module Gen(P : Params) = struct (Build.paths h_files >>> Build.fanout - (SC.expand_and_eval_set ~dir lib.cxx_flags ~standard:(Utils.g ())) + (SC.expand_and_eval_set ~dir lib.cxx_flags ~standard:(Context.cc_g ctx)) requires >>> Build.run ~context:ctx