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