commit | 69fe2397cd45e89f153e2152ea67a85469af7908 | [log] [tgz] |
---|---|---|
author | Devin Jeanpierre <jeanpierreda@google.com> | Tue Oct 04 22:01:24 2022 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Tue Oct 04 22:01:57 2022 -0700 |
tree | 53d19b9dc8bfa223845b35bbac17f61c6f6effcf | |
parent | d5a53624597d342bf8b3f8075a9b4cf4122a8cbf [diff] |
Allow function pointers with references inside the function signature. Without this change, because we change the reference to a pointer, the type doesn't line up: ``` error: cannot initialize return object of type 'crubit::t ype_identity_t<int *(const int *, int *)> *' (aka 'int *(*)(const int *, int *)') with an rvalue of type 'int &(*)(const int &, int *)': type mismatch at 1st parameter ('const int *' vs 'const int &') ``` I was worried this would mean we'd have trouble with `-Wreturn-type-c-linkage`, but surprisingly, it works fine: https://godbolt.org/z/njabjEfTK (As you can see, and as the name implies, it also works fine with reference parameters, but presumably there's another warning that fails there.) I didn't add any other tests because really "does it compile?" is the main thing. This failed before, succeeds now. PiperOrigin-RevId: 478958712
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