1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -109,7 +109,7 @@
path = "src/lib.rs"
[build-dependencies.bindgen]
-version = "0.70"
+version = ">= 0.70, < 1.0"
[build-dependencies.cc]
version = "1"
--- a/build.rs
+++ b/build.rs
@@ -315,7 +315,10 @@
}
}
+use std::io::Write;
fn generate_bindings(target: &str, sysroot: Option<&Path>, out_dir: &Path, include_path: &Path) {
+ let target = if std::env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "riscv64" { "riscv64-unknown-linux-gnu" } else { target };
+
let mut builder = bindgen::Builder::default()
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.default_enum_style(bindgen::EnumVariation::ModuleConsts)
@@ -391,9 +394,17 @@
"selinux-sys: Failed to generate Rust bindings for 'selinux/selinux.h' and other headers",
);
- bindings
- .write_to_file(out_dir.join("selinux-sys.rs"))
- .expect("selinux-sys: Failed to write 'selinux-sys.rs'")
+ // __uint64_t is excluded from the bindings, but on time64 architectures the glibc
+ // headers use it to define ino_t. Replace any reference to it in the generated
+ // bindings with u64.
+ let mut bindingstext = Vec::new();
+ bindings.write(Box::new(&mut bindingstext)).unwrap();
+ let bindingstext = str::from_utf8(&bindingstext).unwrap();
+ let bindingstext = bindingstext.replace("__uint64_t","u64");
+ let mut file = std::fs::File::create(out_dir.join("selinux-sys.rs")).expect("selinux-sys: Failed to open 'selinux-sys.rs'");
+ file.write_all(bindingstext.as_bytes()).expect("selinux-sys: Failed to write data to 'selinux-sys.rs'");
+ drop(file);
+
}
fn find_file_in_dirs(path_suffix: &str, dirs: &[PathBuf]) -> io::Result<PathBuf> {
|