Skip to content

refresh_compile_commands fails #226

Open
@stonebrakert6

Description

@stonebrakert6

Problem

make cdb
bazel run --config=dbg //:refresh_compile_commands && \
         python3 ~/tools/cc_modify.py compile_commands.json
INFO: Invocation ID: 84d29b05-0535-43b6-9a62-9e9eacfdc8c2
WARNING: Build options --features and --host_features have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //:refresh_compile_commands (0 packages loaded, 638 targets configured).
INFO: Found 1 target...
Target //:refresh_compile_commands up-to-date:
  bazel-bin/refresh_compile_commands
  bazel-bin/refresh_compile_commands.check_python_version.py
  bazel-bin/refresh_compile_commands.py
INFO: Elapsed time: 0.138s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/refresh_compile_commands
>>> Analyzing commands used in //base/...
WARNING: Build options --features and --host_features have changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
Traceback (most recent call last):
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.check_python_version.py", line 15, in <module>
    refresh_compile_commands.main()
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.py", line 1422, in main
    compile_command_entries.extend(_get_commands(target, flags))
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.py", line 1282, in _get_commands
    yield from _convert_compile_commands(parsed_aquery_output)
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.py", line 1162, in _convert_compile_commands
    for source_files, header_files, compile_command_args in outputs:
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 619, in result_iterator
    yield _result_or_cancel(fs.pop())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 317, in _result_or_cancel
    return fut.result(timeout)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.py", line 1126, in _get_cpp_command_for_files
    source_files, header_files = _get_files(compile_action)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kartik/.cache/bazel/_bazel_kartik/2759e3591425690b59973aa47ef8b141/execroot/app0/bazel-out/k8-fastbuild-debug/bin/refresh_compile_commands.runfiles/app0/refresh_compile_commands.py", line 630, 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!"
           ^^^^^^^^^^^^^^^^^^^^^^
AssertionError: No source files found in compile args: ['external/local_config_cc/cc_wrapper.sh', '-xc++-header', '-fsyntax-only', '-U_FORTIFY_SOURCE', '-fstack-protector', '-Wall', '-Wthread-safety', '-Wself-assign', '-Wunused-but-set-parameter', '-Wno-free-nonheap-object', '-fcolor-diagnostics', '-fno-omit-frame-pointer', '-std=c++14', '-MD', '-MF', 'bazel-out/k8-fastbuild-debug/bin/external/com_google_absl/absl/strings/_objs/strings/ascii.h.d', '-iquote', 'external/com_google_absl', '-iquote', 'bazel-out/k8-fastbuild-debug/bin/external/com_google_absl', '-mcrc32', '-g', '-fno-omit-frame-pointer', '-DLOG_ACTIVE_LEVEL=0', '-std=c++20', '-stdlib=libc++', '-fnew-alignment=8', '-fno-rtti', '-fno-exceptions', '-fsized-deallocation', '-Wall', '-Wextra', '-Wc++98-compat-extra-semi', '-Wcast-qual', '-Wconversion', '-Wdead-code-aggressive', '-Wfloat-overflow-conversion', '-Wfloat-zero-conversion', '-Wfor-loop-analysis', '-Wformat-security', '-Wgnu-redeclared-enum', '-Winfinite-recursion', '-Winvalid-constexpr', '-Wliteral-conversion', '-Wmissing-declarations', '-Woverlength-strings', '-Wpointer-arith', '-Wself-assign', '-Wshadow-all', '-Wshorten-64-to-32', '-Wsign-conversion', '-Wstring-conversion', '-Wtautological-overlap-compare', '-Wtautological-unsigned-zero-compare', '-Wundef', '-Wuninitialized', '-Wunreachable-code', '-Wunused-comparison', '-Wunused-local-typedefs', '-Wunused-result', '-Wvla', '-Wwrite-strings', '-Wno-float-conversion', '-Wno-implicit-float-conversion', '-Wno-implicit-int-float-conversion', '-Wno-unknown-warning-option', '-DNOMINMAX', '-no-canonical-prefixes', '-Wno-builtin-macro-redefined', '-D__DATE__="redacted"', '-D__TIMESTAMP__="redacted"', '-D__TIME__="redacted"', '-c', 'external/com_google_absl/absl/strings/ascii.h', '-o', 'bazel-out/k8-fastbuild-debug/bin/external/com_google_absl/absl/strings/_objs/strings/ascii.h.processed'].
Please file an issue with this information!
make: *** [Makefile:37: cdb] Error 1

