bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.97k stars 4.03k forks source link

Can't determine which target(s) have failed by parsing log with --keep_going #23196

Open peakschris opened 1 month ago

peakschris commented 1 month ago

Description of the bug:

We run builds with --keep_going. Errors are reported as:

ERROR: <snip>/src/main/BUILD.bazel:20:13: Linking src/main/test_link_error.exe failed: (Exit 1120): link.bat failed: error executing CppLink command (from target //src/main:test_link_error) external\our_toolchain+\toolchain\x64-windows\14.29.30133\link.bat @bazel-out/x64_windows-opt/bin/src/main/test_link_error.exe-2.params
test_link_error.obj : error LNK2019: unresolved external symbol "int __cdecl not_defined(void)" (?not_defined@@YAHXZ) referenced in function main
bazel-out\x64_windows-opt\bin\src\main\test_link_error.exe : fatal error LNK1120: 1 unresolved externals
INFO: From Compiling src/main/test_compile_error.cxx:
src/main/test_compile_error.cxx(9): error C3861: 'not_declared': identifier not found
ERROR: <snip>/src/main/BUILD.bazel:11:13: output 'src/main/_objs/test_compile_error/test_compile_error.obj' was not created
ERROR: <snip>/src/main/BUILD.bazel:11:13: Compiling src/main/test_compile_error.cxx failed: not all outputs were created or valid

Errors are reported with a BUILD.bazel line number, which I can correlate to a target with bazel query //... --output location

However, if a target is defined inside a bzl macro, multiple targets map to a single BUILD.bazel line number, and I cannot reliably distinguish which one has failed.

Some errors include the text (from target //src/main:test_link_error) but this does not appear to be consistent.

The ask is for a standard reliable way to identify failed target in a logged ERROR message.

If I'm missing an option that would give me this, it would be really helpful to know, thanks!

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a C++ repo with two targets, one that fails with compile error and one with link error. Compile both with bazel build //... --keep_going.

I can provide a minimal example if needed.

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

7.3.0rc1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

meteorcloudy commented 1 month ago

Is this a regression in 7.3.0rc1, if so, can you help bisect which commit caused this?

I can provide a minimal example if needed.

This would be helpful!

comius commented 3 weeks ago

I reassigned to team-performance, becuase they probably have the most experience with --keep_going (and it seems to be a general problem, not specific to C++)