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

Handle cross compilation in our -sys libraries #583

Open
jbaublitz opened this issue Mar 1, 2023 · 3 comments
Open

Handle cross compilation in our -sys libraries #583

jbaublitz opened this issue Mar 1, 2023 · 3 comments
Assignees

Comments

@jbaublitz
Copy link
Member

It's a little bit unclear to me how to best approach this for all required uses cases in bindgen.

Sub issues:

@jbaublitz jbaublitz self-assigned this Mar 1, 2023
@flxo
Copy link

flxo commented Mar 20, 2023

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 stratis-storage/devicemapper-rs@d66efa4#diff-fdb00b839f512eccbbdb64f45536cba6b07e26a3da7b432dbf37cf6ab5248aaf.
Building such a container is not straight forward - I don't have one and decided to fork the android dm (verity) parts.

@jbaublitz
Copy link
Member Author

@flxo Would a solution like stratis-storage/libcryptsetup-rs#278 solve your problem too?

@flxo
Copy link

flxo commented Sep 13, 2023

@flxo Would a solution like stratis-storage/libcryptsetup-rs#278 solve your problem too?

Sorry for the late reply.

No - because libdevmapper.hdoesn't exist in the cross sysroot in my case (android) there's no -Ito add.

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

No branches or pull requests

2 participants