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

refresh_compile_commands fails with bazel cc_test using @googletest//:gtest as dep #218

Open
xFile3160 opened this issue Sep 16, 2024 · 2 comments

Comments

@xFile3160
Copy link

xFile3160 commented Sep 16, 2024

As per title,
I have an unit test:

cc_test(
    name = "test_vivivisio_preview_pipeline",
    srcs = ["test_vivivisio_preview_pipeline.cpp"],
    data = [
        "//pipelines:pipeline-preview.bin",
        "//pipelines:pipeline-preview.json",
    ],
    deps = [
        "//core:vivivisio",
        "@bazel_tools//tools/cpp/runfiles",
        "@fmt//:fmt",
        "@googletest//:gtest",
        "@googletest//:gtest_main",
    ],
    linkstatic = True,
)

Now when I either run:

bazel run //:refresh_compile_commands

or

bazel run @hedron_compile_commands//:refresh_all

I get:

INFO: Invocation ID: c9c374fd-8920-4877-bcea-728edffb6e80
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 @@hedron_compile_commands~//:refresh_all (130 packages loaded, 5338 targets configured).
INFO: Found 1 target...
Target @@hedron_compile_commands~//:refresh_all up-to-date:
  bazel-bin/external/hedron_compile_commands~/refresh_all
  bazel-bin/external/hedron_compile_commands~/refresh_all.check_python_version.py
  bazel-bin/external/hedron_compile_commands~/refresh_all.py
INFO: Elapsed time: 1.163s, Critical Path: 0.24s
INFO: 5 processes: 5 internal.
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/external/hedron_compile_commands~/refresh_all
>>> Analyzing commands used in @//...
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/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/_main/../hedron_compile_commands~/refresh_all.check_python_version.py", line 15, in <module>
    refresh_all.main()
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/hedron_compile_commands~/refresh_all.py", line 1417, in main
    compile_command_entries.extend(_get_commands(target, flags))
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/hedron_compile_commands~/refresh_all.py", line 1279, in _get_commands
    yield from _convert_compile_commands(parsed_aquery_output)
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/hedron_compile_commands~/refresh_all.py", line 1159, in _convert_compile_commands
    for source_files, header_files, compile_command_args in outputs:
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/external/rules_python~~python~python_3_12_x86_64-unknown-linux-gnu/lib/python3.12/concurrent/futures/_base.py", line 619, in result_iterator
    yield _result_or_cancel(fs.pop())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/external/rules_python~~python~python_3_12_x86_64-unknown-linux-gnu/lib/python3.12/concurrent/futures/_base.py", line 317, in _result_or_cancel
    return fut.result(timeout)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/external/rules_python~~python~python_3_12_x86_64-unknown-linux-gnu/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/external/rules_python~~python~python_3_12_x86_64-unknown-linux-gnu/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/external/rules_python~~python~python_3_12_x86_64-unknown-linux-gnu/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/hedron_compile_commands~/refresh_all.py", line 1123, in _get_cpp_command_for_files
    source_files, header_files = _get_files(compile_action)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vividivision/.cache/bazel/_bazel_vividivision/1800c18f5c7d55c42ae1b08d6982ff30/execroot/_main/bazel-out/k8-fastbuild/bin/external/hedron_compile_commands~/refresh_all.runfiles/hedron_compile_commands~/refresh_all.py", line 627, 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/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh', '-xc++-header', '-fsyntax-only', '-U_FORTIFY_SOURCE', '-fstack-protector', '-Wall', '-Wunused-but-set-parameter', '-Wno-free-nonheap-object', '-fno-omit-frame-pointer', '-std=c++14', '-MD', '-MF', 'bazel-out/k8-fastbuild/bin/external/abseil-cpp~/absl/strings/_objs/strings/ascii.h.d', '-iquote', 'external/abseil-cpp~', '-iquote', 'bazel-out/k8-fastbuild/bin/external/abseil-cpp~', '-w', '-fPIC', '-O3', '-std=c++20', '-Wall', '-Wextra', '-Wcast-qual', '-Wconversion-null', '-Wformat-security', '-Wmissing-declarations', '-Woverlength-strings', '-Wpointer-arith', '-Wundef', '-Wunused-local-typedefs', '-Wunused-result', '-Wvarargs', '-Wvla', '-Wwrite-strings', '-DNOMINMAX', '-Wno-builtin-macro-redefined', '-D__DATE__="redacted"', '-D__TIMESTAMP__="redacted"', '-D__TIME__="redacted"', '-c', 'external/abseil-cpp~/absl/strings/ascii.h', '-o', 'bazel-out/k8-fastbuild/bin/external/abseil-cpp~/absl/strings/_objs/strings/ascii.h.processed'].
Please file an issue with this information!

If I remove googletest//:gtest form the dependencies, the refresh_command does not fail.

thoughts?

EDIT: just verified that even a simple gtest makes the refresh_command fail.

@stonebrakert6
Copy link

+1
Facing the same problem 226

@xFile3160
Copy link
Author

I can confirm:
with latest bazel if I do:

bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
    module_name = "hedron_compile_commands",
    remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
    commit = "f5fbd4cee671d8d908f37c83abaf70fba5928fc7",
)

Taking the commit sha id of #219

The issue is solved.

Thanks @stonebrakert6 for flagging

@xFile3160 xFile3160 reopened this Oct 8, 2024
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

No branches or pull requests

2 participants