-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow verbose output to be directed to a file #7746
Conversation
Thanks for your pull request and interest in making D better, @marler8997! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#7746" |
baef47f
to
b60e9df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this solves anything (whether rdmd reads from stdout or reads from file its still one compiler invocation).
src/dmd/mars.d
Outdated
if (!params.verbose) | ||
{ | ||
import core.stdc.errno : errno; | ||
error("failed to open verbose output file '%s' (errno %d)", filename, errno); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know that there's a libc function that returns an error message for the given errno.
I'm not sure how introducing a regression warrants a new feature. |
@marler8997 - Please be positive about this. Please be aware that things are still up in the air regarding your linked discussion thread. Please understand that any sweeping changes whilst discussions are ongoing are to be considered in haste. |
b60e9df
to
37c14f3
Compare
I've edited the description to explain why it's useful to allow the verbose output to go to a file. |
44610df
to
2fdcffb
Compare
What's wrong with:
? It's what I do. |
I'm a bit confused;
the point of this PR is to allow a tool to invoke Another solution to this problem would be to redirect |
2fdcffb
to
cc19fa9
Compare
@WalterBright @marler8997 I'd like this PR regardless of above mentioned OPTLINK bug, but is this related? DigitalMars/optlink#20 Replace error message box by output to stderr #20 |
This is definitely a matter with optlink. What other output goes to stdout? |
Other than some special categories of verbose output (i.e. -vls, -vgc, etc) that's all that I know of. If a user wanted to use rdmd and see output from those arguments then we'd have to address those as well. |
optlink would need to be fixed to output to stderr, in all likelihood that shouldn't be too hard. @marler8997 can you please file an issue? There would also be output of |
why would you think it's a security risk? |
|
I'm not an expert but I figure pragmas could instruct dmd to load dependencies from paths and modules that aren't supposed to be looked at. |
Interesting. Yes you could most certainly use pragmas to cause rdmd/dmd to load other files (at least with the current design, not with the new |
You can also use https://dlang.org/dmd-windows.html#switch-Xf The JSON output is supposed to be so other tools can get at the information. |
I'm not familiar with what the JSON file contains, are you saying the you think rdmd could use the JSON file to get all the information it needs? It needs to know all the modules that were imported, the compiler config file, and all the library files that are included in the compilation. |
I suggest generating the file, and see if it fills the need or falls short. If the latter, it can be improved. |
Will do |
There is also a dedicated JSON output in the works, because dub has similar problems and already generates such a probing file: |
__ctfeWrite (whenever gets implemented) could write to stdout -vtls goes to stdout (and has no prefix, eg
All in all, -v=file would avoid all these corner cases AND make tooling based on parsing -v robust without having to know such intricacies.
Let's get it in please, I haven't heard any valid arguments against it. |
Different compiler implementations send output to different locations also, which was the entire point of having |
Per Walter's suggestion, I've started adding code to extend the existing JSON format to contain the relevant information needed by rdmd. It's not done yet but hopefully will be soon. (#7757). |
The converse argument is providing information to tools via json:
I agree that speed may be an issue, as the json file can be large with all the other stuff in it. But I would support a switch to pare that down for specific purposes as needed, but it still should be a json file. |
adding the missing info to json and adding a way to control what json outputs is indeed the best solution. We probably need just 1 way to output json though (via existing -Xf, see #7757) instead of 2 ways (-probe, see #7521)
for things that get automatically generated (like dmd's json output), vanilla json is fine. However for configuration files (eg dmd.conf, dub.json) that are meant to be human edited, ability to add comments is key IMO. A common json extension that allows line comments would be more appropriate for these cases (eg, sublimetext json configuration allows these). It doesn't add much complexity for consumers (eg preprocess json file to remove line comments) |
I did want to mention that there is one drawback to the JSON format. It's not a weakness of JSON itself, more that the current JSON format has an organized structure. This organized structure has a performance cost to the compiler. With the verbose output, you can print any information you like at any time and then throw away that information away if you no longer need it. With the JSON format, you need to save the data until the JSON is generated whether or not you need it for anything else. In the case of the new data I've added for RDMD (https://github.com/dlang/dmd/pull/7757/files), this means that we now have to save a list of all the files that were imported using the "import expression". Before this, that information was "thrown away" after the file was imported, however, now it is saved to an array of "contentImports" in a field added to the Module class, so that the JSON generation code will have that information. In this particular case it's not a big deal since import expressions are so rare, but it is a limitation to consider when deciding whether we want rdmd to use the JSON format instead of the current "verbose" output. |
Going to close. In my opinion, allowing verbose output to be directed to a file might be a nice feature even if it's not necessary for |
? |
I'll just put this in the phantom zone. |
Why did @WalterBright reopen this PR and @ibuclaw why did you close it? |
Provide an option to direct verbose output to a file. This can be used to allow tools to invoke the compiler and capture the verbose output without having to redirect stdout/stderr. This is a potential solution to the rdmd "single invocation problem" and can also be used by other tools to gain information from the compiler without having to redirect stdout/stderr so that error messages and other information still gets back to the user.
EDIT: had originally pushed this to allow rdmd to support single invocation, but now I have another tool that can use it.