cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.75k stars 377 forks source link

Can't cross compile to armv7 from Fedora36 + podman #1010

Closed tmayoff closed 2 years ago

tmayoff commented 2 years ago

Checklist

Describe your issue

I'm trying to setup a cross compile setup for my to ease my development of a raspberry pi project.

But after the initial clone / setup all I get is this

Error: lsetxattr /nix/store/.links: operation not permitted

Looking around it seems to be a SELinux issue but I'm not sure how to go about fixing it

What target(s) are you cross-compiling for?

armv7-unknown-linux-gnueabihf

Which operating system is the host (e.g computer cross is on) running?

What architecture is the host?

What container engine is cross using?

cross version

cross 0.2.4 (47df5c7 2022-08-30)

Example

git clone --branch cross https://github.com/tmayoff/lgaircon.git

cross build --target armv7-unknown-linux-gnueabihf

Additional information / notes

No response

Alexhuszagh commented 2 years ago

Does it affect any other targets, just wondering? Also, I don't think it should be using /nix/store, as we don't create it if it isn't provided nor do we pass NIX_STORE as an environment variable if it isn't provided. /nix/store shouldn't be present on Fedora, so it's not clear immediately to me why this is happening. If the directory doesn't exist and NIX_STORE or NIX_STORE_DIR is provided, we should fail fast with a permissions error, so this wouldn't reproduce the above error.

lsetxattr definitely is an SELinux issue, however. Can you try aarch64-unknown-linux-gnu and aarch64-linux-android just to test? Can you also report if /nix/store exists, and if NIX_STORE or NIX_STORE_DIR is set? Also, can you report the value of getenforce (to see if SELinux is set to enforcing or permissive mode)?

Thanks.

Alexhuszagh commented 2 years ago

Pinging @otavio, do you know anything about this? I know /nix/store/.links is actually a valid part of the Nix store for NixOS, which seems odd given the Fedora host. Possibly related to #989.

tmayoff commented 2 years ago

Okay so it does happen with the other targets you suggested, /nix/store exists but the environment variables don't I do however remember doing something NIX related (I don't remember what). I remove /nix and solved this.

tmayoff commented 2 years ago

Small question is it possible to cross compile when relying on C libraries, like sqlite3 and lirc_client

I get these errors

= note: /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: cannot find -llirc_client
          /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: cannot find -lsqlite3
          collect2: error: ld returned 1 exit status
Alexhuszagh commented 2 years ago

Okay so it does happen with the other targets you suggested, /nix/store exists but the environment variables don't I do however remember doing something NIX related (I don't remember what). I remove /nix and solved this.

So then the issue is it's trying to mount a directory it doesn't have permissions to modify as the current users, which is odd.... We might need to change the SELinux labels.

As for the glibc errors, see the pinned issue #724. For the other ones with external dependencies, we've documented this on the wiki. Let me know if anything is unclear. It's absolutely possible to cross-compile with C dependencies, and we understand it's a bit trickier to setup, so we've tried to make the process as simple as possible.

Alexhuszagh commented 2 years ago

Closed in favor of #1012, which details this issue more precisely and generally.