diff --git a/Changes b/Changes index a6df83cea..d7ab9fbd1 100644 --- a/Changes +++ b/Changes @@ -481,6 +481,10 @@ Working version (Xavier Leroy, report by Alain Frisch, review by Nicolás Ojeda Bär and Alain Frisch) +- #9925: Correct passing -fdebug-prefix-map to flexlink on Cygwin by prefixing + it with -link. + (David Allsopp, review by ???) + OCaml 4.11.1 ------------ diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml index b8c874b23..6660fee46 100644 --- a/bytecomp/bytelink.ml +++ b/bytecomp/bytelink.ml @@ -573,7 +573,13 @@ let build_custom_runtime prim_name exec_name = else "-lcamlrun" ^ !Clflags.runtime_variant in let debug_prefix_map = if Config.c_has_debug_prefix_map && not !Clflags.keep_camlprimc_file then - [Printf.sprintf "-fdebug-prefix-map=%s=camlprim.c" prim_name] + let flag = + [Printf.sprintf "-fdebug-prefix-map=%s=camlprim.c" prim_name] + in + if Ccomp.linker_is_flexlink then + "-link" :: flag + else + flag else [] in let exitcode = diff --git a/utils/ccomp.ml b/utils/ccomp.ml index 429273a03..22b60a8b9 100644 --- a/utils/ccomp.ml +++ b/utils/ccomp.ml @@ -206,3 +206,9 @@ let call_linker mode output_name files extra = in command cmd ) + +let linker_is_flexlink = + (* Config.mkexe, Config.mkdll and Config.mkmaindll are all flexlink + invocations for the native Windows ports and for Cygwin, if shared library + support is enabled. *) + Sys.win32 || Config.supports_shared_libraries && Sys.cygwin diff --git a/utils/ccomp.mli b/utils/ccomp.mli index 89724252b..fb520e2a4 100644 --- a/utils/ccomp.mli +++ b/utils/ccomp.mli @@ -37,3 +37,5 @@ type link_mode = | Partial val call_linker: link_mode -> string -> string list -> string -> int + +val linker_is_flexlink : bool