[wg-windows] mingw, ocamlopt and "input line is too long"
dra-news at metastack.com
Thu Jul 7 12:19:17 BST 2016
Alain Frisch wrote:
> On 07/07/2016 12:27, Andreas Hauptmann wrote:
> > However there are at least two problems:
> > - the decision to use bash or not is based on a gross estimation, not
> > the real command line length (It looks at your object files, not your
> > include directories)
> Indeed, and this is now fixed in the development version.
> > - The wrong quote function is used to write the shell script
> > (Filename.quote quotes for cmd, not a unix shell,...)
> Do you have a reproduction case for this one?
The full story is even more involved than just argument quoting (I did a lot of forensic digging in the code for cygwin1.dll in May). Handling of double-quotes is different from the standard Windows mechanism (described in the somewhat obscurely-named CommandLineToArgvW function in MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/bb776391(v=vs.85).aspx).
The final result of digging (and fruitless requests on the Cygwin list) was:
1. When invoking a Cygwin process, it is necessary to go via the win_create_process C primitive from the Unix module (in order to bypass OCaml's correct implementation of CommandLineToArgvW escaping)
2. It is necessary to escape the arguments also taking into Cygwin's noglob setting (two entirely different escaping code paths).
For OPAM, which does not need any globbing assistance, this resulted in https://github.com/dra27/opam/blob/windows/src/core/opamProcess.ml#L17-L202. It's working for me so far, but it's clearly going to need @response support implementing soon, as noted in the comments! That code also permits the effect of being able to execute #! scripts directly: https://github.com/dra27/opam/blob/windows/src/core/opamProcess.ml#L369-L421.
More information about the wg-windows