-
Notifications
You must be signed in to change notification settings - Fork 30
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
DM version detection broken when cross compiling #801
Comments
I didn't find a way to tell build What do you think? |
@flxo Is it reasonable to assume that the correct dm-ioctl.h contents is somehow provided by the cross-toolchain and that our build script is just not looking in the correct place? Or does it make sense to allow specifying an alternative location for the dm-ioctl.h file during the build process? |
@mulkieran The cross toolchain is not used when the bindings are generated the first time (for version detection) and the correct header is not available.
|
@flxo After looking into this a little bit, would .clang_arg(format!("target={}", env!("TARGET")).as_str()) work in bindgen? |
I don't think so because the host toolchain is used and not the one for the target. This approach would require to setup the full cross compile foo in the build script - e.g search for clang etc. The problem is that we need the target headers. |
I see two options. The first I'm less sure about. I know a little bit less about cross compilation than other domains of cargo so I'm not sure how realistic this is, but I could file an upstream bug to have cargo respect the cross compile target in its build-dependencies. The piece I'm not sure about is I would expect the build-dependencies to have to run on the host so I could see this potentially rendering the build-dependencies unrunable. However, the The second option I see is generating the low level bindings in devicemapper-rs as well just for version detection and removing devicemapper-rs-sys as a build dependency. Because the target is set appropriately in devicemapper-rs's build script, I think this should work. What are your thoughts? |
Think it's not only about setting
Hm. That should be a workaround. But isn't the problem we're discussing here a general one for every |
@flxo I think this is a more general problem. I've created a tracking issue for all of our I feel like I'm still misunderstanding a little bit what exactly you want. Are you saying you want to cross compile without having all of the target headers installed? Are you saying you have all of the target headers installed but in the current state of things, devicemapper-rs is using the host headers? I think I need a little bit more concrete information about what your desired state is. I may need to read up a little bit more on cross compilation in Rust because I'm not as familiar with this domain as other parts of the toolchain. |
The build script uses
device-mapper-sys
for the dm version detection. The dependency is declared here.What happens, is that the
TARGET
is set to the host target - the machine that is used for building. The result is thatbindgen
in the device-mapper-sys build script uses the hostsdm-ioctl.h
header in instead of the one (probably) in the cross toolchain in use. If the headers differ a wrong version is detected. In my case accidently441
is assumed but the later build fails because aDM_GET_TARGET_VERSION_CMD
is missing because during the later cross buildTARGET
is correct.I verified with a
rustc:warning
in thedevice-mapper-sys
build script:Then a random cross compile reveals:
A solution must tell the build script in the dependency (device-mapper-sys) that
TARGET
is something different. This is the classic "build script is not cross compiled problem".The text was updated successfully, but these errors were encountered: