mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 15:26:31 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user