toolchains_llvm icon indicating copy to clipboard operation
toolchains_llvm copied to clipboard

`hdrs` includes are passed as `-isystem` to clang, suppressing important warnings

Open froody opened this issue 5 months ago • 1 comments

By default, most include paths passed to clang when using toolchains_llvm are passed as -isystem, which suppresses many warnings. This wasted a lot of time for me the other day when I accidentally declared a function with a bool return type and no return value. This is easily caught by clang under normal circumstances as I pass -Wall and -Werror, but due to the way headers are included, the warning/error never surfaced and it took hours to find.

For this target:

cc_libray(
name = "foo",
srcs=glob(["foo/*.cpp"]),
hdrs=glob(["foo/*.hpp"]),
)

I would expect things like -Wreturn-type violations in .hpp files to fail the build, but the way clang is currently invoked they don't.

froody avatar Jul 06 '25 07:07 froody

This will be fixed in Bazel itself: https://github.com/bazelbuild/bazel/pull/25750

fmeum avatar Jul 06 '25 07:07 fmeum