PR#5611: avoid clashes betwen .cmo files and output files during linking

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12901 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Wojciech Meyer 2012-09-01 13:10:10 +00:00
parent 7cb5ba33fc
commit 4f968563b6
3 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,7 @@ Bug fixes:
- PR#5327: (Windows) Unix.select blocks if same socket listed in first and
third arguments
- PR#5551: Avoid repeated lookups for missing cmi files
- PR#5611: avoid clashes betwen .cmo files and output files during linking
- PR#5662: typo in md5.c
- PR#5695: remove warnings on sparc code emitter
- PR#5697: better location for warnings on statement expressions

View File

@ -21,6 +21,7 @@ open Cmo_format
type error =
File_not_found of string
| Not_an_object_file of string
| Wrong_object_name of string
| Symbol_error of string * Symtable.error
| Inconsistent_import of string * string * string
| Custom_runtime
@ -272,6 +273,12 @@ let make_absolute file =
(* Create a bytecode executable file *)
let link_bytecode ppf tolink exec_name standalone =
(* Avoid the case where the specified exec output file is the same as
one of the objects to be linked *)
List.iter (function
| Link_object(file_name, _) when file_name = exec_name ->
raise (Error (Wrong_object_name exec_name));
| _ -> ()) tolink;
Misc.remove_file exec_name; (* avoid permission problems, cf PR#1911 *)
let outchan =
open_out_gen [Open_wronly; Open_trunc; Open_creat; Open_binary]
@ -581,6 +588,8 @@ let report_error ppf = function
| Not_an_object_file name ->
fprintf ppf "The file %a is not a bytecode object file"
Location.print_filename name
| Wrong_object_name name ->
fprintf ppf "The output file %s has a wrong name. The extension implies object file when the link step was requested" name
| Symbol_error(name, err) ->
fprintf ppf "Error while linking %a:@ %a" Location.print_filename name
Symtable.report_error err

View File

@ -23,6 +23,7 @@ val extract_crc_interfaces: unit -> (string * Digest.t) list
type error =
File_not_found of string
| Not_an_object_file of string
| Wrong_object_name of string
| Symbol_error of string * Symtable.error
| Inconsistent_import of string * string * string
| Custom_runtime