summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2008-10-15 08:48:51 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2008-10-15 08:48:51 +0000
commit46e80874df7661e079163cccb9c912e1f3f48df4 (patch)
treed067decf00deab43ddcf78d8021adefed8eaf888
parent8e0ac797ea5d8332588ba48709772a9c089346c4 (diff)
downloadocaml-46e80874df7661e079163cccb9c912e1f3f48df4.tar.gz
PR#4621: honor -cc flag when linking
git-svn-id: http://caml.inria.fr/svn/ocaml/version/3.11@9084 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--driver/main.ml2
-rw-r--r--driver/optmain.ml3
-rw-r--r--utils/ccomp.ml18
-rw-r--r--utils/clflags.ml2
-rw-r--r--utils/clflags.mli2
5 files changed, 16 insertions, 11 deletions
diff --git a/driver/main.ml b/driver/main.ml
index d7e11a0d64..eb79f4779a 100644
--- a/driver/main.ml
+++ b/driver/main.ml
@@ -91,7 +91,7 @@ module Options = Main_args.Make_options (struct
let _a = set make_archive
let _annot = set annotations
let _c = set compile_only
- let _cc s = c_compiler := s
+ let _cc s = c_compiler := Some s
let _cclib s = ccobjs := Misc.rev_split_words s @ !ccobjs
let _ccopt s = ccopts := s :: !ccopts
let _config = show_config
diff --git a/driver/optmain.ml b/driver/optmain.ml
index e8c2f46643..d2a1853c83 100644
--- a/driver/optmain.ml
+++ b/driver/optmain.ml
@@ -90,7 +90,6 @@ let show_config () =
let main () =
native_code := true;
- c_compiler := Config.native_c_compiler;
let ppf = Format.err_formatter in
try
Arg.parse (Arch.command_line_options @ [
@@ -98,7 +97,7 @@ let main () =
"-annot", Arg.Set annotations,
" Save information in <filename>.annot";
"-c", Arg.Set compile_only, " Compile only (do not link)";
- "-cc", Arg.String(fun s -> c_compiler := s),
+ "-cc", Arg.String(fun s -> c_compiler := Some s),
"<comp> Use <comp> as the C compiler and linker";
"-cclib", Arg.String(fun s ->
ccobjs := Misc.rev_split_words s @ !ccobjs),
diff --git a/utils/ccomp.ml b/utils/ccomp.ml
index 3cb192e318..4e28485e1d 100644
--- a/utils/ccomp.ml
+++ b/utils/ccomp.ml
@@ -54,7 +54,12 @@ let compile_file name =
command
(Printf.sprintf
"%s -c %s %s %s %s"
- !Clflags.c_compiler
+ (match !Clflags.c_compiler with
+ | Some cc -> cc
+ | None ->
+ if !Clflags.native_code
+ then Config.native_c_compiler
+ else Config.bytecomp_c_compiler)
(String.concat " " (List.rev !Clflags.ccopts))
(quote_prefixed "-I" (List.rev !Clflags.include_dirs))
(Clflags.std_include_flag "-I")
@@ -104,11 +109,12 @@ let call_linker mode output_name files extra =
extra
else
Printf.sprintf "%s -o %s %s %s %s %s %s %s"
- (match mode with
- | Exe -> Config.mkexe
- | Dll -> Config.mkdll
- | MainDll -> Config.mkmaindll
- | Partial -> assert false
+ (match !Clflags.c_compiler, mode with
+ | Some cc, _ -> cc
+ | None, Exe -> Config.mkexe
+ | None, Dll -> Config.mkdll
+ | None, MainDll -> Config.mkmaindll
+ | None, Partial -> assert false
)
(Filename.quote output_name)
(if !Clflags.gprofile then Config.cc_profile else "")
diff --git a/utils/clflags.ml b/utils/clflags.ml
index 94494dac4a..f7649fcd38 100644
--- a/utils/clflags.ml
+++ b/utils/clflags.ml
@@ -46,7 +46,7 @@ and principal = ref false (* -principal *)
and recursive_types = ref false (* -rectypes *)
and make_runtime = ref false (* -make_runtime *)
and gprofile = ref false (* -p *)
-and c_compiler = ref Config.bytecomp_c_compiler (* -cc *)
+and c_compiler = ref (None: string option) (* -cc *)
and no_auto_link = ref false (* -noautolink *)
and dllpaths = ref ([] : string list) (* -dllpath *)
and make_package = ref false (* -pack *)
diff --git a/utils/clflags.mli b/utils/clflags.mli
index 8ba36210e1..af4ded9a6e 100644
--- a/utils/clflags.mli
+++ b/utils/clflags.mli
@@ -43,7 +43,7 @@ val principal : bool ref
val recursive_types : bool ref
val make_runtime : bool ref
val gprofile : bool ref
-val c_compiler : string ref
+val c_compiler : string option ref
val no_auto_link : bool ref
val dllpaths : string list ref
val make_package : bool ref