commit | 7571ece6bb1447d2ae8963e9cc4c7c5025440b41 | [log] [tgz] |
---|---|---|
author | Devin Jeanpierre <jeanpierreda@google.com> | Fri Jan 13 11:39:26 2023 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Fri Jan 13 11:40:02 2023 -0800 |
tree | 97415940db443754473a1dc1abf739a993946a90 | |
parent | 60386e948dbeeeb7e39362e2756a18ddd2a686ba [diff] |
If a header is in multiple targets, take it as part of the first target (lexicographically). This is not Good Behavior. In particular, this means that adding a dependency can break Rust callers. Consider the following: ```cc //h1.h struct S {}; ``` ```cc //h2.h void Foo(S s); ``` with this BUILD file: ```py cc_library(name="h1_a", hdrs=["h1.h"], ...) cc_library(name="h1_b", hdrs=["h1.h"], ...) cc_library(name="h2_a", hdrs=["h2.h"], deps=[":h1_a"]) cc_library(name="h2_b", hdrs=["h2.h"], deps=[":h1_b"]) cc_library(name="h2_ab", hdrs=["h2.h"], deps=[":h1_a", ":h1_b"]) ``` Then: * `h2_a` contains `fn Foo(s: h1_a::S);` * `h2_b` contains `fn Foo(s: h2_a::S);` * `h2_ab` contains `fn Foo(s: h1_a::S);` Meaning that adding a single (TRANSITIVE) dependency can accidentally change the type of your parameters, breaking Rust callers -- a caller who was passing `h2_a::S` would get broken if a transitive dependency on `h1_a` were added. But note: without this CL, we're even _worse_ off, because that same transitive dependency breaks the build entirely, and there is no way to resolve it. After this CL, there is a quick fix: use `h1_a::S`. --- Alternatives considered: * We could fix all headers everywhere to have a single canonical build target, but this is a big task. We do likely want to do it eventually, but it shouldn't block early adopters from trying Crubit. --- It's worth noting that with the proposed[] PiperOrigin-RevId: 501900537
Extremely experimental interop tooling for C++ and Rust.
Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.
$ apt install clang lld bazel $ git clone git@github.com:google/crubit.git $ cd crubit $ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl
$ git clone https://github.com/llvm/llvm-project $ cd llvm-project $ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install $ cmake --build build -j $ # wait... $ cmake --install build $ cd ../crubit $ LLVM_INSTALL_PATH=../llvm-project/install bazel build //rs_bindings_from_cc:rs_bindings_from_cc_impl