commit | cc61dad19e74a1c2cf3cc14fc27aa769c312501b | [log] [tgz] |
---|---|---|
author | Devin Jeanpierre <jeanpierreda@google.com> | Tue Jul 19 01:40:09 2022 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Tue Jul 19 01:40:48 2022 -0700 |
tree | 30c698a9f47044e947cafb7fbce22b94a06a6463 | |
parent | c4fa436a2e3cda66440d67dd29e409e563d5c539 [diff] |
Mark classes as `final` in the tests and goldens. These I think were meant to be `final`, and their output was incorrect: when we correctly support non-`final` classes, the interfaces here will change to accept `impl Ctor<Output=T>`, not `T` itself. --- A quick reminder why (since I often forget the details myself): `Pin<&mut T>` has a [`set(T)` method](https://doc.rust-lang.org/std/pin/struct.Pin.html#method.set), and base classes aren't safe to Rust-assign to (including via `set()`). This is true both because Rust-assignment destroys the target (UB for a base class), but also because Rust-assignment overwrites `sizeof(T)` bytes, and derived classes can live inside of that span (e.g. via [EBO](https://en.cppreference.com/w/cpp/language/ebo), though it's more general than that). Because set exists, but must never be called, we forbid access to the raw `T` type. This ends up being the same as how we treat trivially relocatable functions. (However, note that this decision is reversible if we choose to stop using `Pin`.) And so, even though it would obviously be safe to use a `T` by value in by-value parameters or return types, we forbid it anyway, because it would allow for unsafe behavior when you have references. This explanation will become more salient with the followup change, which actually implements pass-by-value for `!Unpin` types (including non-`final` types). Woo! PiperOrigin-RevId: 461824564
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