Open davidzchen opened 1 month ago
same error
I also have this issue. The logic in _get_files(compile_action)
does not seem to support a header only compile command. There are no source files because the command is attempting to precompile a header file.
diff --git a/refresh.template.py b/refresh.template.py
index 3b33701..acc5f90 100644
--- a/refresh.template.py
+++ b/refresh.template.py
@@ -615,6 +615,11 @@ def _get_files(compile_action):
# Getting the source file is a little trickier than it might seem.
+ is_precompiled_header = any([arg == "-xc++-header" for arg in compile_action.arguments])
+ if is_precompiled_header:
+ header_files = [arg for arg in compile_action.arguments if not arg.startswith('-') and arg.endswith(".h")]
+ return set(), set(header_files)
+
# First, we do the obvious thing: Filter args to those that look like source files.
source_file_candidates = [arg for arg in compile_action.arguments if not arg.startswith('-') and arg.endswith(_get_files.source_extensions)]
assert source_file_candidates, f"No source files found in compile args: {compile_action.arguments}.\nPlease file an issue with this information!"
This patch works for me.
That's odd. I had cc_library
targets that only had headers in the past, and the tool ran just fine. Something caused this error to come up recently, but I do not know what changed on my system, aside from maybe Bazel getting updated (I am using bazelisk but I don't have Bazel pinned to a specific version in my repo).
In any case, this patched worked for me as well. @ehuang3 can you open a PR?
I started having the same problem in my project. The error also triggers on abseil's header file. I created a small repository so that reproducing is easier. https://github.com/tolikzinovyev/hedron-fail
Arch Linux, Bazel 7.2.0
I started having the same problem in my project. The error also triggers on abseil's header file. I created a small repository so that reproducing is easier. https://github.com/tolikzinovyev/hedron-fail
Arch Linux, Bazel 7.2.0 use https://github.com/xiedeacc/bazel-compile-commands-extractor
Can someone please open a PR for this?
Hey guys--I'm seeing this and will engage with it shortly, aiming for this weekend. Sorry to be only getting to this now; I've been underwater with other things.
Seems like bazel added a new type of header-only compile action, when formerly they only issued them for source files. I think the first step is to understand what's going on in those actions to make sure there aren't other problems and figure out if there's another way to distinguish them (in case the problem happens also with, e.g. c (not c++) headers, breaking the solution above).
Awesome to have a minimal reproduction case and know the Bazel version that broke it--thanks guys.
If anyone is willing to help in the meantime, I think the next steps would be
I recently started getting a
No source files found in compile args
error while runningrefresh_compile_commands
. The error message told me to file an issue for this.Repository is here: https://github.com/davidzchen/bazel-ycm-test
System Info
OS: macOS 14.4.1 Sonoma
Bazel/Bazelisk version:
Python version: