Skip to content

[bazel] Enable header processing for C++ builds. #138934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged

Conversation

vonosmas
Copy link
Contributor

@vonosmas vonosmas commented May 7, 2025

This would only work for projects that explicitly enable "parse_headers" feature (or for builds that specify this on command-line) - right now there are none, so this change shouldn't affect most builds. When "parse_headers" is enabled though, it would catch problems of incorrect/missing includes in header-only cc_libraries.

See https://bazel.build/docs/bazel-and-cpp#toolchain-features on why this option is a best practice for C++ projects.

This would only work for projects that explicitly enable "parse_headers"
feature (or for builds that specify this on command-line) - right now
there are none, so this change shouldn't affect most builds. When
"parse_headers" is enabled though, it would catch problems of
incorrect/missing includes in header-only cc_libraries.

See https://bazel.build/docs/bazel-and-cpp#toolchain-features on
why this option is a best practice for C++ projects.
@keith
Copy link
Member

keith commented May 7, 2025

seems reasonable but does this pass for the whole build now? i assume it doesn't in lldb at least because of circular dependencies that we're avoiding

@vonosmas
Copy link
Contributor Author

vonosmas commented May 7, 2025

Yes, bazel build @@llvm-project//... succeeds (re-running now to confirm), because, as noted in the message, the project needs to enable parse_headers for this flag to take effect. If I add it for lldb, then yes, the build fails, as likely there's quite a bit of cleanup. It almost works for libc, so I intend to enable "parse_headers" explicitly in libc/BUILD.bazel soon, but not in other sub-projects.

@keith
Copy link
Member

keith commented May 7, 2025

Ah thanks I forgot this requires the feature too

@vonosmas
Copy link
Contributor Author

vonosmas commented May 8, 2025

Thank you for the review!

@vonosmas vonosmas merged commit 215dbcb into llvm:main May 8, 2025
10 checks passed
petrhosek pushed a commit to petrhosek/llvm-project that referenced this pull request May 8, 2025
This would only work for projects that explicitly enable "parse_headers"
feature (or for builds that specify this on command-line) - right now
there are none, so this change shouldn't affect most builds. When
"parse_headers" is enabled though, it would catch problems of
incorrect/missing includes in header-only cc_libraries.

See https://bazel.build/docs/bazel-and-cpp#toolchain-features on why
this option is a best practice for C++ projects.
@vonosmas
Copy link
Contributor Author

vonosmas commented May 8, 2025

Seems to have landed fine:

WARNING: Build option --process_headers_in_dependencies has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
--
  | INFO: Analyzed 7245 targets (206 packages loaded, 38394 targets configured).
  | INFO: Found 4548 targets and 2697 test targets...
  | INFO: Elapsed time: 14.828s, Critical Path: 2.29s
  | INFO: 243 processes: 34381 action cache hit, 13 internal, 230 processwrapper-sandbox.
  | INFO: Build completed successfully, 243 total actions
  |  
  | Executed 0 out of 2697 tests: 2697 tests pass.

@vonosmas vonosmas deleted the bazel-ci branch May 8, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants