Open jbaublitz opened 1 year ago
Some notes on Android:
I have a device mapper use case on android targets (aarch64-linux-android
). The catchup with various crates that rely on bindgen stuff is major pain. Also for device mapper. My standard way of building for android is cross that comes with a Docker container for android rust builds. The latest version doesn't include libdevmapper.h
(none does) which makes totally sense because normally an application developer would never need to use it in applications (and isn't allowed to). Same story applies for e.g binder
.
Compiling devicemapper-sys v0.1.5
error: failed to run custom build command for `devicemapper-sys v0.1.5`
Caused by:
process didn't exit successfully: `/target/debug/build/devicemapper-sys-abb148ccab8c3f94/build-script-build` (exit status: 101)
--- stderr
dm.h:2:10: fatal error: 'libdevmapper.h' file not found
thread 'main' panicked at 'Could not generate dm.h bindings: ClangDiagnostic("dm.h:2:10: fatal error: 'libdevmapper.h' file not found\n")', /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/devicemapper-sys-0.1.5/build.rs:24:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `devicemapper-sys v0.1.5`
Caused by:
process didn't exit successfully: `/target/debug/build/devicemapper-sys-abb148ccab8c3f94/build-script-build` (exit status: 101)
--- stderr
dm.h:2:10: fatal error: 'libdevmapper.h' file not found
thread 'main' panicked at 'Could not generate dm.h bindings: ClangDiagnostic("dm.h:2:10: fatal error: 'libdevmapper.h' file not found\n")', /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/devicemapper-sys-0.1.5/build.rs:24:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
A cross build that uses bindgen
is always interesting because the toolchain headers need to exactly match the target ones. My guess is, that in a lot of cases this is not the case we're all just lucky that Linux API don't change that dramatically and things just work (TM).
For checking this crate for android you would a NDK + libdm which you don't get off the shelf (or revert https://github.com/stratis-storage/devicemapper-rs/commit/d66efa4c73ac8afd1e1bc2139f3159504baa028e#diff-fdb00b839f512eccbbdb64f45536cba6b07e26a3da7b432dbf37cf6ab5248aaf. Building such a container is not straight forward - I don't have one and decided to fork the android dm (verity) parts.
@flxo Would a solution like stratis-storage/libcryptsetup-rs#278 solve your problem too?
@flxo Would a solution like stratis-storage/libcryptsetup-rs#278 solve your problem too?
Sorry for the late reply.
No - because libdevmapper.h
doesn't exist in the cross sysroot in my case (android
) there's no -I
to add.
It's a little bit unclear to me how to best approach this for all required uses cases in bindgen.
Sub issues: