Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse of shared structs containing String #551

Closed
alexeyr opened this issue Dec 8, 2020 · 2 comments · Fixed by #560
Closed

Reuse of shared structs containing String #551

alexeyr opened this issue Dec 8, 2020 · 2 comments · Fixed by #560

Comments

@alexeyr
Copy link

alexeyr commented Dec 8, 2020

It seems I am still getting something wrong about #297. Here I am trying to reuse a shared struct instead of declaring it the second time and get

  running: "E:\\VisualStudio\\VC\\Tools\\MSVC\\14.26.28801\\bin\\HostX64\\x64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "E:\\MyProgramming\\tokenizers\\bindings\\cpp\\target\\debug\\build\\tokenizers-cpp-348e1825e6b8d85d\\out\\cxxbridge\\include" "-I" "E:\\MyProgramming\\tokenizers\\bindings\\cpp\\target\\debug\\build\\tokenizers-cpp-348e1825e6b8d85d\\out\\cxxbridge\\crate" "-I" "." "-I" "target/cxxbridge/tokenizers-cpp" "-I" "thirdparty" "-W4" "/std:c++14" "/EHsc" "-FoE:\\MyProgramming\\tokenizers\\bindings\\cpp\\target\\debug\\build\\tokenizers-cpp-348e1825e6b8d85d\\out\\cxxbridge\\sources\\tokenizers-cpp\\tokenizers-cpp\\processors.rs.o" "-c" "E:\\MyProgramming\\tokenizers\\bindings\\cpp\\target\\debug\\build\\tokenizers-cpp-348e1825e6b8d85d\\out\\cxxbridge\\sources\\tokenizers-cpp\\tokenizers-cpp\\processors.rs.cc"
  processors.rs.cc
  E:\MyProgramming\tokenizers\bindings\cpp\target\cxxbridge\tokenizers-cpp\tokenizers-cpp/processors.rs.h(198): error C2338: type ::huggingface::tokenizers::ffi::KVStringU32 marked as Trivial in Rust is not trivially move constructible and trivially destructible in C++     
  E:\MyProgramming\tokenizers\bindings\cpp\target\debug\build\tokenizers-cpp-348e1825e6b8d85d\out\cxxbridge\sources\tokenizers-cpp\tokenizers-cpp\processors.rs.cc(251): error C2338: type ::huggingface::tokenizers::ffi::KVStringU32 marked as Trivial in Rust is not trivially 
move constructible and trivially destructible in C++
  exit code: 2

  --- stderr

  CXX include path:
    E:\MyProgramming\tokenizers\bindings\cpp\target\debug\build\tokenizers-cpp-348e1825e6b8d85d\out\cxxbridge\include
    E:\MyProgramming\tokenizers\bindings\cpp\target\debug\build\tokenizers-cpp-348e1825e6b8d85d\out\cxxbridge\crate

The only potentially significant difference from #465 that I can see on my own is that I include!("tokenizers-cpp/models.h"); and not .rs.h; but trying to change that adds a lot more errors and doesn't fix this one.

Hopefully the commit introducing the error is small enough; if not, I can try to create a smaller case reproducing it.

@alexeyr
Copy link
Author

alexeyr commented Dec 8, 2020

Ah, the problem is that it contains a String, and is never actually passed by value in models, but only in processors . Is that right?

@alexeyr
Copy link
Author

alexeyr commented Dec 8, 2020

It looks like the problem can be fixed by adding

template <>
struct IsRelocatable<MyStruct> : std::true_type {};

If I understand IsRelocatable, this should be safe, and can be generated for any shared struct containing String; and for shared structs containing Vec<SomethingElse>,

template <>
struct IsRelocatable<MyStruct> : IsRelocatable<SomethingElse>::value {};

(approximately). If this is correct, I can make a pull request.

@alexeyr alexeyr changed the title Shared struct reuse question Reuse of shared structs containing String Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant