8000 Add system_includes to cc_library/cc_binary by keith · Pull Request #25751 · bazelbuild/bazel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@keith
Copy link
Member
@keith keith commented Apr 1, 2025

Previously even though the attribute was named includes, the paths
added there were actually propagated through the system_includes
attribute of compilation context. This lead to crosstools passing these
flags with -isystem which was unexpected for first party code.

Many non bazel-first projects have header directory structures that
require custom include paths be propagated throughout the graph, the
alternative to includes is to use strip_include_prefix. The downside
of strip_include_prefix is that you add 1 include path per
cc_library, even if the libraries are in the same package. With
includes these are deduplicated. In the case of LLVM using includes
reduced the number of search paths on the order of hundreds.

If users want to use -isystem for third party code that uses
includes, they can pass --features=external_include_paths --host_features=external_include_paths

Fixes #20267

@keith
Copy link
Member Author
keith commented Apr 1, 2025

this is an alternative option to #25750

@github-actions github-actions bot added team-Rules-CPP 8000 Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Apr 1, 2025
Previously even though the attribute was named `includes`, the paths
added there were actually propagated through the `system_includes`
attribute of compilation context. This lead to crosstools passing these
flags with `-isystem` which was unexpected for first party code.

Many non bazel-first projects have header directory structures that
require custom include paths be propagated throughout the graph, the
alternative to `includes` is to use `strip_include_prefix`. The downside
of `strip_include_prefix` is that you add 1 include path per
`cc_library`, even if the libraries are in the same package. With
`includes` these are deduplicated. In the case of LLVM using `includes`
reduced the number of search paths on the order of hundreds.

If users want to use `-isystem` for third party code that uses
`includes`, they can pass `--features=external_include_paths --host_features=external_include_paths`

Fixes bazelbuild#20267
@keith keith force-pushed the ks/add-system_includes-to-cc_library-cc_binary branch from 246759f to 26c9df6 Compare April 2, 2025 15:56
@keith
Copy link
Member Author
keith commented Apr 2, 2025

unless there's strong support for this over #25750 im going to move forward with that other change instead.

primarily i think that one is preferred since it's unlikely a library should set both includes and system_includes at the same time, and having fewer attrs seems nicer, even when you can get similar behavior with what should be a low usage feature

@keith keith closed this Apr 2, 2025
@keith keith deleted the ks/add-system_includes-to-cc_library-cc_binary branch April 2, 2025 23:26
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: rename includes to system_includes in cc_* functions

1 participant

0