diff --git a/bytecomp/bytelink.ml b/bytecomp/bytelink.ml index 1db87b828..80a9307a0 100644 --- a/bytecomp/bytelink.ml +++ b/bytecomp/bytelink.ml @@ -474,7 +474,7 @@ let link objfiles = if Sys.file_exists c_file then raise(Error(File_exists c_file)); try link_bytecode_as_c objfiles c_file; - if Ccomp.compile_file c_file <> 0 + if Ccomp.compile_file_bytecode c_file <> 0 then raise(Error Custom_runtime); remove_file c_file with x -> diff --git a/driver/compile.ml b/driver/compile.ml index a962b22c4..285db4743 100644 --- a/driver/compile.ml +++ b/driver/compile.ml @@ -153,4 +153,4 @@ let implementation sourcefile = raise x let c_file name = - if Ccomp.compile_file name <> 0 then exit 2 + if Ccomp.compile_file_bytecode name <> 0 then exit 2 diff --git a/driver/optcompile.ml b/driver/optcompile.ml index 628bd3792..7d1e67a94 100644 --- a/driver/optcompile.ml +++ b/driver/optcompile.ml @@ -140,4 +140,4 @@ let implementation sourcefile = remove_preprocessed inputfile let c_file name = - if Ccomp.compile_file name <> 0 then exit 2 + if Ccomp.compile_file_native name <> 0 then exit 2 diff --git a/utils/ccomp.ml b/utils/ccomp.ml index 3ffd92cdf..82ed0956d 100644 --- a/utils/ccomp.ml +++ b/utils/ccomp.ml @@ -21,7 +21,7 @@ let command cmdline = end; Sys.command cmdline -let compile_file name = +let compile_file_bytecode name = command (Printf.sprintf "%s -c %s %s -I%s %s" @@ -33,6 +33,18 @@ let compile_file name = Config.standard_library name) +let compile_file_native name = + command + (Printf.sprintf + "%s -c %s %s -I%s %s" + Config.native_c_compiler + (String.concat " " (List.rev !Clflags.ccopts)) + (String.concat " " + (List.map (fun dir -> "-I" ^ dir) + (List.rev !Clflags.include_dirs))) + Config.standard_library + name) + let create_archive archive file_list = Misc.remove_file archive; match Config.system with diff --git a/utils/ccomp.mli b/utils/ccomp.mli index 17aae2a66..5e6611343 100644 --- a/utils/ccomp.mli +++ b/utils/ccomp.mli @@ -14,5 +14,6 @@ (* Compiling C files and building C libraries *) val command: string -> int -val compile_file: string -> int +val compile_file_bytecode: string -> int +val compile_file_native: string -> int val create_archive: string -> string list -> int