This is an archive of the discontinued LLVM Phabricator instance.

[clang] Set ShowInSystemHeader for module-build and module-import remarks
ClosedPublic

Authored by kastiglione on Dec 8 2022, 10:42 AM.

Details

Summary

Without this change, the use of -Rmodule-build and -Rmodule-import only produces diagnostics for modules built or imported by non-system code.

For example, if a project source file requires the Foundation module to be built, then -Rmodule-build will show a single diagnostic for Foundation, but not in turn for any of Foundation's (direct or indirect) dependencies. This is because the locations of those transitive module builds are initiated from system headers, which are ignored by default. When wanting to observe module building/importing, the system modules can represent a significant amount of module diagnostics, and I think should be shown by default when -Rmodule-build and -Rmodule-import are specified.

I noticed some other remarks use ShowInSystemHeader.

Diff Detail

Event Timeline

kastiglione created this revision.Dec 8 2022, 10:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 10:42 AM
kastiglione requested review of this revision.Dec 8 2022, 10:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2022, 10:42 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Nice. It would be nice to have tests for this, though.

Also, do you think this should be configurable on the command line? I'm thinking about users that are trying to debug their own modular code, but don't really care what happens in the SDK.

Also, do you think this should be configurable on the command line?

Do you have a flag in mind? I have worked around the current behavior with -Wno-system-header, but there are two problems with that: first, it's not obvious that it's needed (I had to debug clang to figure out why diagnostics were missing, most people wouldn't do that), and second it can result in many many warnings, which – if you are only interested in module remarks, represents a bunch of noise.

I'm thinking about users that are trying to debug their own modular code, but don't really care what happens in the SDK.

My first question is how many of those users are there? It seems to me that the module remarks are more for tooling developers than end users. Speaking as someone working on tools, I think I would always want all module-build remarks, since – correct me if I'm wrong – they're relevant only to performance, and for performance I want to see all the builds.

For module-import remarks, I could see it being more interesting to developers, but I don't know how many developers know about and use -Rmodule-import. If we want to proactively support those users, maybe the solution is two flags, say -Rmodule-import and -Rmodule-import-all (I can't think of a better spelling).

For relevant comparisons, the only thing I can think about is the -H flag, which shows all header includes, it does not exclude system headers. Speaking of which, an equivalent for modules might be helpful.

jansvoboda11 accepted this revision.Dec 8 2022, 1:33 PM
jansvoboda11 added subscribers: vsapsai, Bigcheese.

Also, do you think this should be configurable on the command line?

Do you have a flag in mind?

We could have a separate -Ruser-module-{build,import} (and maybe -Rsystem-module-{build,import}) besides the -Rmodule-{build,import} (that would now include both).

I'm thinking about users that are trying to debug their own modular code, but don't really care what happens in the SDK.

My first question is how many of those users are there? It seems to me that the module remarks are more for tooling developers than end users.

I'm not sure TBH. But I think Clang modules are used by people that are not familiar with the inner workings of the SDK.

Speaking as someone working on tools, I think I would always want all module-build remarks, since – correct me if I'm wrong – they're relevant only to performance, and for performance I want to see all the builds.

FWIW, these remarks have been useful for me when checking correctness of implicit builds as well. As for performance, let's pretend I'm trying to optimize LLVM's modular build. I can imagine myself starting investigating our own modules (e.g. seeing how many times clangFrontend gets built), and only dropping down into system headers once that's optimized. Getting bombarded by all the modules that are built for the SDK right away would be too noisy.

For module-import remarks, I could see it being more interesting to developers, but I don't know how many developers know about and use -Rmodule-import. If we want to proactively support those users, maybe the solution is two flags, say -Rmodule-import and -Rmodule-import-all (I can't think of a better spelling).

For relevant comparisons, the only thing I can think about is the -H flag, which shows all header includes, it does not exclude system headers. Speaking of which, an equivalent for modules might be helpful.

I'm fine with landing current functionality provided it's tested (and people like @vsapsai and @Bigcheese don't have objections).

This revision is now accepted and ready to land.Dec 8 2022, 1:33 PM

We could have a separate -Ruser-module-{build,import} (and maybe -Rsystem-module-{build,import}) besides the -Rmodule-{build,import} (that would now include both).

that sounds good to me.

I'll add tests if there are no objections.

From my experience, ShowInSystemHeader for -Rmodule-build is overall useful. I haven't heard from people who want no remarks from system headers and the rest is just hypothetical guesses that can go both ways (some people might like one option while some people might like another option).

Don't have strong opinion about -Rmodule-import as don't use it extensively. But don't have any reasons to avoid consistency in this case, so ShowInSystemHeader for this flag makes sense.

A test case would be great, especially I think that at some point I've seen remarks from system headers (though maybe it was with -Wsystem-header).

minor cleanup of test

This revision was landed with ongoing or failed builds.Mar 31 2023, 3:56 PM
This revision was automatically updated to reflect the committed changes.

CC @ChuanqiXu -- this relates to our discussions about diagnostics in modules. Are you okay with the direction this change is going?