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

Support for `Cross.toml` configs

Open redeexpressos opened this issue 1 year ago • 3 comments
trafficstars

Trying to build a crate that depends on protoc. When cross-compiling, I have to add Cross.toml:

[build]
default-target = "armv7-unknown-linux-gnueabihf"
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get --assume-yes install protobuf-compiler:$CROSS_DEB_ARCH",
]

How can I add that configuration when compiling with this layer?

redeexpressos avatar Jul 24 '24 11:07 redeexpressos

I don't think calling apt-get install, etc. would make sense in the Yocto context. I suggest to try to modify your bit bake recipe to include protoc in the native sysroot, that's hopefully in the path. Something like DEPENDS += " protobuf-native"

tronical avatar Jul 24 '24 12:07 tronical

@tronical Thanks for answering. However, doesn't this layer use cross to build? When I use Cross, I also have to install protoc via a Cross.toml like this:

[build]
default-target = "armv7-unknown-linux-gnueabihf"
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH",
    "apt-get update && apt-get --assume-yes install protobuf-compiler:$CROSS_DEB_ARCH",
]

redeexpressos avatar Jul 25 '24 07:07 redeexpressos

However, doesn't this layer use cross to build?

No, meta-rust-bin does not use cross to build. In fact, it doesn't build rust, it fetches the right binaries and makes them available (via bit bake classes) to recipes for invocation. The actual build of crates compiled with meta-rust-bin happen inside the yocto/bitbake environment, not inside a docker container (like cross). In short, cross-compilation with meta-rust-bin is like calling cargo build --target=aarch64-unknown-linux-gnu (or similar), along with a cargo config set up to invoke the correct linker, set the right sysroot, etc - behind the scenes.

tronical avatar Jul 25 '24 08:07 tronical