[WIP] Implement responsefiles support PR7050#748
[WIP] Implement responsefiles support PR7050#748bschommer wants to merge 2 commits intoocaml:4.04from bschommer:responsefile
Conversation
Teh functions expandargv and writeargv implement the nearly the same functionality as the expandargv and writeargv functions of the libiberty, which is used by the gnu tools. Expandargv allows it to specify response files for too long command lines and writeargv prints an array of arguments in a compatible way.
This allows the ocaml compiler to read arguments from responsefiles.
|
Dear @bschommer, Once upon a time, the Win32 version of OCaml had expansion of Then it was noticed this conflicted with the In conclusion: your pull request reintroduces the problem with expanding What you could investigate instead is to add to in their argument parsing specifications. |
|
Another problematic point is that we still haven't agreed on a concrete syntax for response files. The one proposed in this PR is fine for Unix-like platforms, as it inverts Also, @alainfrisch adamantly champions the "one line = one option" syntax. See, the problem is not so much to code a reasonable solution; it is to agree on the specs of a reasonable solution. |
|
It was more of a first throw, I should have made it clearer that this is not some finished implementation but rather some first try.
That is the reason why I called it before any argument parsing, however with the current implementation you still could not write @AE if there is a file called ae in the working directory.
My thoughts for using the Unix syntax is that is widely used and gcc as well as clang both support it. For the compiler itself one could support different quoting styles and choose them according to the OS or some ENV variable. This would also allow the simple one arg = one line approach.
This seems actually a pretty good idea. How about adding the spec to the |
Please, don't do that. Concerning the choice of a syntax, I maintain my position that the "one line = one arg" solution is the simplest one, both in terms of implementation and of usability (for all build systems that will need to produce response file), and also the most portable one (including for cross-compilation scenarios). What are the benefits of requiring any quoting convention? |
|
I think the only implementing the gnu quoting conventions is that they allow writing the command line in the same way than passing it through the actually command line. |
|
What about There are two advantages:
It's just a bit annoying if you want to write a responsefile by hand, so maybe we could support both: |
I opened a PR request with the implementation of this. |
I suspect that nobody is ever going to need (and thus probably use) the |
|
The only arguments I think of are defines for the C source code, but those can be passed in response file for the C compiler. |
|
I guess one example would be an interpreter where you want to pass some input from the command line. But more generally, even though having newlines in filenames is a bad idea, it's not technically forbidden. So by using |
|
But in other options it could appear, that is basically the problem with any separator sign. However these kind of options could still be passed via the command line. |
|
You cannot have |
|
Another the problem with |
|
That's right, newlines are better for files written by humans (you can use a normal editor) while |
|
How about using both? The newline as separators and the |
|
In the Mantis discussion http://caml.inria.fr/mantis/view.php?id=7050 , I suggested to split at NUL bytes if the response file contains NUL bytes, otherwise split at newlines. This was ignored, but it seems we're on our way to propose it again. This discussion is really going in circles. |
|
Sorry, I didn't read the mantis discussion initially. Splitting at |
|
It seems we are converging to Xavier's solution 1b in http://caml.inria.fr/mantis/view.php?id=7050#c14736 What would be the exact rules? In particular:
|
|
I would ignore consecutive |
This makes it impossible to pass arbitrary arguments (it's not like empty arguments are very common, but neither are those with newlines). I would also suggest that at least for the text version (i.e. no NUL), we trim a final \r character on each line (assuming lines are split on \n) to avoid problems if Windows tools are used to produce (in text mode) those response files. |
|
The various tools that takes a For the same reason I think a final newline shouldn't create a final empty argument. Ignoring consecutive NUL bytes doesn't seem right to me; given that such files will always be machine generated, programmers can manually filter empty arguments if they want to |
|
Fine with me. About the implementation: My suggestion would be to add the |
|
Agreed. I would add the reading and writing functions directly to the |
|
I totally agree with @diml on all points. |
|
BTW you will have to open a new PR against trunk, as this is not going into 4.04. |
|
I will open a new PR once PR #778 is merged. |
|
Concerning the scope: I would also like to add responsefile support for the other tools, e.g. ocamldep, ocamldoc, etc. |
WG3 move gen_sizeclasses
"include functor" extension from ocaml-jst
Added (4): * Winning on Windows: porting the OCaml Platform * R&B: Towards bringing functional programming to everyday's web programmer * Relit: Implementing Typed Literal Macros in Reason * Wall: rendering vector graphics with OCaml and OpenGL Still Missing (8): * Abusing Format for fun and profits * MLExplain * OCaml on the ESP32 chip: Well-Typed Lightbulbs Await * RFCs, all the way down! * The OCaml Platform 1.0 * The OCaml Software Foundation * The Vecosek Ecosystem * This PDF is an OCaml bytecode Co-authored-by: Cuihtlauac ALVARADO <[email protected]>
"include functor" extension from ocaml-jst
This is a first implementation of support for giving arguments via response file as
@file. The quoting conventions are the ones of the gnu tools. The implementation itself is a variation of the patch attached to the original mantis issue http://caml.inria.fr/mantis/view.php?id=7050.The functionality is implemented via two new functions in the Arg module.