cross-rs/cross

error[E0463]: can't find crate for `std`

tae-soo-kim opened this issue · 6 comments

Checklist

Describe your issue

$ cargo new --bin hello
$ cd hello
$ cross build --target aarch64-unknown-linux-gnu
error[E0463]: can't find crate for `std`
  |
  = note: the `aarch64-unknown-linux-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add aarch64-unknown-linux-gnu`
$ rustup target add aarch64-unknown-linux-gnu
info: component 'rust-std' for target 'aarch64-unknown-linux-gnu' is up to date

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

No response

Additional information / notes

Looks like cross is not able to find downloaded rust std.

I can only compile using nightly toolchain with -Z build-std. This option is unavailable when using stable toolchain.

try uninstalling the target and adding it back

rustup target remove aarch64-unknown-linux-gnu and then rustup target add aarch64-unknown-linux-gnu

also, make sure that the cargo you're defaulting to is actually managed by rustup

easiest way to check that would be RUSTUP_TOOLCHAIN=test cargo -V which should fail with error: override toolchain 'test' is not installed: the RUSTUP_TOOLCHAIN environment variable specifies an uninstalled toolchain

The terminal output is exactly as you described in those two replies. However cross build still doesn't work.

this might be a permission problem where the target component folder is not readable by podman

Can you check the permissions in the rustup folder

$ rustup which cargo
/path/to/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo

$ ls -la /path/to/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/
drwxr-xr-x  30 emil  staff     960 Sep 21 20:26 .
drwxr-xr-x  23 emil  staff     736 Sep 21 20:26 ..
drwxr-xr-x   4 emil  staff     128 Sep 21 20:26 aarch64-apple-darwin
drwxr-xr-x   3 emil  staff      96 Sep 21 20:26 aarch64-unknown-linux-gnu

and then just for sanity

podman run -v /rustup:/path/to/.rustup/ -it ubuntu:20.04 ls -la /rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/
# should output the same thing as above

Thank you! There seems to be a problematic file /rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/components that has a non-container_file_t SELinux label. And this file cannot be accessed in the container. I don't think Rust or rustup itself changes SELinux label in any way. I guess it's cross that changed these labels in the rustup folder but it's missing this one?

I think running rustup target remove aarch64-unknown-linux-gnu and then rustup target add aarch64-unknown-linux-gnu is creating a new components file with a non-container_file_t label. This invalidates the change made by cross. And cross is not checking the label correctness.

I noticed SELinux labels of project source files in src are changed too. I'm wondering if the original labels on my source files can be kept? For example, when I serve the source dir on a web server, I need label httpd_sys_content_t. But this label is gone if replaced by container_file_t.

try using cross installed from main cargo install cross --git https://github.com/cross-rs/cross we've done some changes to the mounts that weren't included in 0.2.5, you can see the command cross does with -v