meta-rust-bin icon indicating copy to clipboard operation
meta-rust-bin copied to clipboard

Incorporate bindgen support

Open nastevens opened this issue 3 years ago • 4 comments

Adapted from #75

Presumably there is a large crossover between people using meta-rust-bin and people who need to interface C with Rust. Providing a "paved path" for using bindgen would therefore be useful.

I am unaware of any existing recipes/layers to support bindgen in yocto right now but would be happy to be proven wrong.

nastevens avatar Feb 10 '21 02:02 nastevens

https://github.com/rust-embedded/meta-rust-bin/issues/75#issuecomment-776399157

I'm not sure that it belongs directly in this layer

I mean, where else? This layer is about compiling software with Rust. That includes bindgen as well, because it's part of the rust ecosystem. So IMHO it should be meta-rust-bins job to tell clang/bindgen where the real sysroot is.

I can see, that this is very specific to one package (namely bindgen) and other may have different quirks (I don't know anything about cbindgen or similar).

So, either we can have a generic environment variable, e.g. CLANG_ARGS which will be accepted by all packages that need to deal with it, or we try to reach the maintainer of said packages and ask for their 2 cents on this topic.

hellow554 avatar Feb 10 '21 08:02 hellow554

ping @nastevens :)

hellow554 avatar Aug 03 '21 06:08 hellow554

Any workout here? I'm investigate simillar issue with crosscompilation of redisjson and pretty sure that one could be the root of bindgen problems https://github.com/rust-lang/rust-bindgen/pull/1915 But it's implented patch already ?

TopperBG avatar Oct 12 '21 07:10 TopperBG

As a Workaround use https://github.com/rust-embedded/meta-rust-bin/issues/75#issuecomment-770340164

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

use it like this:

$ cat my-file.bb
inherit cargo

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

hellow554 avatar Oct 12 '21 07:10 hellow554