Skip to content
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

Fix for header-only compile actions by Bazel #219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikael-s-persson
Copy link

Fix for header-only compile actions by Bazel

This PR fixes, as far as I can tell, the issues related to #199 where Bazel adds header-only / syntax-only compilation actions that produce dummy output files (.processed). I believe this is part of Bazel open-sourcing more of its capabilities for preprocessing headers and handling pre-compiled modules.

The fix is based on #209 and makes the following changes:

  • Adds '.h', '.inl', '.hh', '.hpp', '.hxx' to the list of expected source files for C and C++.
  • Add '.processed' to the list of expected output file extensions for compiler actions.
  • Removes '-fsyntax-only' or '/Zs' from the compilation arguments when running the preprocessor-only compilation step to silence any warnings about unused compiler arguments.

This fix was tested in this repo: https://github.com/mikael-s-persson/evdevpp
And also tested and used for a while in other private repos.
This seems to produce clean, non-racy outputs. AFAICT, the resulting compile_commands.json file contains everything it should, including the headers.

Fixes #199

@davidzchen
Copy link

Is ready to be committed? Can someone please review this?

Copy link

@xFile3160 xFile3160 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mtanida
Copy link

mtanida commented Nov 6, 2024

Is this ready to be merged? We are running into the same issue...

@LaicepS
Copy link

LaicepS commented Nov 19, 2024

This worked fine to produce a compilation database on a Abseil library. But I had to patch the refresh.template.py file in the bazel cache by hand. Is there another way (other than waiting for this to be merged)?

@davidzchen
Copy link

@cpsauer could you take a look at this when you have a chance? It would be great to finally get this merged. Thanks in advance.

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.

No source files found in compile args error
5 participants