Reputation: 1526
I generated bindings to Microsoft SEAL C++ Library using the rust-bindgen tool.
My config:
// Generate the bindings
let bindings = bindgen::Builder::default()
.generate_inline_functions(true)
.derive_default(true)
.header("./seal/src/seal/seal.h")
.clang_arg("-I./seal/src/")
.clang_arg("-std=c++17")
.clang_arg("-x")
.clang_arg("c++")
.opaque_type("std::.*")
.whitelist_type("seal::.*")
.whitelist_function("seal::.*")
.generate()
.expect("Unable to generate bindings");
The SEAL project is compiled using cc-rs using this config:
let mut build = cc::Build::new();
build.cpp(true);
build.flag_if_supported("-std=c++17");
build.flag_if_supported("-march=native");
build.flag_if_supported("-fkeep-inline-functions");
build.flag_if_supported("-fno-inline-functions");
let base_path = Path::new("./seal/src/seal/");
let util_base_path = Path::new("./seal/src/seal/util/");
add_cpp_files(&mut build, base_path);
add_cpp_files(&mut build, util_base_path);
build.include("./seal/src");
build.compile("seal");
But afterwards, when creating a new context (this is mostly SEAL-specific) using a static method I get a segmentation fault (SIGSEGV: invalid reference) which, I figured after debugging with gdb
comes from when a pointer to a memory pool is copied.
I was able to instantiate multiple regular objects (stuff that didn't have a static constructor) but it doesn't seem to work for SEALContext no matter what parameters I try.
You can access my project seal-rs here. The whole thing is in the build script and clones the repo so cargo test
should build and reproduce the error.
My OS is Archlinux 64bit, the compiler used is clang 7.
Upvotes: 1
Views: 383
Reputation: 1526
This is caused by a bug in the rust-bindgen library as such I will close the question.
Upvotes: 0