[3/5] support C++20 Modules, add deps-scanner and update toolchains#22429
[3/5] support C++20 Modules, add deps-scanner and update toolchains#22429PikachuHyA wants to merge 2 commits intobazelbuild:masterfrom
Conversation
9582891 to
4f31b5a
Compare
4f31b5a to
c6a1120
Compare
comius
left a comment
There was a problem hiding this comment.
After filtering out the other 2 PRs this change looks mostly reasonable. I posted some nits on the files unique to this change.
c6a1120 to
546b0b7
Compare
|
I just keep the main commit in this patch. I also fix |
fd16e2e to
4b3d7f3
Compare
|
hi @comius , the third patch is ready. please review. |
comius
left a comment
There was a problem hiding this comment.
LGTM in general, except an a lot of renames to keep it consistent with PR[1/5].
Please replace cpp20_modules with cpp_modules.
Please replace deps_scanning with cpp_module_deps_scanning - so that there isn't a confusion what the deps are. Or maybe is should be dep_module_scanning?
This patch adds `compiler_input_flags_feature` and `compiler_output_flags_feature` to the features. follow #22717 By default, the features `compiler_input_flags_feature` and `compiler_output_flags_feature` are included through `CppActionConfigs.java` in the `getFeaturesToAppearLastInFeaturesList` method. For reference, see the relevant code here: https://github.com/bazelbuild/bazel/blob/0dbfaccaf5bee5ea7f11c01db1fc0cd1ca7f3810/src/main/java/com/google/devtools/build/lib/rules/cpp/CppActionConfigs.java#L1513-L1573 ## Background I modified `tools/cpp/unix_cc_toolchain_config.bzl` and found no input and output on macOS when testing #19940 with the new action names `c++20-deps-scanning` and `c++20-module-compile`. As discussed in #22429 (comment), I added these two features to `unix_cc_toolchain_config.bzl`. the Windows toolchains already have these features, so no modifications were necessary for `windows_cc_toolchain_config.bzl`. - Windows input flags: https://github.com/bazelbuild/bazel/blob/786a893ef6f69a8f77ca008a478bf67abfdcdc57/tools/cpp/windows_cc_toolchain_config.bzl#L1073-L1095 - Windows output flags: https://github.com/bazelbuild/bazel/blob/786a893ef6f69a8f77ca008a478bf67abfdcdc57/tools/cpp/windows_cc_toolchain_config.bzl#L960-L1020 cc @comius Closes #22743. PiperOrigin-RevId: 643345702 Change-Id: I5715d25e12c7a3616d1fdb484f77ef7cd0fd1bba
1871243 to
282423a
Compare
Complete the following renaming.
How should I handle the singular and plural forms? Currently, Additionally, |
282423a to
c0d43c1
Compare
|
@comius |
|
@trybka ping |
|
Apologies. I had some personal stuff take my attention this past week. I will prioritize this review (and the other splits if they are ready) this week. I appreciate your patience as I am ramping up on this work. |
c0d43c1 to
86d1494
Compare
86d1494 to
ae05dee
Compare
|
@trybka |
trybka
left a comment
There was a problem hiding this comment.
This looks fine to me. I was waiting for the PR for 2/5 to be imported, and I think there are still unresolved comments there (possibly on the internal import), but this split should be fine once that one is ready.
Summary
I have splited the XXL PR #19940 into several smaller patches. This is the third patch to support C++20 Modules, which adds the
deps-scannertool and updates toolchains.This patch includes:
Action Names
Three action names have been added:
c++-module-deps-scanningc++20-module-compilec++20-module-codegenWhen two-phase compilation is employed:
c++-module-deps-scanning: Scans source files and retrieves C++20 Modules dependencies, storing them in<filename>.ddi.c++20-module-compile: Compiles the C++20 Modules Interfaces to a Built Module Interface (BMI), converting<filename>.cppmto<filename>.pcm.c++20-module-codegen: Compiles the BMI to an object file, converting<filename>.pcmto<filename>.o.When one-phase compilation is employed:
c++-module-deps-scanning: Operates similarly to two-phase compilation.c++20-module-compile: Compiles the C++20 Modules Interfaces directly to an object file<filename>.oand produces a BMI<filename>.pcmas a byproduct.File Extensions
We follow the file extensions preferred by different compilers, adding two new
ArtifactCategorys:CPP_MODULE_GCMandCPP_MODULE_IFC..pcm(CPP_MODULE, already exists)..gcm(CPP_MODULE_GCM, new)..ifc(CPP_MODULE_IFC, new).Following the CMake implementation, we added three extra
ArtifactCategorys:CPP_MODULES_INFO,CPP_MODULES_DDI, andCPP_MODULES_MODMAP..ddifile (CPP_MODULES_DDI) stores the dependencies information of one source file..CXXModules.jsonfile (CPP_MODULES_INFO) stores dependencies information for an entire target..modmapfile (CPP_MODULES_MODMAP) maps module names to BMIs, with different formats for each compiler.Additionally, a special
ArtifactCategory,CPP_MODULES_MODMAP_INPUT, is an auxiliary file used to easily obtain the requested BMI paths.Build Variables
Two build variables,
CPP_MODULE_MODMAP_FILEandCPP_MODULE_OUTPUT_FILE, have been added.CPP_MODULE_MODMAP_FILEspecifies the path to the.modmapfile and is used by thecpp20_modmap_file_feature.CPP_MODULE_OUTPUT_FILEspecifies the output name of the BMI when one-phase compilation is employed and is used by thecpp20_module_compile_flags_feature.Toolchains
Three action configs (
cpp_module_scan_deps,cpp20_module_compile, andcpp20_module_codegen) have been added, corresponding to the action names section.Two features (
cpp_module_modmap_file_featureandcpp20_module_compile_flags_feature) have been added, corresponding to the build variables section.Using C++20 Modules necessitates topological ordering for the compilation units. For more details, see the Discovering Dependencies section.
Considering the various compilers, I have added the
deps-scannertool. The default implementation is a script wrapper that uses different scanning methods depending on the compiler. The wrapperdeps_scanner_wrapperis generated by a template file<compiler>_deps_scanner_wrapper.sh.tpl. Three template files have been added:clang_deps_scanner_wrapper.sh.tplgcc_deps_scanner_wrapper.sh.tplmvsc_deps_scanner_wrapper.bat.tplFor a demonstration of how to scan C++20 dependencies, please refer to this demo.