Do not expose external repo source root as system include - #802
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
When external_include_paths is enabled, keep the external repository source root available only to the target's own compilation through local_includes. Do not propagate it as an external include to downstream targets, where it becomes an -isystem path and can expose non-header files such as VERSION to angle-bracket includes on case-insensitive filesystems. Fixes bazelbuild#801
cf502b8 to
257b000
Compare
|
There's a tough call here because this is potentially breaking anyone have bright ideas? |
But shouldn't be expected that repos that do use "import from the root of the repo" should have The change just removes the implicit include paths that were never mentioned anywhere, yet caused problems. As C++ gains more STL headers in newer revisions, more conflicts like these will arise, some even on case-sensitive filesystems. |
Today that isn't possible #625 |
I wasn't aware of that. But don't you think that this PR actually fits nicely together with yours? |
|
the annoyance I guess is then users would have to add a dep on a module in the root of the repo to every nested cc_library. not in the simple BCR case, but in the more complex case where they follow that pattern |
Fixes #801.
When
external_include_pathsis enabled for a target in an external repository,rules_ccreclassifies public include paths as external/system includes. Including the external repository source root (repo_path) in that set emits-isystem external/<repo>on downstream compile actions and exposes unrelated root files to angle-bracket lookup.On case-insensitive filesystems, a repository containing a root-level
VERSIONfile can therefore break libc++’s#include <version>. The issue originally surfaced inDoDoENT/bazel-playgroundthrough its OpenCV/libtiff dependency graph.Keep the external repository root propagated as a quote-only include (
-iquote). This preserves repository-relative quoted includes for downstream dependents without making the root eligible for angle-bracket includes. Generated roots and explicit public include directories remain external/system includes.The
external_include_pathsanalysis regression inspects a downstream compile action and asserts that the exact external repository root:-isystemand-I, reproducing the original header-shadowing failure;-iquote, reproducing the downstream include failure caused by keeping the root target-local.Other public paths from the external dependency are still required to appear as system includes.
Validation:
bazel test //tests/cc/common:cc_binary_configured_target_tests --test_output=errors