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

cross compiling using bindgen under x86_64, but requires 32 bit #75

Closed
sprhawk opened this issue Jun 21, 2020 · 9 comments
Closed

cross compiling using bindgen under x86_64, but requires 32 bit #75

sprhawk opened this issue Jun 21, 2020 · 9 comments

Comments

@sprhawk
Copy link
Contributor

sprhawk commented Jun 21, 2020

I'm building btrfsutil-rs,
it complains following errors:

| --- stdout
| cargo:rustc-link-lib=btrfsutil
| cargo:rerun-if-changed=btrfsutil_wrapper.h
| cargo:rerun-if-changed=bindgen_whitelist.toml
|
| --- stderr
| /usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
| /usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found, err: true
| thread 'main' panicked at 'Unable to generate bindings: ()', deps/btrfsutil-rs/build.rs:44:39
| stack backtrace:

I guess is compiler when running build.rs is looking for 32bit lib, but why?

I can build ffi for libimobiledevice without problem

@sprhawk
Copy link
Contributor Author

sprhawk commented Jun 21, 2020

I have used BINDGEN_EXTRA_CLANG_ARGS to fixed it.

Is this a bug or intention ?

@sprhawk sprhawk closed this as completed Jun 21, 2020
@sprhawk sprhawk reopened this Jun 21, 2020
@nastevens
Copy link
Member

Can you share a minimal example that demonstrates this please?

@sprhawk
Copy link
Contributor Author

sprhawk commented Aug 28, 2020

I was busy doing project. I'll try to make a small example project recently

@hellow554
Copy link
Contributor

hellow554 commented Sep 16, 2020

Same issue here 🙋

In my case, I have a program, that depends on socketcan-alt, which uses bindgen, to produce bindings for the <linux/can.h> header.

Here's the error message for me (which is somewhat similar to @sprhawk's)

| error: failed to run custom build command for `socketcan-alt v0.2.2 (https://github.com/Hakuyume/socketcan-rs.git?rev=f79cef958e7f4ec68ee1e0f30a7b66df15411ad6#f79cef95)`
| 
| Caused by:
|   process didn't exit successfully: `/home/op/y_unic/build/tmp/work/cortexa7t2hf-neon-vfpv4-mut-linux-gnueabi/emv-test/1.0-r0/target/release/build/socketcan-alt-31d2e4f812a3f006/build-script-build` (exit code: 101)
|   --- stderr
|   /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
|   /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found, err: true

I'm building for an arm device, so like sprhawk not for the same platform. Maybe that's the issue?

A question, which you might be able to answer: What target is bindgen aiming at? The host or target platform, when he's looking for the <linux/can.h> file (e.g. does he try to use the recipe-sysroot or recipse-sysroot-native directory?)

@hellow554
Copy link
Contributor

It seems to me, that he uses my systems /usr/include/linux/types.h file, instead of the sysroot ones. Is that possible? I don't think, that that is inteded, right?

@ryankurte
Copy link

this appears to be a common issue with bindgen, may be related to the "Pre-built bindgen outputs often do not match target architecture sizes" section here.

@sprhawk
Copy link
Contributor Author

sprhawk commented Jan 31, 2021

use following defines in layer to fixed it:

export BINDGEN_EXTRA_CLANG_ARGS
BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=${WORKDIR}/recipe-sysroot -I${WORKDIR}/recipe-sysroot/usr/include"

@sprhawk sprhawk closed this as completed Jan 31, 2021
@hellow554
Copy link
Contributor

Hey @sprhawk
That looks like a proper fix for this Problem. IMHO this should be included into this layer.
What do you think @nastevens ?

@nastevens
Copy link
Member

nastevens commented Feb 10, 2021

@hellow554 I'm not sure that it belongs directly in this layer, but I am more than happy to accept a PR to add something to the README since I suspect that there is a lot of crossover between people using Yocto and needing to interface Rust with C.

If this were to be included in the layer I'd rather see it as a .bbclass specifically for supporting bindgen. I don't want to lose track of this idea so I've opened #96. Please feel free to comment on that if you have specific ideas of what would be useful!

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

4 participants