From 4ca26815f59fb60c35b341c438d834578c0f9d6f Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 12 Dec 2025 17:44:46 +0000 Subject: [PATCH] Disable parse_headers when generating commands Since the parse_headers action has a command line with no source files and only headers it results in an exception like: ``` File "/home/ubuntu/.cache/bazel/_bazel_ubuntu/480ee760ab026be301955dc1adc19e40/execroot/_main/bazel-out/k8-dbg/bin/bazel/internal/internal_refresh_compile_commands_use_script_instead.runfiles/_main/bazel/internal/internal_refresh_compile_commands_use_script_instead.py", line 1087, in _get_cpp_command_for_files source_files, header_files = _get_files(compile_action, bazel_binary) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/ubuntu/.cache/bazel/_bazel_ubuntu/480ee760ab026be301955dc1adc19e40/execroot/_main/bazel-out/k8-dbg/bin/bazel/internal/internal_refresh_compile_commands_use_script_instead.runfiles/_main/bazel/internal/internal_refresh_compile_commands_use_script_instead.py", line 590, in _get_files assert source_file_candidates, f"No source files found in compile args: {compile_action.arguments}.\nPlease file an issue with this information!" ^^^^^^^^^^^^^^^^^^^^^^ ``` This header knowledge probably isn't necessary anyways since that can come from other sources. --- refresh.template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/refresh.template.py b/refresh.template.py index 194f365e..cdd47d22 100644 --- a/refresh.template.py +++ b/refresh.template.py @@ -1225,10 +1225,12 @@ def _get_commands(target: str, flags: str): # If https://github.com/clangd/clangd/issues/123 is resolved and we're not doing header extraction, we could try removing this, checking that there aren't erroneous red squigglies squigglies before the module maps are generated. # If Bazel starts supporting modules (https://github.com/bazelbuild/bazel/issues/4005), we'll probably need to make changes that subsume this. '--features=-layering_check', + # Disable parse_headers feature which has a command line with no source file. The resulting compile command would conflict with other knowledge anyways. + '--features=-parse_headers' ] if _get_bazel_version() >= (6, 1, 0): - aquery_args += ['--host_features=-compiler_param_file', '--host_features=-layering_check'] + aquery_args += ['--host_features=-compiler_param_file', '--host_features=-layering_check', '--host_features=-parse_headers'] aquery_args += additional_flags