Support C++20 modules, MSVC part - #836
Open
PikachuHyA wants to merge 2 commits into
Open
Conversation
Fix C++ module support on the MSVC toolchain Apply the MSVC runtime library flags (/MT, /MTd, /MD, /MDd) to the module compile and codegen actions (cpp_module_compile, cpp_module_codegen, cpp20_module_compile, cpp20_module_codegen). Previously module interface units were compiled with no runtime library flag, so cl.exe fell back to the static CRT while importing TUs used /MD, which produced C5050 at import time and LNK4098 at link time. Also fix module dependency scanning on Windows: the deps scanner wrapper passed /scanDependencies- (which disables scanning) and redirected stdout to an output file Bazel never consumes. Pass /scanDependencies with the output file path as an argument and provide DEPS_SCANNER_OUTPUT_FILE to the scanning action, and declare the cpp_module artifact name pattern (.ifc) so module interface files are named correctly.
The include_paths feature only covered regular compile actions, so module dependency scanning and module interface compiles ran cl.exe without /I flags. Headers and modules that resolve through include paths (includes = [...] attributes or external deps) were invisible to the scanner, which could miss dependencies or fail to find headers. Align the action list with the Unix toolchain and also cover the module codegen actions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix C++ module support on the MSVC toolchain
Apply the MSVC runtime library flags (/MT, /MTd, /MD, /MDd) to the module compile and codegen actions (cpp_module_compile, cpp_module_codegen, cpp20_module_compile, cpp20_module_codegen). Previously module interface units were compiled with no runtime library flag, so cl.exe fell back to the static CRT while importing TUs used /MD, which produced C5050 at import time and LNK4098 at link time.
Also fix module dependency scanning on Windows: the deps scanner wrapper passed /scanDependencies- (which disables scanning) and redirected stdout to an output file Bazel never consumes. Pass /scanDependencies with the output file path as an argument and provide DEPS_SCANNER_OUTPUT_FILE to the scanning action, and declare the cpp_module artifact name pattern (.ifc) so module interface files are named correctly.
about
cl.exe /scanDependencies, see https://learn.microsoft.com/en-us/cpp/build/reference/scandependencies?view=msvc-170