Are cc_library hdrs irrelevant in Bazel 4.0?

79 views
Skip to first unread message

carpen...@gmail.com

unread,
Jun 22, 2021, 8:07:41 AM6/22/21
to bazel-discuss
Hi, 

With Bazel 4.0 if I have two cc_library(s) (A->B), but no where do I export any headers. Then I do I expect a warning to say that you haven't got a dependency on that header anymore, or has is the hdrs declaration of a public interface now obsolete? 

This is a minimal example:

A\BUILD
```
cc_library(
    name="a",
    srcs=["final.cpp"],
    deps=[
        "//b"
    ]
)
```
A\final.cpp
```
#include "b/item.h"
```

B\BUILD 
```
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "b",
    srcs = [
        "item.cpp",
        "item.h",
    ],
    visibility = ["//visibility:public"],
)

```
B/item.h 
```
```
B/item.cpp
```
#include "item.h"
```

I expect to get a warning as this is not a declared header, but instead it seems to work fine.
Does bazel now track these files? 
Will A be guaranteed to rebuild when you have reproducible builds and the B/B.lib is the same checksum, even if `B/item.h` changes checksum?

Thanks

James

Tobias Werth

unread,
Jun 22, 2021, 8:27:01 AM6/22/21
to carpen...@gmail.com, Pedro Liberal Fernandez, bazel-discuss

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/c2a88fd4-9f5b-40c7-b91b-9edb6f09be6dn%40googlegroups.com.

p...@google.com

unread,
Jun 22, 2021, 8:46:04 AM6/22/21
to bazel-discuss
Which header is undeclared? The only header I see is declared in "b" and that is available to "a".

carpen...@gmail.com

unread,
Jun 22, 2021, 9:38:38 AM6/22/21
to bazel-discuss
"B/item.h" is undeclared and is available to B only according to the documentation as its a private header. I don't have anything in the  hdrs section of B.

If I put no dependency between A and B then it fails the header inclusion check, but not when A uses a private header of B. 



Xavier Bonaventura

unread,
Aug 10, 2021, 3:04:39 AM8/10/21
to bazel-discuss
Hi James,

I think what you describe is exactly what is being discussed in this ticket

Bests,

Xavi

Reply all
Reply to author
Forward
0 new messages