bazel: cc_libaray target won't be rebuilt when header files are modified

Description of the bug:

cc_libaray target won’t be rebuilt when header files list in hdrs attr are modified.

Which category does this issue belong to?

C++/Objective-C Rules

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

Create a target with a c++ header file and a c++ source file:


cc_library(
    name = "my_lib",
    hdrs = ["my_lib.hpp"],
)

cc_binary(
    name = "main",
    srcs = ["main.cpp"],
    deps = ["my_lib"]
)

my_lib.hpp content:

#include <string>

struct MyLib {
  std::string value = "my_lib";
};

main.cpp content:

#include <iostream>
#include "my_lib.hpp"

int main(){
  MyLib obj;
  std::cout << obj.value << std::endl;
  return 0;
}

Run bazel run my_lib. and modify my_lib.hpp to set default value of MyLib::value to another string (do not modify the main.cpp), run bazel run my_lib again. We will get a same output as the target will not be rebuilt.

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

6.3.2

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 master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

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

Note that I test all release version from 6.1.1 to 6.3.2, This bug exists in version 6.2.0 and later versions, but 6.1.1 ~ 6.1.2 works well.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@dhmemi after you uninstall the english pack, did you re-fetch the cc toolchain? You can do that by bazel clean --expunge first.

My omission, after run bazel clean --expunge, warning message prints correctly.

If we set VSLANG and the user doesn’t have English language pack installed, will the build fail?

No, it will silently fall back to an available locale. I am working on a fix.

@dhmemi Are you still pushing this to be part of 6.4.0? The expected first release candidate date is next Monday (9/18/2023), just FYI. Thanks!

No, According to https://github.com/bazelbuild/bazel/discussions/19451, I solved the problem temporarily by installing English language package in VS and adding the environment variable VSLANG.

@bazel-io fork 6.4.0