When cc rules depend on objc_library, headers of transitive dependencies are dropped #10738
Labels
P4
This is either out of scope or we don't have bandwidth to review a PR. (No assignee)
team-Rules-CPP
Issues for C++ rules
type: bug
Hi wonderful Bazel folk,
I'm pretty sure I've found a bug in the interaction between
cc
rules andobjc_library
, which makes them hard to use together in meaningfully sized dependency graphs.Offhand, my guess is that the fix would need to be on the
cc
side.Background:
C-style language rules (
cc_library
,objc_library
, etc.) need to propagate theirhrs
to all rules that might transitively#include
them. In practice, that means that thehrs
need to be propagated to all c-style rules that depend on them, transitively or directly. In Bazel, this already works whencc
rules depend on each other, whenobjc
rules depend on each other, and whenobjc
rules depend oncc
rules.The Issue
The case that's broken is
cc
rules depending onobjc
rules. Thehdrs
of theobjc
rules' dependencies get dropped, and the build fails when thecc
rule tries to#include
on the the headers of anobjc
rule that#includes
its dependencies.Here's a minimal example of the issue.
Test.zip
#include
s B.h, which#include
s C.hNow we'll try building
//:A
:bazel build A
:If A, B, and C are all
cc_library
s, this works. Same if they're allobjc_libraries
.All the following cases work as expected:
These two cases are broken (project left configured in the first of these cases):
In both cases, building fails with the error
My conclusion
cc
rules seem to fail to pick up thehdrs
of thedeps
ofobjc
rules. (Other cases work as expected.) This happens whether those dependencies arecc
rules orobjc
rules. The expected behavior would be thatobjc
rules would propagate thehdrs
of theirdeps
the same way ascc
rules do, orobjc
rules do with each other.Severity
You can work around this issue, but it's fairly ugly. This issue would come up whenever someone uses an objc_library to bridge from C/C++ into a meaningfully-sized Objective-C or Objective-C++ implementation, as happens with cross-platform code with a backend for Apple platforms.
Thanks,
Chris
(ex-Googler)
The text was updated successfully, but these errors were encountered: