optionally write the output of -dlambda etc into a file#1913
optionally write the output of -dlambda etc into a file#1913trefis merged 1 commit intoocaml:trunkfrom
Conversation
|
Thanks! I like the idea in general. Regarding the name of the option I'd
say `-dfile` seems more straightforward to me. Also, have you considered
giving a more specific extension to the produced file? For instance,
`.lambda` or `.dlambda` etc., given that the latter may be better
because `.cmm` would cause conflicts e.g. with the `.cmm` source files
of the testsuite. Also, with a more specific extention, one could
imagine in the future dumping several things in parallel, which would
have to be in a different PR, of course.
|
|
I didn't really consider printing to several file. While writing this, I realized that |
trefis
left a comment
There was a problem hiding this comment.
I've reviewed the code and it seems all fine to me.
I was a bit surprised to this this new flag in Common_options instead of Compiler_options.
Is there a situation where you'd like to be in the toplevel with -dwhatever -dintofile?
About the name, I disagree with Sebastian: -dfile seems worse to me. I'd be fine with -dtofile (... or -dtf), but that's probably a sign that my english is bad.
I agree with Sebastian that at some point we might want to dump to different files, but that it is a discussion for another day.
Thanks for this work @sliquister, several people have wanted this option for a while!
testsuite/tools/expect_test.ml
Outdated
| if !Clflags.dump_parsetree then Printast. top_phrase ppf phrase; | ||
| if !Clflags.dump_source then Pprintast.top_phrase ppf phrase; | ||
| if !Clflags.dump_parsetree then Printast.top_phrase ppf phrase; | ||
| if !Clflags.dump_source then Pprintast.top_phrase ppf phrase; |
There was a problem hiding this comment.
That diff is a bit gratuitous.
There was a problem hiding this comment.
Oh yeah, that's probably leftover from previous changes, I'll remove it while I squash all the commits.
|
Btw, I'm pretty sure this is going to conflict with #1703, and I'm not sure which one (if any) is going to be easier to rebase. Given that @Drup has already waited a long while, I'm tempted to wait for his PR to get merged first and ask @sliquister to rebase this one (sorry). |
|
(On the other hand, this PR is ready now, and there's always the possibility that @mshinwell won't review @Drup's PR before 2021, so... 😆 ) |
|
How about something like |
|
sliquister (2018/07/18 05:47 -0700):
`-dfile` was actually the previous name I had for this option! I
thought if the `d` means debug or dump, it makes a bit more sense to
say `dump into file` or `debug into file` than `debug file` or `dump
file`, which sounds more like `-dsource`.
Well, to me `-d` is just a prefix for debug-related options so it's just
kind of a namespace, but other developers may have other opinions.
I didn't really consider printing to several file.
I think it's more convenient for tooling to have a single file? As in,
if you have keybindings to go from `.ml` to `.mldump`, that's all you
need.
But what if the tools have some understanding of the different
representations? With one file extension, the tool would not be able to
figure out what the file content is.
If you have 3 files, now the tool needs to ask which file you
want to go in (some of which may exit only due to option from previous
builds).
Well your unique dump file may also exist because of a former
compilation. Dates can be used to make sure the dump file(s) is(are)
newer than the source file, nomatter how many different file types there
are.
It's harder to gitignore such files, though that can be made
to work with a different naming convention. A build system that cares
about undeclared targets would have to know about every option.
Well we already handle `cmt`, `cmti`, \annot` so I don't think it's a
big deal.
The compiler runs `cmm`, `live`, `regalloc`, `cmm`, `live`,
`regalloc`, etc for one source file; we can't create one file per
toplevel declaration, so what would you expect? The dcmm would contain
the concatenation of all the dcmm output?
Isn't it what happens currently on stderr?
Basically my suggestion was to have one file type per different
representation, or per command-line flag, if you prefere.
|
|
@trefis yeah they will conflict, but I don't think the resolution will be problematic: resolve in favor of Drup's PR, and then reimplement this pull request in the couple of files. What'd be annoying is to have conflict in 30 different files. @lpw25 |
|
`-dtofile` would be okay for me, `-dtf` sounds really too cryptic. But
well, I don't have an strong opinion.
|
|
Isn't @mshinwell on vacations till at least the end of this week?
|
|
@shindere: he is. |
|
I completely missed @trefis's initial comment, somehow. I put the flag to control where to dump along with the flags that enables dumping. I could maybe move it to Compiler_options, I'm not sure what tool uses what set of options. In the toplevel, I implemented something because the flag was supported; I thought it may not be useless to say |
|
I didn't check yet, sorry: do yo plan to add tests for this new option?
I think it'd be great.
|
|
I'm not convinced either by the common I agree with @shindere that per-format extensions would be better. Either
I'm skeptical that the situation is worse for build systems for several extensions than for one. Either the build system is smart about parsing the user-provided command-line parameters, and it knows exactly when one of these files will be output (same with one extension or several), or it does not, and it has to pessimistically assume that any of them may be output (same with one extension or several). The The question of what to do when outputting disjoint pieces for each phrase remains (with either What about P.S.: to me |
I disagree with you there. People are of course free to do more work right now, my approval was just meant as "I'd be happy to merge what is currently there, if nothing more happens". |
|
If it goes in the language in the current state, people will adapt their tooling and workflow to support it, and would then have to redo the work if we decide to change things. That sounds bad, and enough of an additional frustration to not change things. It's fine if we disagree on that point, but to me things that change the tool-oriented interface of the compiler should be considered more carefully than things that change the human-oriented interface; we can iterate five times on an error message reformulation if we fancy, not on how we produce new files. |
|
Original author of the First, "d" means "dump", but "display" works too. Second, for debugging the back-end of ocamlopt (something I did a lot of when @gasche was still in elementary school), I find it convenient to have all outputs in one file (redirected from stderr in the old days). Since each top-level function F1...Fn is sent through the back-end pipeline one after the other, the output of With separate files, having this kind of combined view takes more work, not so much with 2 files but certainly with 3 files or more. |
|
(If we go with only |
|
We could also decide, as a hybrid approach, to group some of the passes together but not all. The backend passes that print per-function, they could be grouped together, but personally I would find it weird for I thought of suggesting |
|
@trefis I moved the option to Compiler_options, and removed most of the changes to the toplevel as a result. @gasche Now about the multiple files, I'm surprised people are insisting on it, especially given that the compiler is already printing everything in one file, along with all the errors. I don't see what is this migration cost that would justify keeping the status quo over this pull request. We're talking about looking at intermediate asts here, it's not like every ocaml user does this kind of things every 10min. None of the |
14d132f to
093f86b
Compare
I have to agree with @sliquister here that this argument seems very weak given the current context (what tooling? what workflow?). |
|
Well @sliquister mentioned two kind of changes to adapt to this PR:
Both things would have to be changed if the interface changes. |
|
I looked at what ghc does for comparison: so I renamed the output to This way, you can ignore For the build system, all I can say is it takes 15s to write |
b37d42c to
c45ffce
Compare
|
Allow me to resume the conversation. It is true that that if we merge this PR as is, and then change the meaning of the option to dump to different files, any build system with specific support for that option, which also keeps track of the targets of each rule, will have to be updated. In my opinion, that should be enough to justify merging the current PR as is. Considering that:
I kindly ask you to reconsider your objection, and allow this PR to be merged. |
|
@trefis, I agree with your analysis and I was thinking of writing a message of the same effect anyway. I still believe that the proposed behavior is the wrong one, and that at least all whole-program representations (not per-function representations) should be printed to separate file, but (1) apparently no one else cares except maybe Sébastien and (2) indeed I don't currently have the time to do anything constructive about it. Let's agree to disagree and let you take your responsibilities if you want to merge this PR. |
|
Why are we writing the file to (I wanted to use |
|
The same source can be compiled multiple times: with ocamlc, with ocamlopt,
with ocamlopt with profiling (.p.cmx in the compiler build), etc. Targets
are unambiguous, but unlike sources.
Don't you get both foo.cmo.dump and foo.dump if you compile and link in one
call?
Le sam. 8 sept. 2018 06:30, Gabriel Scherer <notifications@github.com> a
écrit :
… Why are we writing the file to <target>.dump instead of <source>.dump? If
I run ocamlc -o foo test.ml, the "target file" is test.cmo, but this is
somewhat arbitrary: it could have been test.cmi or foo for example.
(I wanted to use -dump-into-file to implement #2030
<#2030> but the use of the target
makes it inconvenient, it is easier to just redirect the error output to a
file.)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1913 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABN0USxdnlABkOU_uygEsZm2ihklr7saks5uY5wtgaJpZM4VT3KD>
.
|
* update tailwind config to accomodate styles for prose sections from tailwind-typography
Right now, -dlambda, -dcmm, -dlive and all such debug flags cause the compiler to write to stderr. This works fine when running the compiler by hand, but when using a build system, it's usually easier or more convenient to change flags for a bunch of files at once, at which point the printing to stderr isn't so nice.
So I propose the addition of a flag -dintofile that makes the compiler write all such output into a file
<compilation-unit>.mldump, or<exe>.mldumpdepending on what is being built.I initially had the command line take the filename to write into, but I think it's preferable to have the compiler choose it, similar to
ocamlopt -S. It's simpler for the build system, simpler to setup editor modes if needed.Implementation-wise, many files are touched, but the changes are simple: the debug output already goes into this
ppfargument being passed around, so I rename it to~ppf_dumpto clarify the intended use of the formatter (and avoid people starting using it to print errors).Then I grepped for Clflags.dump to see if I was missing some flags, and found some prints directly on stderr, which I made use this
ppf_dump.I had a previous version where the formatter was in a global variable (as is traditional), but I think passing the formatter around is better because it's clear when we do and don't need to provide such a formatter.