How to compile have cargo build within a meta-layer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to compile have cargo build within a meta-layer

Jump to solution
1,024 Views
cbugk-dannie
Contributor II

I was following this example on inheriting cargo.bbclass and compiling a simple project:
https://www.youtube.com/watch?v=aPsMuSU-Btw

However, I got following error:
```
NOTE: Executing Tasks
ERROR: my-test-0.1-r0 do_compile: ExecutionError('/opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257', 101, None, None)
ERROR: Logfile of failure stored in: /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/log.do_compile.24257
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: Using rust targets from /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/rust-targets/
| NOTE: cargo = /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/recipe-sysroot-native/usr/bin/cargo
| NOTE: cargo build -v --frozen --target aarch64-poky-linux-gnu --release --manifest-path=/opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git//Cargo.toml
| error: the lock file /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git/Cargo.lock needs to be updated but --frozen was passed to prevent this
| If you want to try to generate the lock file without accessing the network, remove the --frozen flag and use --offline instead.
| WARNING: /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257:185 exit 101 from '"cargo" build -v --frozen --target aarch64-poky-linux-gnu --release --manifest-path=/opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git//Cargo.toml "$@"'
| WARNING: Backtrace (BB generated script):
| #1: oe_cargo_build, /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257, line 185
| #2: cargo_do_compile, /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257, line 157
| #3: do_compile, /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257, line 152
| #4: main, /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/temp/run.do_compile.24257, line 198
ERROR: Task (/opt/yocto/imx-6.6.3-1.0.0-build/sources/meta-my-test/recipes-cargo/install/my-test_0.1.bb:do_compile) failed with exit code '1'
NOTE: Tasks Summary: Attempted 5745 tasks of which 5743 didn't need to be rerun and 1 failed.
```

I had run `bitbake -f my-test core-image-minimal`. BBLAYERS was appended as well.

Simply: How to compile and install a Rust program into iMX93EVK ?

Tags (1)
0 Kudos
Reply
1 Solution
976 Views
cbugk-dannie
Contributor II

I am a fool, more precisely a newbie. The repo I was referring to (https://gitlab.com/pbarker.dev/rust/print-rand) had no Cargo.lock file. I ran it manually on my machine copied file over and voila!

The path the repo was downloaded was `/opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git/` by default. Well I can override that somehow. This was a non-issue. Well hopefully helps other noobs out in the future.

Edit: Some other pitfalls:
* `IMAGE_INSTALL` did not work in my case, but `CORE_IMAGE_EXTRA_INSTALL` allowed me to add custom layer's bb files to `bitbake core-image-minimal` build. Recipe name is irrelevant for all I can tell.
* On first run, I encountered missing crate hashes. Luckily the fix is printed on. Adding those with a `.inc` file beside the `.bb` file was sufficient to get over it without modifying .bb file `cargo bitbake` command generates.

View solution in original post

0 Kudos
Reply
5 Replies
977 Views
cbugk-dannie
Contributor II

I am a fool, more precisely a newbie. The repo I was referring to (https://gitlab.com/pbarker.dev/rust/print-rand) had no Cargo.lock file. I ran it manually on my machine copied file over and voila!

The path the repo was downloaded was `/opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git/` by default. Well I can override that somehow. This was a non-issue. Well hopefully helps other noobs out in the future.

Edit: Some other pitfalls:
* `IMAGE_INSTALL` did not work in my case, but `CORE_IMAGE_EXTRA_INSTALL` allowed me to add custom layer's bb files to `bitbake core-image-minimal` build. Recipe name is irrelevant for all I can tell.
* On first run, I encountered missing crate hashes. Luckily the fix is printed on. Adding those with a `.inc` file beside the `.bb` file was sufficient to get over it without modifying .bb file `cargo bitbake` command generates.

0 Kudos
Reply
970 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Good

0 Kudos
Reply
1,006 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

Rust is not include in the default BSP, you have to add it to yocto.

https://interrupt.memfault.com/blog/rust-in-yocto

 

Regards

 

0 Kudos
Reply
979 Views
cbugk-dannie
Contributor II

cbugk-dannie
cbugk-dannie
Contributor I
BTW, this line in the original post tells me cargo itself is functional:
```
error: the lock file /opt/yocto/imx-6.6.3-1.0.0-build/build_fsl-imx-wayland/tmp/work/armv8a-poky-linux/my-test/0.1/git/Cargo.lock needs to be updated but --frozen was passed to prevent this
```
What I am missing is not knowing how to use the default Yocto behaviour of --frozen with an ordinary cargo project.

But I suppose this is outside of the scope of NXP. Still, ou guys commented on having scripts and all on some other posts on this forum. So thought worth a shot, would appreciate any such tips if any.

0 Kudos
Reply
987 Views
cbugk-dannie
Contributor II

Firstly, thanks.

I get following error when added `DEPENDS += " meta-rust "` to bb file. I thought `meta-rust` was absorbed into `oe-core`, so do I really need it on nanbield?

```
Loading cache: 100% |########################################################################################################################| Time: 0:00:00Loaded 5451 entries from dependency cache. NOTE: Resolving any missing task queue dependencies ERROR: Nothing PROVIDES 'meta-rust' (but /opt/yocto/imx-6.6.3-1.0.0-build/sources/meta-my-test/recipes-my/company/my-test_0.1.bb DEPENDS on or otherwise requires it) ERROR: Required build target 'my-test' has no buildable providers.
Missing or unbuildable dependency chain was: ['my-test', 'meta-rust'] Summary: There were 2 ERROR messages, returning a non-zero exit code.
```

Edit: I also added it as another echo of `BBLAYERS` in imx-setup-release.sh and to manifest of repo tool. However, nanbield is not compatible with this modus operandi:

```ERROR: Layer rust-layer is not compatible with the core layer which only supports these series: nanbield (layer is compatible with mickledore honister hardknott gatesgarth kirkstone)```

 

 

0 Kudos
Reply