This is an archive of the discontinued LLVM Phabricator instance.

[C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4)
ClosedPublic

Authored by ChuanqiXu on Nov 6 2022, 11:53 PM.

Details

Summary

In a private chat with @ben.boeckel , we get in consensus it would be great for cmake if the invocation of clang-scan-deps can get rid of compilation database. Due to the compilation database can't do very well for the files which are not existed yet. @ben.boeckel may have more context to add here.

This patch should be innocent for others usages.

Documents and ReleaseNotes would be added later if this get accepted.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Nov 6 2022, 11:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 11:53 PM
ChuanqiXu requested review of this revision.Nov 6 2022, 11:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 11:53 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ChuanqiXu retitled this revision from [C++20] [Modules] [ClangScanDeps] Support to query separate file for P1689 to [C++20] [Modules] [ClangScanDeps] Support to query separate file for P1689 (3/3).
ChuanqiXu retitled this revision from [C++20] [Modules] [ClangScanDeps] Support to query separate file for P1689 (3/3) to [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689.
ChuanqiXu edited the summary of this revision. (Show Details)
ChuanqiXu retitled this revision from [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 to [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/3).Nov 16 2022, 6:40 PM
ben.boeckel added inline comments.Nov 23 2022, 10:01 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
201

I'm not sure what this means. Is it the compiler's working directory when compiling?

206

Can this be something like -- so that I don't have to figure out how to quote the thing (for the shell and whatever parsing Clang does internally)?

Use -- instead - for parameters in tests to avoid confusion.

ChuanqiXu marked an inline comment as done.Nov 23 2022, 11:28 PM
ChuanqiXu added inline comments.
clang/tools/clang-scan-deps/ClangScanDeps.cpp
201

In fact, the option is not used actually for P1689 now. The idea of the patch is to construct a compilation database from these 4 command line options. And the existence for the option is the placeholder and for the consistency. So you can fill the value as if you (or cmake) are generating a compilation database entry for this.

206

Yeah, it can. Both - and -- are accepted. I've updated the test to disambiguate.

ben.boeckel added inline comments.Nov 25 2022, 11:46 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

I don't mean the flag using -- as a prefix. I don't care about that. What I *do* care about is having to quote everything I'd give to clang here. I'd vastly prefer something like:

clang-scan-deps -p1689-targeted-file-name=… -p1689-use-command -- -flags --for ---clang --go --here
ChuanqiXu marked an inline comment as done.Nov 27 2022, 6:23 PM
ChuanqiXu added inline comments.
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

I got your point. But I prefer the current style if it won't be a problem for you to quote the options. In my imagination, it would be easier for the build systems to quote the flags than we synthesis things here. I guess there should already be one existing command line in the build system. And I feel like the current style may be more convenient and friendly for other tools to use. Could you try to use the current style?

ben.boeckel added inline comments.Nov 28 2022, 5:42 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

I don't think CMake has a mechanism for that at all right now. The problem is knowing how to quote things. Is it specified how Clang will parse this string into arguments? Is it platform-dependent?

ben.boeckel added inline comments.Nov 28 2022, 5:57 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

Ah, it is the same as the compilation database parsing.

ChuanqiXu added inline comments.Nov 28 2022, 6:20 PM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

Yeah, given cmake can generate compilation database for a long time. So I think it should be easy for cmake to fill the value.

ChuanqiXu updated this revision to Diff 479168.Nov 30 2022, 9:54 PM

Address comments. Parse flags after "--" as the command line argument for compilation database.

ChuanqiXu added inline comments.Nov 30 2022, 9:56 PM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
206

@ben.boeckel hi, I found that there is existing component to parse the flags after "--" as the input for compilation database. So I can avoid to do too many works. Could you visit if the current interface good for you?

So a few things I see when trying to put this into CMake:

  • P1689 output is only to stdout?
  • Is there a way to get -MF output for the files read during scanning? This is useful to know that "header X changed, scanning may have changed, so please rerun scanning".

Other than that, I have success with CMake's test suite with this patchset as well as the patchset of D137059.

So a few things I see when trying to put this into CMake:

  • P1689 output is only to stdout?
  • Is there a way to get -MF output for the files read during scanning? This is useful to know that "header X changed, scanning may have changed, so please rerun scanning".

Other than that, I have success with CMake's test suite with this patchset as well as the patchset of D137059.

Great to hear that!

  • P1689 output is only to stdout?

From the current implementation, it looks true that the output of clang-scan-deps is only to stdout. I guess it may not be problem since we can redirect it to the file we want. Or is it necessary to specify an output file in the flags?

Is there a way to get -MF output for the files read during scanning? This is useful to know that "header X changed, scanning may have changed, so please rerun scanning".

I sent https://reviews.llvm.org/D139168 to address. You can specify the output of -MF in --p1689-makeformat-output= flags. Is this satisfying?

ChuanqiXu retitled this revision from [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/3) to [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4).
chfast added a subscriber: chfast.Dec 11 2022, 5:54 AM

Why is it necessary to add new command-line flags for this? Can't the input and output be inherited from the specified Clang command line? Would such command line make sense?

clang/test/ClangScanDeps/P1689.cppm
10

What does "separated" mean in this context?

ben.boeckel added inline comments.Dec 22 2022, 10:59 AM
clang/test/ClangScanDeps/P1689.cppm
10

Yeah, this isn't the right term. There are two things being done:

  • discovering dependencies for a future compile (P1689)
  • collecting deps for the scanning itself to know that "if included file X changes, I need to rescan"

Both are required for correct builds.

Why is it necessary to add new command-line flags for this? Can't the input and output be inherited from the specified Clang command line? Would such command line make sense?

CMake wants to query the dependency information for a single file from time to time due to its current structure. And according to @ben.boeckel , the compilation database can't do very well for the files which don't exist during the configuration time. (Maybe @ben.boeckel can add some additional information).

For the reason why we need --p1689-targeted-file-name and --p1689-targeted-output is that FixedCompilationDatabase wouldn't generate the input and output entry from the command line. See the inline comments for example. I feel it is easier and simpler to add 2 flags for it. I add the prefix -p1689 to tell all other users to not use it unintentionally.

clang/lib/Tooling/CompilationDatabase.cpp
376–378 ↗(On Diff #479168)

Here: we can find the file path and the output entry are left empty for the FixedCompilationDatabase.

Why is it necessary to add new command-line flags for this? Can't the input and output be inherited from the specified Clang command line? Would such command line make sense?

CMake wants to query the dependency information for a single file from time to time due to its current structure. And according to @ben.boeckel , the compilation database can't do very well for the files which don't exist during the configuration time. (Maybe @ben.boeckel can add some additional information).

A special compilation database would be required for scanning because the "real" command lines have @rspfile which CMake writes *during the build* with module dependency information (where to put the .pcm from this compile and where anything imported actually lives). Since this file is non-existent in a fresh build and potentially out-of-date after that, CMake would need to write a compilation database just for scanning purposes. Note that this would mean that any change to any command line would necessitate scanning *all* TUs sharing that database because none of them know if their command line is the one that changed. I feel this is a pessimization in the general case (batch scanning may be better for scratch builds, but measurements need to be made).

For the reason why we need --p1689-targeted-file-name and --p1689-targeted-output is that FixedCompilationDatabase wouldn't generate the input and output entry from the command line. See the inline comments for example. I feel it is easier and simpler to add 2 flags for it. I add the prefix -p1689 to tell all other users to not use it unintentionally.

My GCC patch names it -fdepfile-output= instead of --p1689-targeted-output, gets --p1689-targeted-file-name from the regular command line (it looks like a preprocessor command overall) and the --p1689-makeformat-output flag is handled by the normal -MT and -MF flags. While I'm not thrilled with the P1689 naming in the flags (as it'll become P2222 once the TR it's heading for is accepted, aliases should be simple to maintain. My GCC patch uses -fdep-format=p1689r5 so a rename there is easier than a whole flag name. But I suspect that clang-scan-deps is much more of a "tooling's tool" than something people type out by hand, so it's probably not a big deal?

ChuanqiXu updated this revision to Diff 485022.Dec 22 2022, 7:30 PM

Address comments: fix a typo.

My GCC patch names it -fdepfile-output= instead of --p1689-targeted-output, gets --p1689-targeted-file-name from the regular command line (it looks like a preprocessor command overall) and the --p1689-makeformat-output flag is handled by the normal -MT and -MF flags. While I'm not thrilled with the P1689 naming in the flags (as it'll become P2222 once the TR it's heading for is accepted, aliases should be simple to maintain. My GCC patch uses -fdep-format=p1689r5 so a rename there is easier than a whole flag name. But I suspect that clang-scan-deps is much more of a "tooling's tool" than something people type out by hand, so it's probably not a big deal?

Agreed. I suggest to keep the current name in the process of reviewing if @jansvoboda11 don't feel unhappy.

While I was not suggesting using compilation database instead of the approach taken by this patch, I appreciate your explanation. But it still leaves me wondering whether generating one compilation database per file-to-be-scanned would be a reasonable strategy? That might help us avoid increasing the complexity of the clang-scan-deps command-line interface.

If we really want to avoid writing compilation databases, I think that clang-scan-deps -format=p1689 -- <clang_flags> -std=c++20 <input> -o <output> is much cleaner/generic/reusable than clang-scan-deps -format=p1689 --p1689-targeted-file-name=<input> --p1689-targeted-output=<output> -- <clang_flags> -std=c++20. I understand that FixedCompilationDatabase currently doesn't know what the input/output is unless you explicitly pass that in. What if we were able to construct some kind of CompilationDatabase by properly parsing the given complete command line into CompilerInvocation and poking at FrontendOptions?

clang/lib/Tooling/CompilationDatabase.cpp
378 ↗(On Diff #485022)

I don't think this is correct in cases where the command line already contains an input, or is malformed. As an example, if the last element is an option that expects a value (e.g. "-ferror-limit"), appending FilePath will trigger diagnostics in the driver that the argument to -ferror-limit is not numeric and that an input needs to be specified. While the correct/expected behavior would be to emit single diagnostic complaining about missing value for the last option.

Clang's tooling is littered with ad-hoc command-line parsing/manipulation and it's rarely handling all the edge-cases. I'd prefer this complexity lived somewhere outside of Clang, in the tool that actually constructed the command line in the first place.

While I was not suggesting using compilation database instead of the approach taken by this patch, I appreciate your explanation. But it still leaves me wondering whether generating one compilation database per file-to-be-scanned would be a reasonable strategy? That might help us avoid increasing the complexity of the clang-scan-deps command-line interface.

My preferred solution is to just use clang directly, but this is where we ended up. A database file would still require -MF flags for the scan itself (unless it expects us to "lie" about the command line that we'll actually use…which is already true since we'll have to skip the @module_info file as it either won't exist or may be out-of-date). We also need to communicate:

  • the file the scanning output should go to
  • if -MF isn't "stolen" from the "lying" command line, we'll need those flags too

I guess I don't see the benefit of writing out all of these JSON files dealing with escaping and command line parsing when we can just communicate in the same language we do with the compiler anyways (the command line) instead of communicating through a translator (JSON).

If we really want to avoid writing compilation databases, I think that clang-scan-deps -format=p1689 -- <clang_flags> -std=c++20 <input> -o <output> is much cleaner/generic/reusable than clang-scan-deps -format=p1689 --p1689-targeted-file-name=<input> --p1689-targeted-output=<output> -- <clang_flags> -std=c++20. I understand that FixedCompilationDatabase currently doesn't know what the input/output is unless you explicitly pass that in. What if we were able to construct some kind of CompilationDatabase by properly parsing the given complete command line into CompilerInvocation and poking at FrontendOptions?

You still need to know where to put the P1689 output and where the make-style dependency info for files read during the scan need to go. I see these as distinctly clang-scan-deps flags and should be *before* the --. Basically, it seems weird to me to have the clang flags end up telling the scanner where to put the -MF info (as it is now, but you want even fewer flags which I don't think is workable as the information just isn't there).

I believe you are arguing for a JSON file. The complexity of flags that want to pass to clang-scan-deps is too high. You even get some benefit of caching if you create a JSON file with several targets.

While I was not suggesting using compilation database instead of the approach taken by this patch, I appreciate your explanation. But it still leaves me wondering whether generating one compilation database per file-to-be-scanned would be a reasonable strategy? That might help us avoid increasing the complexity of the clang-scan-deps command-line interface.

My preferred solution is to just use clang directly, but this is where we ended up. A database file would still require -MF flags for the scan itself (unless it expects us to "lie" about the command line that we'll actually use…which is already true since we'll have to skip the @module_info file as it either won't exist or may be out-of-date). We also need to communicate:

  • the file the scanning output should go to
  • if -MF isn't "stolen" from the "lying" command line, we'll need those flags too

I guess I don't see the benefit of writing out all of these JSON files dealing with escaping and command line parsing when we can just communicate in the same language we do with the compiler anyways (the command line) instead of communicating through a translator (JSON).

That makes sense to me, thanks.

If we really want to avoid writing compilation databases, I think that clang-scan-deps -format=p1689 -- <clang_flags> -std=c++20 <input> -o <output> is much cleaner/generic/reusable than clang-scan-deps -format=p1689 --p1689-targeted-file-name=<input> --p1689-targeted-output=<output> -- <clang_flags> -std=c++20. I understand that FixedCompilationDatabase currently doesn't know what the input/output is unless you explicitly pass that in. What if we were able to construct some kind of CompilationDatabase by properly parsing the given complete command line into CompilerInvocation and poking at FrontendOptions?

You still need to know where to put the P1689 output and where the make-style dependency info for files read during the scan need to go. I see these as distinctly clang-scan-deps flags and should be *before* the --. Basically, it seems weird to me to have the clang flags end up telling the scanner where to put the -MF info (as it is now, but you want even fewer flags which I don't think is workable as the information just isn't there).

I'm getting confused by the semantics of --p1689-targeted-output=. In D137527, it's used to populate CompilerCommand::Output which is supposed to be the main compiler output (.o file). Is that correct? If that's not the case and this flag is supposed to only control where to put the JSON file with the dependency information, it might as well have more generic name, like -o or --output and apply to the rest of clang-scan-deps, no?

I'm getting confused by the semantics of --p1689-targeted-output=. In D137527, it's used to populate CompilerCommand::Output which is supposed to be the main compiler output (.o file). Is that correct? If that's not the case and this flag is supposed to only control where to put the JSON file with the dependency information, it might as well have more generic name, like -o or --output and apply to the rest of clang-scan-deps, no?

Correct. The semantics of --p1689-targeted-output= should be the same with the main compiler output (.o file).

If we really want to avoid writing compilation databases, I think that clang-scan-deps -format=p1689 -- <clang_flags> -std=c++20 <input> -o <output> is much cleaner/generic/reusable than clang-scan-deps -format=p1689 --p1689-targeted-file-name=<input> --p1689-targeted-output=<output> -- <clang_flags> -std=c++20. I understand that FixedCompilationDatabase currently doesn't know what the input/output is unless you explicitly pass that in. What if we were able to construct some kind of CompilationDatabase by properly parsing the given complete command line into CompilerInvocation and poking at FrontendOptions?

I was worrying about the complexity and I wanted to reuse FixedCompilationDatabase. I'd like to see if we can implement it simply.

You still need to know where to put the P1689 output and where the make-style dependency info for files read during the scan need to go. I see these as distinctly clang-scan-deps flags and should be *before* the --. Basically, it seems weird to me to have the clang flags end up telling the scanner where to put the -MF info (as it is now, but you want even fewer flags which I don't think is workable as the information just isn't there).

Do you think it is OK to write: clang-scan-deps -format=p1689 -- clang++ -std=c++20 -MD -MT <target_name> -MF <dep_file> -c input_file <any_other_needed_opts> -o output_file?

ChuanqiXu updated this revision to Diff 486195.Jan 4 2023, 1:23 AM

Address comments from @jansvoboda11: use the style of clang-scan-deps -format=p1689 -- <clang_flags> -std=c++20 <input> -o <output> instead of clang-scan-deps -format=p1689 --p1689-targeted-file-name=<input> --p1689-targeted-output=<output> -- <clang_flags> -std=c++20.

ChuanqiXu added inline comments.Jan 4 2023, 1:29 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
691–701

Here is the corresponding code: https://github.com/llvm/llvm-project/blob/0e11d65a58da32311b562ecea2b5ba9d4d655659/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp#L39-L43. There is another FIXME.

Simply, we will lost the output file by using createInvocation and I feel it is not easy to fix. Then I feel it is not too bad to parse -o manually here if we document it clearly. I understand the current style will miss some cases like using -output=, -output instead of -o or missing -o. But I don't feel too bad for it.

ChuanqiXu added inline comments.Jan 4 2023, 1:32 AM
clang/tools/clang-scan-deps/ClangScanDeps.cpp
691–701

createInvocation will be helpful to recognize many cases, e.g., -MF in https://reviews.llvm.org/D139168. I feel it'll be worse if we don't use createInvocation .

I'm getting confused by the semantics of --p1689-targeted-output=. In D137527, it's used to populate CompilerCommand::Output which is supposed to be the main compiler output (.o file). Is that correct? If that's not the case and this flag is supposed to only control where to put the JSON file with the dependency information, it might as well have more generic name, like -o or --output and apply to the rest of clang-scan-deps, no?

So the scanner has a few jobs:

  • given this command line for this object file (we do not think in terms of source files because object files are unique; source files can be reused with different flags), please write out a P1689 file describing the module requirements and any module(s) provided (plural because Fortran supports multiple modules in a single source file and unity builds can also do this though I have no idea how likely unity module builds is ever going to be)
  • the format supports doing this for a set of object files (but given the way it tangles the dep graph, is unlikely to be a perf win for incremental/developer builds; CI may prefer it, but that can be future work)
  • because it is a rule that can itself read extra files that affect the scanning; this is the -MF-style output so that make/ninja can know "oh, frabnitz.h changed, it can affect the scan results in glom.ddi, so I will rescan")

Note that multi-arch builds are an open question (just like multi-arch .pcm files are I believe); the format could support it as two reports on provides/reqs, but the merged object file complicates things.

The object can be obtained from the -o on the command line, but the rest is "lying" if it is extracted from the clang command line and not given to clang-scan-deps directly. This paper may be useful for the overall strategy being used here: https://mathstuf.fedorapeople.org/fortran-modules/fortran-modules.html

Note that multi-arch builds are an open question (just like multi-arch .pcm files are I believe); the format could support it as two reports on provides/reqs, but the merged object file complicates things.

BTW, we decide to forbid multiple-arch .pcm files in https://reviews.llvm.org/D137058 now since we don't know how to handle it properly.

gentle ping @jansvoboda11 . sorry for the a little bit hurried ping since LLVM-16 is going to be branched in the 24th of January.

jansvoboda11 added inline comments.Jan 9 2023, 9:40 AM
clang/test/ClangScanDeps/P1689.cppm
10

@ChuanqiXu Can you write up a better comment here?

clang/tools/clang-scan-deps/ClangScanDeps.cpp
691–701

This is again doing ad-hoc parsing of the command-line. clang-cl accepts output file path in the /o argument, which this code will not recognize. You should be able to use CompilerInvocation::CreateFromArgs() to avoid having the -fsyntax-only option injected.

  • the format supports doing this for a set of object files (but given the way it tangles the dep graph, is unlikely to be a perf win for incremental/developer builds; CI may prefer it, but that can be future work)

Another thing to be aware of is that the scanner is tuned for scanning multiple TUs. Single clang-scan-deps invocation maintains a shared in-memory cache of the filesystem between its threads for all TUs it's given. This means invoking clang-scan-deps once for each TU is not as efficient as it could be. At Apple, we only use clang-scan-deps for the in-tree tests. In production, we actually wrap the C++ interface and expose a libclang API that is able to take advantage of caching to improve performance. To be honest, I'm surprised clang-scan-deps is being integrated into build systems as-is, especially without utilizing the cache. How's the performance looking for larger projects?

  • because it is a rule that can itself read extra files that affect the scanning; this is the -MF-style output so that make/ninja can know "oh, frabnitz.h changed, it can affect the scan results in glom.ddi, so I will rescan")

I see. So the P1689 output is the primary scanner output, but you're also relying on emitting .d files to track the actual FS dependencies.

The object can be obtained from the -o on the command line, but the rest is "lying" if it is extracted from the clang command line and not given to clang-scan-deps directly.

I see your point. But since clang-scan-deps is built around reusing the same FS cache for scanning multiple TUs, you'd need to specify these arguments (that we currently extract from Clang command line) for all of those TUs. That's not very convenient, neither through the command line nor via a separate config file.

clang/test/ClangScanDeps/P1689.cppm
11

I'm fairly happy with the clang-scan-deps interface now (besides the performance aspect mentioned in another comment).

@ChuanqiXu what would happen if you run this Clang command line directly?

Another thing to be aware of is that the scanner is tuned for scanning multiple TUs. Single clang-scan-deps invocation maintains a shared in-memory cache of the filesystem between its threads for all TUs it's given. This means invoking clang-scan-deps once for each TU is not as efficient as it could be. At Apple, we only use clang-scan-deps for the in-tree tests. In production, we actually wrap the C++ interface and expose a libclang API that is able to take advantage of caching to improve performance. To be honest, I'm surprised clang-scan-deps is being integrated into build systems as-is, especially without utilizing the cache. How's the performance looking for larger projects?

I originally investigated (and ended up lost) for something like GCC where P1689 information is extracted via -E -fdep-file=p1689.json -fdep-output=module.o -fdep-format=p1689 (which is "abusing" -E, but works), but using clang-scan-deps was where we ended up after a more-knowledgeable LLVM developer took over knowing what needed to be done.

  • because it is a rule that can itself read extra files that affect the scanning; this is the -MF-style output so that make/ninja can know "oh, frabnitz.h changed, it can affect the scan results in glom.ddi, so I will rescan")

I see. So the P1689 output is the primary scanner output, but you're also relying on emitting .d files to track the actual FS dependencies.

Yes, that's exactly it. It'd be great if *every* command had -MF-style information for more accurate builds, but I'll roll that rock up another hill some other day.

The object can be obtained from the -o on the command line, but the rest is "lying" if it is extracted from the clang command line and not given to clang-scan-deps directly.

I see your point. But since clang-scan-deps is built around reusing the same FS cache for scanning multiple TUs, you'd need to specify these arguments (that we currently extract from Clang command line) for all of those TUs. That's not very convenient, neither through the command line nor via a separate config file.

While batch scanning is probably better for one-shot (basically, CI) builds, I suspect the excess work during development/incremental builds will cause that to "lose" over a long enough time span.

ChuanqiXu updated this revision to Diff 487692.Jan 9 2023, 11:06 PM

Address comments:

  • Add more comments in the test.
  • Avoid ad-hoc parsing -o option manually.
ChuanqiXu marked 3 inline comments as done.Jan 9 2023, 11:13 PM

I originally investigated (and ended up lost) for something like GCC where P1689 information is extracted via -E -fdep-file=p1689.json -fdep-output=module.o -fdep-format=p1689 (which is "abusing" -E, but works), but using clang-scan-deps was where we ended up after a more-knowledgeable LLVM developer took over knowing what needed to be done.

Yeah, I believe the clang-scan-deps would be the better option and according to the talk of clang-scan-deps (https://llvm.org/devmtg/2019-04/slides/TechTalk-Lorenz-clang-scan-deps_Fast_dependency_scanning_for_explicit_modules.pdf), it is also the goal of clang-scan-deps to support c++20 modules.

clang/test/ClangScanDeps/P1689.cppm
10

I've updated the comments to tell it is required for non-exist and potentially out-of-date files.

11

what would happen if you run this Clang command line directly?

I remember this refers to %clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/M.cppm -o %t/M.o previously.

And if we run this clang command line directly, it will compile the module-unit M.cppm into object files if all its dependent precompiled module files lives in the directory %t. The command line should be what will run actually.

ChuanqiXu marked an inline comment as done.Jan 15 2023, 6:45 PM

Oh, I forgot to submit the inline comments. My bad.

@jansvoboda11 gentle ping~ (although I feel it may be hard to land this before the branching since I'll take a vacation in 19th until February, @h-vetinari said it should be OK to backport these patches to branched 16.x.)

@h-vetinari said it should be OK to backport these patches to branched 16.x.

That should be considered a comment from the peanut gallery, not a definite statement. What I had said in https://reviews.llvm.org/D137058 was:

[...] but I am not sure if we can land them in time. I guess it may be possible to backport these patches to 16.x since it is relatively important?

Might make sense tagging the release managers if things get tight - perhaps it's possible. E.g. ranges for LLVM 15 was also finished after the branch.

ChuanqiXu marked an inline comment as done.Jan 15 2023, 7:03 PM

@h-vetinari said it should be OK to backport these patches to branched 16.x.

That should be considered a comment from the peanut gallery, not a definite statement. What I had said in https://reviews.llvm.org/D137058 was:

[...] but I am not sure if we can land them in time. I guess it may be possible to backport these patches to 16.x since it is relatively important?

Might make sense tagging the release managers if things get tight - perhaps it's possible. E.g. ranges for LLVM 15 was also finished after the branch.

Sorry for the misleading and thanks for the quick clarification. So it looks like the status quo is a little bit worse than I imaged...

Sorry for the misleading and thanks for the quick clarification. So it looks like the status quo is a little bit worse than I imaged...

I opened a thread on discourse for more visibility: https://discourse.llvm.org/t/land-c-modules-changes-required-for-cmake-before-llvm-16-branch/67717

Sorry for the misleading and thanks for the quick clarification. So it looks like the status quo is a little bit worse than I imaged...

I opened a thread on discourse for more visibility: https://discourse.llvm.org/t/land-c-modules-changes-required-for-cmake-before-llvm-16-branch/67717

Thanks for chime in!

This revision is now accepted and ready to land.Jan 20 2023, 11:22 AM
This revision was landed with ongoing or failed builds.Feb 9 2023, 6:43 PM
This revision was automatically updated to reflect the committed changes.