This is an archive of the discontinued LLVM Phabricator instance.

clang-cl: Print a blank line at the start of /showIncludes (PR27226)
AbandonedPublic

Authored by hans on May 3 2016, 11:18 AM.

Details

Reviewers
thakis
brad.king
Summary

MSVC prints a blank line there, and it turns out CMake (at least currently released versions) expects it to be there.

Diff Detail

Event Timeline

hans updated this revision to Diff 56034.May 3 2016, 11:18 AM
hans retitled this revision from to clang-cl: Print a blank line at the start of /showIncludes (PR27226).
hans updated this object.
hans added reviewers: thakis, brad.king.
hans added a subscriber: cfe-commits.
thakis added inline comments.May 3 2016, 11:29 AM
lib/Frontend/HeaderIncludeGen.cpp
106

Doesn't do that for me:

C:\src\ninja>cl /c test.cc /nologo /showIncludes
test.cc
Note: including file: c:\src\ninja\test.h

brad.king edited edge metadata.May 3 2016, 11:34 AM

I do not think MSVC starts off with an empty line with -showIncludes specifically. It is just that MSVC unconditionally prints the name of the source file first. This means that any showIncludes output is naturally preceded by a newline because at least one other line was printed first. If clang-cl is to have compatible output with MS cl then it should print the source file name first too. However, that would be a broader decision that should stand on its own.

IMO the motivating use case is simply a bug in CMake and clang-cl should not have to adapt to it. There is already a workaround available for existing clang-cl/CMake release combinations. CMake nightly binaries will be available starting tonight with the fix, and the CMake 3.6 release will have the fix too.

hans added inline comments.May 3 2016, 11:34 AM
lib/Frontend/HeaderIncludeGen.cpp
106

Ah, it's the newline after "test.cc" that CMake looks for. Hmm..

thakis edited edge metadata.May 3 2016, 11:39 AM

I agree with Brad that it'd be nice if we didn't have to add this :-)

What's the workaround for current cmake releases?

hans added a comment.May 3 2016, 11:41 AM

I agree with Brad that it'd be nice if we didn't have to add this :-)

What's the workaround for current cmake releases?

Passing -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " is the work-around I used.

I just figured that if this is easy to fix, it would be nice for clang-cl users who don't have a bleeding-edge CMake version.

In D19881#420245, @hans wrote:

I agree with Brad that it'd be nice if we didn't have to add this :-)

What's the workaround for current cmake releases?

Passing -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " is the work-around I used.

I just figured that if this is easy to fix, it would be nice for clang-cl users who don't have a bleeding-edge CMake version.

So ninja knows how to filter out the source line that cl.exe prints unconditionally, without a way to disable that. If you add a bare newline, ninja won't filter that out and this will add an empty line to each compile step run under ninja. To work around that, you could print the source input file, but that seems very undesirable.

So I think doing nothing (and documenting the workaround somewhere) is probably the best path forward :-/

(Also, this "only" affects .rc compilations, not regular source compilations -- those don't go through cmcldeps)

hans abandoned this revision.May 3 2016, 11:55 AM

So ninja knows how to filter out the source line that cl.exe prints unconditionally, without a way to disable that. If you add a bare newline, ninja won't filter that out and this will add an empty line to each compile step run under ninja. To work around that, you could print the source input file, but that seems very undesirable.

Printing the source input file would be fiddly, and since this doesn't seem to have bitten a lot of people yet, I suppose it's not worth pursuing further.