Skip to content

Using rust from distro repo makes cross mount wierd directory #1198

@blinxen

Description

@blinxen

Checklist

  • I've looked through the issues and pull requests for similar reports

Describe your issue

I have installed rust from the official fedora repository but I still want to sometimes use cross for testing purposes. So for this I installed rustup and made my default toolchain to be the rust version that I installed via the package manager. My ~/.rustup/toolchains directory looks like this:

drwxr-xr-x. 1 xxx xxx 42 Jan 30 22:18 stable-x86_64-unknown-linux-gnu
lrwxrwxrwx. 1 xxx xxx  4 Jan 30 22:18 system -> /usr

When I try to run the following command (added -v to see what cross is trying to do):

CROSS_CONTAINER_ENGINE=podman cross +stable test --target i686-unknown-linux-gnu -v

Then I get an error message that looks like this:

+ cargo +stable metadata --format-version 1 --filter-platform i686-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup --verbose toolchain add stable --profile minimal
verbose: read metadata version: '12'
verbose: updating existing install for 'stable-x86_64-unknown-linux-gnu'
verbose: toolchain directory: '/home/xxx/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
verbose: creating temp file: /home/xxx/.rustup/tmp/mce693vqz1yhvje6_file
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'
verbose: downloading with reqwest
verbose: deleted temp file: /home/xxx/.rustup/tmp/mce693vqz1yhvje6_file
verbose: toolchain is already up to date

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.67.0 (fc594f156 2023-01-24)

info: checking for self-updates
+ rustup target list --toolchain stable
+ rustup component list --toolchain stable
+ /usr/bin/podman
+ /usr/bin/podman run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=xxx' --rm -v /home/xxx/.xargo:/xargo:Z -v /home/xxx/.cargo:/cargo:Z -v /cargo/bin -v /home/xxx/xxx/fallible_collections:/project:Z -v /stable:/rust:Z,ro -v /home/xxx/xxx/fallible_collections/target:/target:Z -w /project -i -t ghcr.io/cross-rs/i686-unknown-linux-gnu:0.2.4 sh -c 'PATH=$PATH:/rust/bin cargo test --target i686-unknown-linux-gnu -v'
Error: statfs /stable: no such file or directory
+ rustup component list --toolchain stable

It seems wierd to me that cross is trying to mount a /stable directory. Replacing the +stable with +PATH_TO_stable-x86_64-unknown-linux-gnu seems to fix my problem. Is this a bug or is this intended?

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

i686-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

0.2.4

Example

No response

Additional information / notes

No response

Activity

Emilgardis

Emilgardis commented on Feb 2, 2023

@Emilgardis
Member

Interesting! Do you get the same behaviour when using cross installed from this git repo? We changed how the toolchain is mounted in #947

This is the offending code:

.args(&["-v", &format!("{}:/rust:Z,ro", dirs.sysroot.to_utf8()?)])
and this is how we do it now.

What is the output of rustc +stable --print sysroot on your system?

edit: also, what's the output of rustc --print sysroot? the same?

blinxen

blinxen commented on Feb 2, 2023

@blinxen
Author

Do you get the same behaviour when using cross installed from this git repo

Error: statfs /stable-x86_64-unknown-linux-gnu: no such file or directory

What is the output of rustc +stable --print sysroot on your system?

> rustc +stable --print sysroot
/home/XXX/.rustup/toolchains/stable-x86_64-unknown-linux-gnu
> rustc  --print sysroot
/usr
Emilgardis

Emilgardis commented on Feb 2, 2023

@Emilgardis
Member

alright, so cross assumes that the sysroot of the default toolchain is in the same place as the other ones, I think that should be considered a bug.

I think the way forward is for us to fix this inconsistency (somehow), and in the meantime you should be able to do RUSTUP_TOOLCHAIN=stable cross ...

Emilgardis

Emilgardis commented on Feb 2, 2023

@Emilgardis
Member

Can you show me the calls cross does when using the version from main btw. Would be appreciated!

blinxen

blinxen commented on Feb 2, 2023

@blinxen
Author

I think the way forward is for us to fix this inconsistency (somehow), and in the meantime you should be able to do RUSTUP_TOOLCHAIN=stable cross ...

This fixes my problem :D

Can you show me the calls cross does when using the version from main btw. Would be appreciated!

How can I do this?

blinxen

blinxen commented on Feb 2, 2023

@blinxen
Author

Do you mean these calls?

+ cargo +stable metadata --format-version 1 --filter-platform i686-unknown-linux-gnu
+ rustc --print sysroot
+ /usr/bin/rustc
+ /usr/bin/podman
+ /usr/bin/podman version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ /usr/bin/podman info -f '{{ .Version.OsArch }}'
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ /usr/bin/podman run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/home/XXX/.xargo' -e 'CARGO_HOME=/home/XXX/.cargo' -e 'CROSS_RUST_SYSROOT=/stable-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e CROSS_CONTAINER_ENGINE -e CROSS_CUSTOM_TOOLCHAIN -e TERM -e 'USER=XXX' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=0' -e 'CROSS_RUSTC_PATCH_VERSION=0' --name cross-stable-x86_64-unknown-linux-gnu-3db1b-fc594f156-i686-unknown-linux-gnu-a5836-1675341298420 --rm -v /home/XXX/.xargo:/home/XXX/.xargo:z -v /home/XXX/.cargo:/home/XXX/.cargo:z -v /home/XXX/.cargo/bin -v /home/XXX/XXX/fallible_collections:/home/XXX/XXX/fallible_collections:z -v /stable-x86_64-unknown-linux-gnu:/stable-x86_64-unknown-linux-gnu:z,ro -v /home/XXX/XXX/fallible_collections/target:/target:z -w /home/XXX/XXX/fallible_collections -t ghcr.io/cross-rs/i686-unknown-linux-gnu:main sh -c 'PATH="$PATH":"/stable-x86_64-unknown-linux-gnu/bin" cargo test --target i686-unknown-linux-gnu vec -v'
Error: statfs /stable-x86_64-unknown-linux-gnu: no such file or directory
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
Emilgardis

Emilgardis commented on Feb 2, 2023

@Emilgardis
Member

perfect, thanks!

blinxen

blinxen commented on Feb 2, 2023

@blinxen
Author

If you need any help with fixing this then just let me know.

linked a pull request that will close this issue on Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @Emilgardis@blinxen

      Issue actions

        Using rust from distro repo makes cross mount wierd directory · Issue #1198 · cross-rs/cross