cross compiling #53

Open
opened 2022-01-13 03:59:29 +00:00 by rtwfroody · 4 comments
rtwfroody commented 2022-01-13 03:59:29 +00:00 (Migrated from github.com)

I'm trying to cross compile the example, and am having no luck.

Using cross:

tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ cat Cross.toml 
[build.env]
passthrough = [ "DEP_LV_CONFIG_PATH" ]
tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cross build --example demo --target=armv7-unknown-linux-gnueabihf --features="alloc"
warning: field is never read: `r_type`
   --> lvgl-codegen/src/lib.rs:306:5
    |
306 |     r_type: Option<Box<syn::Type>>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `lvgl-codegen` (lib) generated 1 warning
   Compiling lvgl-sys v0.5.2 (/project/lvgl-sys)
error: failed to run custom build command for `lvgl-sys v0.5.2 (/project/lvgl-sys)`

Caused by:
  process didn't exit successfully: `/target/debug/build/lvgl-sys-c9bd983769ee75ba/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'Directory /home/tnewsome/projects/fahrenheit/lvgl-rs/examples/include referenced by DEP_LV_CONFIG_PATH needs to exist', lvgl-sys/build.rs:32:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

I assume there is some way to set DEP_LV_CONFIG_PATH to a value that works inside the container, but I've had no luck in figuring out the solution.

Using --target:

tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo build --target armv7-unknown-linux-gnueabihf --example demo --features=alloc
warning: field is never read: `r_type`
   --> lvgl-codegen/src/lib.rs:306:5
    |
306 |     r_type: Option<Box<syn::Type>>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `lvgl-codegen` (lib) generated 1 warning
warning: 1 Build compiler: cc
warning: 1 Build compiler: arm-linux-gnueabihf-gcc
   Compiling lvgl v0.5.2 (/home/tnewsome/projects/fahrenheit/lvgl-rs/lvgl)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "/home/tnewsome/projects/fahrenheit/lvgl-rs/target/armv7-unknown-linux-gnueabihf/debug/examples/demo-2fe78188483d1610.121qmq4pggluyri0.rcgu.o" ...
...
  = note: /usr/bin/ld: /home/tnewsome/projects/fahrenheit/lvgl-rs/target/armv7-unknown-linux-gnueabihf/debug/examples/demo-2fe78188483d1610.121qmq4pggluyri0.rcgu.o: relocations in generic ELF (EM: 40)
...
          collect2: error: ld returned 1 exit status
          

error: could not compile `lvgl` due to previous error

The problem there seems to be that it's using cc and ld instead of the appropriate cross compiler and linker. I added a warning in lvgl-sys/build.rs. You can see that in the first invocation the compiler is set to cc, while in the second invocation it is set to arm-linux-gnueabihf-gcc which looks correct.

I'm trying to cross compile the example, and am having no luck. Using `cross`: ``` tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ cat Cross.toml [build.env] passthrough = [ "DEP_LV_CONFIG_PATH" ] tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cross build --example demo --target=armv7-unknown-linux-gnueabihf --features="alloc" warning: field is never read: `r_type` --> lvgl-codegen/src/lib.rs:306:5 | 306 | r_type: Option<Box<syn::Type>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: `lvgl-codegen` (lib) generated 1 warning Compiling lvgl-sys v0.5.2 (/project/lvgl-sys) error: failed to run custom build command for `lvgl-sys v0.5.2 (/project/lvgl-sys)` Caused by: process didn't exit successfully: `/target/debug/build/lvgl-sys-c9bd983769ee75ba/build-script-build` (exit status: 101) --- stderr thread 'main' panicked at 'Directory /home/tnewsome/projects/fahrenheit/lvgl-rs/examples/include referenced by DEP_LV_CONFIG_PATH needs to exist', lvgl-sys/build.rs:32:13 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... error: build failed ``` I assume there is some way to set DEP_LV_CONFIG_PATH to a value that works inside the container, but I've had no luck in figuring out the solution. Using `--target`: ``` tnewsome@compy-linux:~/projects/fahrenheit/lvgl-rs$ DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo build --target armv7-unknown-linux-gnueabihf --example demo --features=alloc warning: field is never read: `r_type` --> lvgl-codegen/src/lib.rs:306:5 | 306 | r_type: Option<Box<syn::Type>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: `lvgl-codegen` (lib) generated 1 warning warning: 1 Build compiler: cc warning: 1 Build compiler: arm-linux-gnueabihf-gcc Compiling lvgl v0.5.2 (/home/tnewsome/projects/fahrenheit/lvgl-rs/lvgl) error: linking with `cc` failed: exit status: 1 | = note: "cc" "/home/tnewsome/projects/fahrenheit/lvgl-rs/target/armv7-unknown-linux-gnueabihf/debug/examples/demo-2fe78188483d1610.121qmq4pggluyri0.rcgu.o" ... ... = note: /usr/bin/ld: /home/tnewsome/projects/fahrenheit/lvgl-rs/target/armv7-unknown-linux-gnueabihf/debug/examples/demo-2fe78188483d1610.121qmq4pggluyri0.rcgu.o: relocations in generic ELF (EM: 40) ... collect2: error: ld returned 1 exit status error: could not compile `lvgl` due to previous error ``` The problem there seems to be that it's using `cc` and `ld` instead of the appropriate cross compiler and linker. I added a warning in lvgl-sys/build.rs. You can see that in the first invocation the compiler is set to `cc`, while in the second invocation it is set to `arm-linux-gnueabihf-gcc` which looks correct.
rafaelcaricio commented 2022-01-27 11:49:49 +00:00 (Migrated from github.com)

Could you contextualize me here on what is cross?

Could you contextualize me here on what is `cross`?
rtwfroody commented 2022-01-27 16:37:44 +00:00 (Migrated from github.com)

I was referring to https://github.com/cross-rs/cross, version 0.2.1.

I was referring to https://github.com/cross-rs/cross, version 0.2.1.
rafaelcaricio commented 2022-01-27 18:37:36 +00:00 (Migrated from github.com)

Does this path exists inside the container: /home/tnewsome/projects/fahrenheit/lvgl-rs/examples/include ? I don't think so (I doubt you are not mounting your system root path as root path of the container). I believe here you will need to add the path that works for the container in the DEP_LV_CONFIG_PATH env var.

Maybe try to see what are the paths inside the container and change the variable to point to that.

Does this path exists inside the container: `/home/tnewsome/projects/fahrenheit/lvgl-rs/examples/include` ? I don't think so (I doubt you are not mounting your system root path as root path of the container). I believe here you will need to add the path that works for the container in the `DEP_LV_CONFIG_PATH ` env var. Maybe try to see what are the paths inside the container and change the variable to point to that.
rtwfroody commented 2022-02-02 04:36:26 +00:00 (Migrated from github.com)

The path definitely does not exist. I was hoping somebody else had already cross-compiled this library so I wouldn't have to learn too many details about cross (or about using --target) but it sounds like nobody has yet. I might spend some more time digging into this later.

The path definitely does not exist. I was hoping somebody else had already cross-compiled this library so I wouldn't have to learn too many details about `cross` (or about using `--target`) but it sounds like nobody has yet. I might spend some more time digging into this later.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: rafaelcaricio/lvgl-rs#53
No description provided.