cross-rs/cross

failed to build to aarch64-unknown-linux-gnu

ZHider opened this issue · 4 comments

Checklist

Describe your issue

Failed to cross build on Windows 10 x64, Docker for desktop on WSL2.

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

aarch64-unknown-linux-gnu

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

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

cargo init --bin hello
cross run --target aarch64-unknown-linux-gnu
   Compiling hello v0.1.0 (/project)
warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.1wzo2ddvk07ysav3.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/1wzo2ddvk07ysav3.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.2yawwvxy47jniai0.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/2yawwvxy47jniai0.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.3qo22uka2ymqkdm9.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/3qo22uka2ymqkdm9.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.45lasg6m76ggyj3p.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/45lasg6m76ggyj3p.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.46rhcooeqh7ue7m9.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/46rhcooeqh7ue7m9.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.544fa8djmnmenqqi.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqc9uz042o-1obk22-working/544fa8djmnmenqqi.o`: Operation not permitted (os error 1)

warning: `hello` (bin "hello") generated 6 warnings
error: failed to link or copy `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19` to `/target/aarch64-unknown-linux-gnu/debug/hello`

Caused by:
  Operation not permitted (os error 1)

Additional information / notes

rustup toolchain: stable-x86_64-pc-windows-gnu (default)
(Also tested on stable-mvsc and the result remains the same)
rustc 1.73.0 (cc66ad468 2023-10-03)
Docker version 24.0.6, build ed223bc

can you try a cargo clean and then retry?

can you try a cargo clean and then retry?

D:\Hider\Code\hello>cargo clean

D:\Hider\Code\hello>cross build --target aarch64-unknown-linux-gnu
   Compiling hello v0.1.0 (/project)
warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.1wzo2ddvk07ysav3.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/1wzo2ddvk07ysav3.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.2yawwvxy47jniai0.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/2yawwvxy47jniai0.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.3qo22uka2ymqkdm9.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/3qo22uka2ymqkdm9.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.45lasg6m76ggyj3p.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/45lasg6m76ggyj3p.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.46rhcooeqh7ue7m9.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/46rhcooeqh7ue7m9.o`: Operation not permitted (os error 1)

warning: error copying object file `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19.544fa8djmnmenqqi.rcgu.o` to incremental directory as `/target/aarch64-unknown-linux-gnu/debug/incremental/hello-wlpynlpr6m1x/s-gqd7g6s4ua-9e7pg9-working/544fa8djmnmenqqi.o`: Operation not permitted (os error 1)

warning: `hello` (bin "hello") generated 6 warnings
error: failed to link or copy `/target/aarch64-unknown-linux-gnu/debug/deps/hello-05828c9a82637a19` to `/target/aarch64-unknown-linux-gnu/debug/hello`

Caused by:
  Operation not permitted (os error 1)

Thank you for your advice but nothing changed.

It looks like it had something wrong with the permission while copying files in the mounted /target dir. I found that to run docker run with the parameter --privileged might solve the problem but since it's not me but cross to deal with the container I'm not able to try the solution.

C:\test\hello>cross clean
[cross] note: Falling back to `cargo` on the host.

C:\test\hello>cross build --target aarch64-unknown-linux-gnu
   Compiling hello v0.1.0 (/project)
    Finished dev [unoptimized + debuginfo] target(s) in 8.81s

Everything works now! The filesystem of D: drive is ReFS, and for C: is NTFS. It looks like docker's mount doesn't work properly on the refs filesystem.
The ReFS filesystem doesn't support file linking, cargo will fallback to file copying instead of linking, and cargo build still works correctly, but it seems docker doesn't.

Interesting!

If you need to add --privileged you can use CARGO_CONTAINER_OPTS="--privileged" to tell cross to add it.