-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
"strict transitive dependency mode" not work ? #15632
Comments
Hello @daohu527, Can you provide more details to reproduce the above problem. Thanks! |
I modified https://github.com/bazelbuild/examples/tree/main/cpp-tutorial/stage3 as an example. as you see additional, cpp-tutorial/stage3/main/BUILDload("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
cc_library(
name = "hello-greet",
srcs = ["hello-greet.cc"],
hdrs = ["hello-greet.h"],
deps = [
"//lib:hello-time",
],
)
cc_binary(
name = "hello-world",
srcs = ["hello-world.cc"],
deps = [
":hello-greet",
],
) cpp-tutorial/stage3/main/hello-world.cc#include "lib/hello-time.h"
#include "main/hello-greet.h"
#include <iostream>
#include <string>
int main(int argc, char** argv) {
std::string who = "world";
if (argc > 1) {
who = argv[1];
}
std::cout << get_greet(who) << std::endl;
// print_localtime();
return 0;
} |
Strict deps checking for C++ on that level of granularity requires passing the flag |
yes, it thrown out an error like below.
Then my question is, since bazel lets users use |
@daohu527 This project of mine might be interesting for you: https://github.com/martis42/depend_on_what_you_use It aims at linting the usage of headers in Bazel C++ targets compared to the targets dependency list. It is still in an early phase, but maybe it can help you. |
@martis42 Thanks for your work, I will check out this project in detail ! |
The `layering_check` feature and toolchain support are required to realize header dependency checking in Bazel. If enabled, this also reports errors for explicitly included transitive, non-direct headers. Fixes #17055 Fixes #15632 Closes #17057. PiperOrigin-RevId: 499189567 Change-Id: Ia7978193e4572a358e26d24183d125649f8654b9
Description of the bug:
Suppose there is the following dependency a->b->c, a contains the header file of c, but does not use anything, then a's build file depends on b, but not on c. Then this forms an implicit dependency, and bazel will not report a error!
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
No response
Which operating system are you running Bazel on?
ubuntu 18.04
What is the output of
bazel info release
?(11:37:20) INFO: Invocation ID: b93b0d49-edac-4215-9d9a-366bf997e477 release 3.7.1
If
bazel info release
returnsdevelopment 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
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: