Don't call the archiver/librarian for empty .cmxa
parent
d732593c85
commit
e6ab329541
6
Changes
6
Changes
|
@ -648,8 +648,10 @@ OCaml 4.11
|
|||
avoiding a problem with x87 excess precision in Float.round.
|
||||
(Xavier Leroy, review by Sébastien Hinderer)
|
||||
|
||||
- #9011: Allow linking .cmxa files with no units on MSVC by not requiring the
|
||||
.lib file to be present.
|
||||
* #9011: Do not create .a/.lib files when creating a .cmxa with no modules.
|
||||
macOS ar doesn't support creating empty .a files (#1094) and MSVC doesn't
|
||||
permit .lib files to contain no objects. When linking with a .cmxa containing
|
||||
no modules, it is now not an error for there to be no .a/.lib file.
|
||||
(David Allsopp, report by Dimitry Bely, review by Xavier Leroy)
|
||||
|
||||
- #9064: Relax the level handling when unifying row fields
|
||||
|
|
|
@ -212,13 +212,12 @@ let scan_file obj_name (tolink, objfiles) = match read_file obj_name with
|
|||
reqd)
|
||||
infos.lib_units tolink
|
||||
and objfiles =
|
||||
if Config.ccomp_type = "msvc"
|
||||
&& infos.lib_units = []
|
||||
if infos.lib_units = []
|
||||
&& not (Sys.file_exists (object_file_name obj_name)) then
|
||||
(* MSVC doesn't support empty .lib files, so there shouldn't be one
|
||||
if the .cmxa contains no units. The file_exists check is added to
|
||||
be ultra-defensive for the case where a user has manually added
|
||||
things to the .lib file *)
|
||||
(* MSVC doesn't support empty .lib files, and macOS struggles to make
|
||||
them (#6550), so there shouldn't be one if the .cmxa contains no
|
||||
units. The file_exists check is added to be ultra-defensive for the
|
||||
case where a user has manually added things to the .a/.lib file *)
|
||||
objfiles
|
||||
else
|
||||
obj_name :: objfiles
|
||||
|
|
|
@ -128,36 +128,18 @@ let compile_file ?output ?(opt="") ?stable_name name =
|
|||
then display_msvc_output file name;
|
||||
exit
|
||||
|
||||
let macos_create_empty_archive ~quoted_archive =
|
||||
let result =
|
||||
command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive)
|
||||
in
|
||||
if result <> 0 then result
|
||||
else
|
||||
let result =
|
||||
command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive)
|
||||
in
|
||||
if result <> 0 then result
|
||||
else
|
||||
command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive)
|
||||
|
||||
let create_archive archive file_list =
|
||||
Misc.remove_file archive;
|
||||
let quoted_archive = Filename.quote archive in
|
||||
if file_list = [] then
|
||||
0 (* Don't call the archiver: #6550/#1094/#9011 *)
|
||||
else
|
||||
match Config.ccomp_type with
|
||||
"msvc" ->
|
||||
command(Printf.sprintf "link /lib /nologo /out:%s %s"
|
||||
quoted_archive (quote_files file_list))
|
||||
| _ ->
|
||||
assert(String.length Config.ar > 0);
|
||||
let is_macosx =
|
||||
match Config.system with
|
||||
| "macosx" -> true
|
||||
| _ -> false
|
||||
in
|
||||
if is_macosx && file_list = [] then (* PR#6550 *)
|
||||
macos_create_empty_archive ~quoted_archive
|
||||
else
|
||||
let r1 =
|
||||
command(Printf.sprintf "%s rc %s %s"
|
||||
Config.ar quoted_archive (quote_files file_list)) in
|
||||
|
|
Loading…
Reference in New Issue