Disabling warnings from external headers
The default Bazel C++ toolchain has a cool feature that allows disabling warnings from external headers: https://github.com/bazelbuild/bazel/pull/13107. It would be nice to add this to rules_cc_toolchain, too. It would make clang version upgrades less painful for downstream users like Pigweed (since third-party deps may pick up lots of new warnings on a version upgrade).
The implementation in the default toolchain is actually very simple, but it's not possible to express as a cc_feature, so it's not immediately clear to me how to add it.
Perhaps this should wait until the modular cc toolchains is finalized, since that may involve big changes to rules_cc_toolchain.
I used to think this would be quite easy: https://github.com/tpudlik/rules_cc_toolchain/commit/80677f37da51d3d18cc9baba63327d36d91b23bd
But to my surprise, this leads to errors when I try to compile Pigweed. Typical error:
In file included from external/boringssl/src/crypto/x509/x_val.c:62:
In file included from external/boringssl/src/crypto/x509/internal.h:62:
external/boringssl/src/include/openssl/base.h:340:13: error: typedef redefinition with different types ('int' vs 'struct crypto_threadid_st')
typedef int CRYPTO_THREADID;
^
external/debian_stretch_amd64_sysroot/usr/include/openssl/crypto.h:237:3: note: previous definition is here
} CRYPTO_THREADID;
^
I think what's going on here is that the -I vs -isystem distinction was used in rules_cc_toolchain to override headers from the sysroot with headers from other external repos (boringssl in this case). But external_include_paths is implemented in upstream Bazel by converting -Is from external repos to -isystem.
This can probably be fixed by ensuring the include order for sysroot libraries is correct (so that they're overriden anyway), but the details are hazy to me.
Yeah, I don't really have a good understanding of this either. I'm more than happy to change the usage of include flags in rules_cc_toolchain. I'll admit I'm not super familiar with the differences between; -I, -isystem, -iquote. I've read the docs for these flags, but I didn't feel like I fully understood the specific differences in enough detail to offer any guidance.