Bazel Version

bazel version
Bazelisk version: development
INFO: Invocation ID: a6f50428-5a46-4b06-99b2-1975b99791c1
Build label: 7.3.2
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Oct 1 17:46:05 2024 (1727804765)
Build timestamp: 1727804765
Build timestamp as int: 1727804765

OS Details

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.1 LTS"

WORKSPACE file (stripped)

workspace(name = "app0")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
http_archive(
    name = "hedron_compile_commands",
    sha256 = "c8029e92da302f0a32fd0d4059358c8657b5cb82628000b7b5e259c73f91882d",
    strip_prefix = "bazel-compile-commands-extractor-4f28899228fb3ad0126897876f147ca15026151e",

    # Replace the commit hash in both places (below) with the latest, rather than using the stale one here.
    # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
    url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/4f28899228fb3ad0126897876f147ca15026151e.zip",
    # When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
)

load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")

hedron_compile_commands_setup()

load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive")

hedron_compile_commands_setup_transitive()

load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive")

hedron_compile_commands_setup_transitive_transitive()

load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive")

hedron_compile_commands_setup_transitive_transitive_transitive()

base/BUILD.bazel file

load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//bazel:copts.bzl", "APP0_DEFAULT_COPTS")

cc_library(
    name = "base",
    srcs = [
        "factorial.cc",
        "logger.cc",
    ],
    hdrs = [
        "factorial.h",
        "fuzztest_wrapper.h",
        "logger.h",
    ],
    copts = APP0_DEFAULT_COPTS,
    linkstatic = True,
    visibility = ["//visibility:public"],
    deps = [
        "@com_github_gabime_spdlog//:spdlog",
    ],
)

filegroup(
    name = "data_test",
    srcs = glob(["test_data/*.txt"]),
)

cc_test(
    name = "factorial.t",
    size = "small",
    srcs = ["factorial_test.cc"],
    copts = APP0_DEFAULT_COPTS,
    data = [
        ":data_test",
    ],
    linkstatic = True,
    tags = [
        "small",
        "smoke",
    ],
    deps = [
        ":base",
        "@bazel_tools//tools/cpp/runfiles",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_binary(
    name = "factorial.bm",
    srcs = ["factorial_benchmark.cc"],
    copts = APP0_DEFAULT_COPTS,
    deps = [
        ":base",
        "@com_github_google_benchmark//:benchmark",
    ],
)

cc_test(
    name = "factorial.fuzz",
    size = "small",
    srcs = ["factorial_fuzz.cc"],
    copts = APP0_DEFAULT_COPTS,
    linkstatic = True,
    tags = [
        "filesystem",
        "small",
        "smoke",
    ],
    deps = [
        ":base",
        "@com_google_fuzztest//fuzztest",
        "@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
        "@com_google_googletest//:gtest",
    ],
)

BUILD.bazel in repository root

load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

buildifier(
    name = "buildifier",
)

refresh_compile_commands(
    name = "refresh_compile_commands",

    # Specify the targets of interest.
    # For example, specify a dict of targets and any flags required to build.
    targets = {
        "//base/...": "--config=dbg",
        "//main/...": "--config=dbg",
        "//workset_cache/...": "--config=dbg",
    },
    # No need to add flags already in .bazelrc. They're automatically picked up.
    # If you don't need flags, a list of targets is also okay, as is a single target string.
    # Wildcard patterns, like //... for everything, *are* allowed here, just like a build.
    # As are additional targets (+) and subtractions (-), like in bazel query https://docs.bazel.build/versions/main/query.html#expressions
    # And if you're working on a header-only library, specify a test or binary target that compiles it.
)

Any ideas how to fix this? It was working last time I checked in March 2024

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions