Replies: 1 comment 15 replies
-
Thanks for the nice summary! (Context #17928 (comment))
Yeah, this seems to be hard.
I believe header detection is also an important feature to ensure correctness for C++ builds, so disabling it by default doesn't sound ideal.
Yeah, personally I prefer setting |
Beta Was this translation helpful? Give feedback.
15 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Bazel Community!
Recently, we found that deps pruning with MSVC may result in incorrect build. When built with MSVC, Bazel uses the
/showIncludes
flag to get the actual included header files from a source file. Then Bazel will prune the dependencies based on the output. This behavior is enabled in this commit. The problem is that parsing the/showIncludes
output can be tricky sometimes.The main problem is the
/showIncludes
output may come with different languages and encodings. Bazel already supports 14 languages. But all with UTF-8 encoding. If the encoding of the MSVC output is not UTF-8(for example, the default encoding for zh-CN locale is cp936), then Bazel will fail to detect the/showIncludes
output. But this will not result in any error. Bazel will simply think this source file includes no header files. If any of these header files is modified without updating the source file, this source file will not be re-compiled, resulting in an incorrect build. We noticed this when we upgraded Bazel from 5.4.1 to 6.3.2 recently.One way to fix this is by adding the
VSLANG=1033
environment variable to force MSVC to generate output in English. @meteorcloudy suggested we can add this env var as a default to the parse_showincludes feature. We tested it, and it works great. Sadly, if we didn't install the English language pack, then MSVC would fall back to one of the languages installed, soVSLANG=1033
may cause a non-reproducible build and the problem is not entirely solved.We can fix this problem by installing the English language or changing our build environment to UTF-8 encoding. But I think it's important to avoid Bazel causing incorrect builds without the user's knowledge. Here are some options I came up with:
/showIncludes
output. If it's not UTF-8, fail the build. But I don't know if we can find a reliable way to detect the encoding.This problem should only affect a few users at present, but it invalidates the most important feature of Bazel: always correct. So I think it is worth solving, and I look forward to your opinions.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions