summaryrefslogtreecommitdiff
path: root/utils/ccomp.ml
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2020-09-11 13:43:53 +0100
committerDavid Allsopp <david.allsopp@metastack.com>2020-09-21 10:11:39 +0100
commit14300d3b1a992a51760da7489aae8784782d09f6 (patch)
tree19a915715f01f3cc3c31fbb361eb63bec058e1c6 /utils/ccomp.ml
parentfed86fb598d87943fd0ae71c15bbe8ba4f7b9959 (diff)
downloadocaml-14300d3b1a992a51760da7489aae8784782d09f6.tar.gz
Fix -fdebug-prefix-map when using flexlink
Prepend the -fdebug-prefix-map= option with -link if the "linker" is in fact flexlink.
Diffstat (limited to 'utils/ccomp.ml')
-rw-r--r--utils/ccomp.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils/ccomp.ml b/utils/ccomp.ml
index 429273a038..1986299ca5 100644
--- a/utils/ccomp.ml
+++ b/utils/ccomp.ml
@@ -206,3 +206,25 @@ let call_linker mode output_name files extra =
in
command cmd
)
+
+let linker_is_flexlink =
+ let command =
+ String.trim @@ Option.value !Clflags.c_compiler ~default:Config.mkexe in
+ if String.length command < 2 then false else
+ (* Get the first "word" of command *)
+ let full_path =
+ (* This is not comprehensive, but should be good enough for Windows *)
+ if command.[0] = '"' then
+ match String.index_from command 1 '"' with
+ | idx -> String.sub command 1 (idx - 1)
+ | exception Not_found -> String.sub command 1 (String.length command - 1)
+ else
+ match String.index_from command 1 ' ' with
+ | idx -> String.sub command 0 idx
+ | exception Not_found -> command
+ in
+ let prog =
+ let prog = Filename.basename full_path in
+ Option.value ~default:prog @@ Filename.chop_suffix_opt prog ~suffix:".exe"
+ in
+ String.lowercase_ascii prog = "flexlink"