When compiling using a Mercury compiler built on top of MSVC,

Estimated hours taken: 3
Branches: main

When compiling using a Mercury compiler built on top of MSVC,
we use the windows command shell to invoke commands.
The windows command shell limits the length of command lines,
this change works around that limit when building the command line
to build an archive.

compiler/compile_target_code.m:
	When linking using the windows lib tool, place the list of
	files into a temp file and use that temp file as the method
	to pass the set of files to link to lib.
This commit is contained in:
Peter Ross
2007-06-14 00:18:26 +00:00
parent fd13fd11ab
commit c145103208

View File

@@ -2037,11 +2037,45 @@ create_archive(ErrorStream, LibFileName, Quote, ObjectList, Succeeded, !IO) :-
% Quoting would prevent that.
join_string_list(ObjectList, "", "", " ", Objects)
),
MakeLibCmd = string.append_list([
ArCmd, " ", ArFlags, " ", ArOutputFlag, " ",
LibFileName, " ", Objects]),
invoke_system_command(ErrorStream, cmd_verbose_commands,
MakeLibCmd, MakeLibCmdSucceeded, !IO),
( ArCmd = "lib" ->
%
% If we are using lib, we are on windows and windows doesn't
% handle long command lines, so place the list of object
% files in a file and pass that file as an argument to lib.
%
io.make_temp(TmpFile, !IO),
io.open_output(TmpFile, OpenResult, !IO),
(
OpenResult = ok(TmpStream),
io.write_string(TmpStream, Objects, !IO),
io.close_output(TmpStream, !IO),
MakeLibCmd = string.append_list([
ArCmd, " ", ArFlags, " ", ArOutputFlag,
LibFileName, " @", TmpFile]),
invoke_system_command(ErrorStream, cmd_verbose_commands,
MakeLibCmd, MakeLibCmdSucceeded0, !IO),
io.remove_file(TmpFile, RemoveResult, !IO),
(
RemoveResult = ok,
MakeLibCmdSucceeded = MakeLibCmdSucceeded0
;
RemoveResult = error(_),
MakeLibCmdSucceeded = no
)
;
OpenResult = error(_),
MakeLibCmdSucceeded = no
)
;
MakeLibCmd = string.append_list([
ArCmd, " ", ArFlags, " ", ArOutputFlag, " ",
LibFileName, " ", Objects]),
invoke_system_command(ErrorStream, cmd_verbose_commands,
MakeLibCmd, MakeLibCmdSucceeded, !IO)
),
(
( RanLib = ""
; MakeLibCmdSucceeded = no