Closed tylerhawkes closed 4 years ago
What are the exact version of cpp and cpp_build crates being used? Make sure this is the exact same version. Maybe using cargo update
is needed.
The versions of cpp, cpp_macros, cpp_common, and cpp_build are all 0.5.4. I checked that before posting since it indicates it might be the issue.
I also encountered this problem, `pub fn run(wrapper_ptr: &dyn WrapperTrait) { // let name = std::ffi::CString::new(name).unwrap(); // let name_ptr = name.as_ptr();
// let source = std::ffi::CString::new(source).unwrap(); // let source_ptr = source.as_ptr(); unsafe { // cpp!([wrapper_ptr as "Holder"] { // run(Holder()); // })
cpp!([]{
}) } } `
`error: proc-macro derive panicked --> src\v8\core.rs:86:2 | 86 | / cpp!([]{ 87 | 88 | }) | ___^ |
---|
= help: message: -- rust-cpp fatal error --
Struct metadata not present in target library file.
NOTE: Double-check that the version of cpp_build and cpp_macros match
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error ` Cargo.toml [dependencies] console = "0.9.1" clap = "2.33" winreg = "0.6" cpp = "0.5" xml-rs = "0.8" winapi = "0.3" lazy_static = "1.4" log = "0.4" env_logger = "0.7"
[build-dependencies] cpp_build = "0.5.4"
when i restore code
unsafe { cpp!([wrapper_ptr as "Holder"] { native_run(wrapper_ptr); })
and delete the code below
`
cpp!([]{
}) `
when i compiled again .it's success。 so weird.
I just found this issue while encountering the same problem. The code in question is from the lldb-vscode plugin but running FreeBSD 12.1 so most likely this works on other platforms but haven't checked yet. Crates for cpp, cpp_macros, cpp_common, and cpp_build are at 0.5.4 as well.
The code is as follows:
use super::*;
cpp_class!(pub unsafe struct SBAddress as "SBAddress");
unsafe impl Send for SBAddress {}
impl SBAddress {
pub fn from_load_address(addr: u64, target: &SBTarget) -> Self {
cpp!(unsafe [addr as "addr_t", target as "SBTarget*"] -> SBAddress as "SBAddress" {
return SBAddress(addr, *target);
})
}
pub fn file_address(&self) -> usize {
cpp!(unsafe [self as "SBAddress*"] -> usize as "size_t" {
return self->GetFileAddress();
})
}
pub fn load_address(&self, target: &SBTarget) -> u64 {
cpp!(unsafe [self as "SBAddress*", target as "SBTarget*"] -> u64 as "uint64_t" {
return self->GetLoadAddress(*target);
})
}
pub fn offset(&self) -> usize {
cpp!(unsafe [self as "SBAddress*"] -> usize as "size_t" {
return self->GetOffset();
})
}
pub fn line_entry(&self) -> Option<SBLineEntry> {
cpp!(unsafe [self as "SBAddress*"] -> SBLineEntry as "SBLineEntry" {
return self->GetLineEntry();
})
.check()
}
pub fn symbol(&self) -> Option<SBSymbol> {
cpp!(unsafe [self as "SBAddress*"] -> SBSymbol as "SBSymbol" {
return self->GetSymbol();
})
.check()
}
pub fn get_description(&self, description: &mut SBStream) -> bool {
cpp!(unsafe [self as "SBAddress*", description as "SBStream*"] -> bool as "bool" {
return self->GetDescription(*description);
})
}
}
The output I'm getting with "-Zexternal-macro-backtrace" enabled:
error: proc-macro derive panicked
--> <::cpp::__cpp_class_internal macros>:7:21
|
1 | / (@ parse [$ ($ attrs : tt) *] [$ ($ vis : tt) *]
2 | | [unsafe struct $ name : ident as $ type : expr]) =>
3 | | {
4 | | __cpp_class_internal !
... |
7 | | [# [derive (__cpp_internal_class)] # [repr (C)] $ ($ vis) * struct $
| | ^^^^^^^^^^^^^^^^^^^^
... |
52 | | [$ ($ attributes) * # [derive ($ i)]] [$ ($ result) *]
53 | | }) ;
| |______- in this expansion of `__cpp_class_internal!`
|
::: adapter2/deps/lldb/src/sbaddress.rs:4:1
|
4 | cpp_class!(pub unsafe struct SBAddress as "SBAddress");
| ------------------------------------------------------- in this macro invocation
|
::: <::cpp::cpp_class macros>:1:1
|
1 | / ($ (# [$ ($ attrs : tt) *]) * unsafe struct $ name : ident as $ type : expr)
2 | | =>
3 | | {
4 | | __cpp_class_internal !
... |
10 | / | __cpp_class_internal !
11 | | | {
12 | | | @ parse [$ (# [$ ($ attrs) *]) *] [pub]
13 | | | [unsafe struct $ name as $ type]
14 | | | }
| |_|_____- in this macro invocation
... |
23 | | }
24 | | } ;
| |___- in this expansion of `cpp_class!`
|
= help: message:
-- rust-cpp fatal error --
Struct metadata not present in target library file.
NOTE: Double-check that the version of cpp_build and cpp_macros match
error: aborting due to previous error
Is there anything I can double-check or any more info I can provide to help solve this? Another thing I tried was pulling the source for this project and building it then running the tests and all of those pass just fine.
Cargo is at 1.42.0-nightly and rustc is at 1.43.0-nightly. I also ran cargo upgrade.
weird..it built when I changed this:
cpp! {{
#include <lldb/API/LLDB.h>
using namespace lldb;
}}
to this:
cpp! {{
#include "lldb/API/LLDB.h"
using namespace lldb;
}}
So i guess in my case the error meant what it said and then afterward had to do: cargo clean cargo build
It doesn't like the angle brackets there for the include? Between this project and the other that was the only difference with how it imports stuff.
Looks like cpp_build does not tell cargo track changes in files other that the root of the crate?
Manually emitting cargo:rerun-if-changed=...
for all files in the crate seems to help (well, perhaps just the files using cpp! macro would suffice).
I was able to reproduce the problem in one of my project, it appears that there is a bug in the aho-corasick which makes finding the metadata not working depending on the offset of the metadata in the binary file: https://github.com/BurntSushi/aho-corasick/issues/64
The aho-corasick bug that was causing this problem has been fixed in 0.7.14 so i'm gonna close this one.
I'm building tflite 0.7.0 and I got this error:
I've included the generated files. I'm using g++, gcc, cc, and c++ versions 9.1.1 on a fedora docker image. Interestingly enough, this doesn't happen in the travis ci builds which is also on x86_64-unknown-linux-gnu or if I cross compile for aarch64-unknown-linux-gnu using the linaro 7.4.1-2019.02 toolchain.
rust_cpp.tar.gz