bazel-contrib / bazel-contrib/toolchains_llvm

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

Open
#523 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
371
Forks
283
Avg merge
1d 55m
Merged PRs (30d)
25

Description

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.

Contributor guide

Open the contributing guide

Research direction

Trace how toolchains_llvm turns hdrs include paths into clang flags for the shown cc_library target. Reproduce the case with -Wall and -Werror and a header containing a missing return, then compare -isystem with ordinary include handling. Done means the warning is surfaced without suppressing warnings from external headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.