Skip to content
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

rdmd.d: Capture stderr when calculating dependencies #469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

the-horo
Copy link

When invoking the compiler to calculate dependencies capture both stdout and stderr since gdc's verbose output goes to stderr.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @the-horo! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + tools#469"

rdmd.d Outdated
Comment on lines 602 to 607
File stderrFile;
if (captureStderr)
stderrFile = outputFile;
else
stderrFile = stderr;
auto process = spawnProcess(args, stdin, outputFile, stderrFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto process = spawnProcess(args, stdin, outputFile,  captureStderr ? outputFile : stderr);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that having both stdout and stderr be the same file breaks something, see the ubuntu-latest test failure.

As for my tests, when they fail, because they only sometimes fail, they always fail at

tools/rdmd_test.d

Lines 205 to 207 in 1a8c1a9

res = execute(rdmdArgs ~ ["--force", forceSrc]);
enforce(res.status == 0, res.output);
enforce(res.output.canFind("compile_force_src")); // force will re-compile

The output has, so far, been "". One more reason to postpone this PR.

@CyberShadow
Copy link
Member

CyberShadow commented Apr 26, 2024

  1. rdmd and GDC are both very old, why is this change needed now? Has it never worked with GDC?

  2. Wouldn't this also swallow error messages from the compiler that the user should be able to see?

  3. Would it not be better to make the change in GDC (or at least its gdmd wrapper), so that it conforms to the same behavior as the other compilers?

When invoking the compiler to calculate dependencies capture both
stdout and stderr since gdc's verbose output goes to stderr.

Signed-off-by: Andrei Horodniceanu <a.horodniceanu@proton.me>
@CyberShadow
Copy link
Member

CC @ibuclaw

@the-horo
Copy link
Author

  1. rdmd and GDC are both very old, why is this change needed now? Has it never worked with GDC?

The tests fail with gdc so I guess not.

2. Wouldn't this also swallow error messages from the compiler that the user should be able to see?

Yes, they do, that's too bad a consequence to allow as is. Is it enough if we displayed the collected stderr? I can think of either this or rerunning the failed command without changing how gdc or gdmd work.

3. Would it not be better to make the change in GDC (or at least its `gdmd` wrapper), so that it conforms to the same behavior as the other compilers?

Since gdmd is just a wrapper, I don't know how it would be able to split the -v output into legitimate output tied to stdout and error messages displayed on stderr.

@CyberShadow
Copy link
Member

Since gdmd is just a wrapper, I don't know how it would be able to split the -v output into legitimate output tied to stdout and error messages displayed on stderr.

It could pass an internal switch to the command it's wrapping, which redirects these messages to standard output. I think that's what the ldmd command does for LDC, though there, it's not a wrapper but a driver (so it talks to the compiler implementation via function calls instead of subprocesses).

@CyberShadow
Copy link
Member

Yes, they do, that's too bad a consequence to allow as is. Is it enough if we displayed the collected stderr? I can think of either this or rerunning the failed command without changing how gdc or gdmd work.

I think we should try to pursue the third option first. If that doesn't work, then I think that would be OK provided that we only do this redirection for GDC. Since we're already parsing the output, we could also re-print all lines that we couldn't parse (and are therefore likely messages intended for the user).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants